示例#1
0
        public override void Visitor(ProbabilisticGameNode cloned, GameTree <GameNode> tree, QueueActionEventArgs e)
        {
            // If the action queue is empty, we have reached a leaf node game state
            // so compare it for equality with other final game states
            if (cloned.Game.ActionQueue.IsEmpty)
            {
                if (!cloned.Game.EquivalentTo(e.Game))
                {
                    tree.LeafNodeCount++;
                    // This will cause the game to be discarded if its fuzzy hash matches any other final game state
                    // TODO: Optimize to use TLS and avoid spinlocks
                    lock (uniqueGames) {
                        if (!uniqueGames.ContainsKey(cloned.Game))
                        {
                            uniqueGames.Add(cloned.Game, cloned.Probability);
#if _TREE_DEBUG
                            DebugLog.WriteLine("UNIQUE GAME FOUND ({0}) - Hash: {1:x8}", uniqueGames.Count, cloned.Game.FuzzyGameHash);
                            DebugLog.WriteLine("{0:S}", cloned.Game);
#endif
                        }
                        else
                        {
                            uniqueGames[cloned.Game] += cloned.Probability;
#if _TREE_DEBUG
                            DebugLog.WriteLine("DUPLICATE GAME FOUND - Hash: {0:x8}", cloned.Game.FuzzyGameHash);
#endif
                        }
                    }
                }
            }
        }
示例#2
0
 public override void Visitor(ProbabilisticGameNode cloned, GameTree <GameNode> tree, QueueActionEventArgs e)
 {
     // If the action queue is empty, we have reached a leaf node game state
     // TODO: Optimize to use TLS and avoid spinlocks
     if (cloned.Game.ActionQueue.IsEmpty)
     {
         tree.LeafNodeCount++;
         lock (leafNodeGames) {
             leafNodeGames.Add(cloned);
         }
     }
 }
示例#3
0
 public virtual void Visitor(ProbabilisticGameNode cloned, GameTree <GameNode> tree, QueueActionEventArgs e)
 {
 }
示例#4
0
 public ProbabilisticGameNode(Game Game, ProbabilisticGameNode Parent = null, double Weight = 1.0, bool TrackChildren = true)
     : base(Game, Parent, Weight, TrackChildren)
 {
     Probability = (Parent != null ? Parent.Probability * Weight : Weight);
 }