コード例 #1
0
ファイル: Decider.cs プロジェクト: AndrewPool/Chess
 //this is for internal Deciderness.
 public Decider(DeciderNode node)
 {
     root = node;
     if (root.IsLeaf)
     {
         root.SetMovesTo();
     }
 }
コード例 #2
0
ファイル: Decider.cs プロジェクト: AndrewPool/Chess
    private Move StupidHeapBuild()
    {
        Debug.Log("picking one");
        IDictionary <DeciderNode, Empty> nodesInTree = new Dictionary <DeciderNode, Empty>(10000);


        MaxHeap heap = new MaxHeap(root);

        Debug.Log("adding nodes to checklist");
        root.AddNodesToTreeRecursivly(nodesInTree);

        if (root.to.Keys == null)
        {
            return(null);
        }
        Debug.Log("popping and adding to tree");
        while (nodesInTree.Count < 10000 && heap.HasTop())
        {
            DeciderNode top = (DeciderNode)heap.Pop();


            top.SetMovesTo();
            foreach (DeciderNode node in top.to.Values)
            {
                if (!nodesInTree.ContainsKey(node))
                {
                    heap.AddToHeap(node);
                    nodesInTree.Add(node, new Empty());
                }
            }
        }
        Debug.Log(heap.Count);
        // picking the best for the player;

        DeciderNode topOfHeap = (DeciderNode)heap.Pop();

        while (topOfHeap.Player != root.Player && heap.HasTop())
        {
            topOfHeap = (DeciderNode)heap.Pop();
        }

        return(MoveForNode(topOfHeap));
    }
コード例 #3
0
ファイル: ChessGameTests.cs プロジェクト: AndrewPool/Chess
    public void ChessGameTestsSimplePasses()
    {
        SmartSquare[,] dumbSquares = SmartSquare.StandardBoardSetUp();

        Decider game = new Decider(dumbSquares);

        int choices = game.Choices().Count;

        Debug.Log(choices);


        DeciderNode node = new DeciderNode(SmartSquare.StandardBoardSetUp());

        node.SetMovesTo();

        Debug.Log(node.to.Count);
        //TestPickOneForMe();

        //PlayGame(10);
    }
コード例 #4
0
ファイル: Decider.cs プロジェクト: AndrewPool/Chess
 /// <summary>
 /// This is for setting up. don't feed a game in progress here, it will destroy the whole tree!
 /// </summary>
 /// <param name="setupState"></param>
 public Decider(SmartSquare[,] setupState)
 {
     root = new DeciderNode(setupState);
     root.SetMovesTo();//first player
     //we know this is a leaf
 }