예제 #1
0
파일: Main.cs 프로젝트: sander2/draughts
        public static void Main(string[] args)
        {
            Board b = new Board ();

            Player player1 = null;
            foreach (var a in args)
            {
                if (a.Contains("human"))
                    player1 = new HumanPlayer(b);
            }

            if (player1 == null)
                player1 = new AI(b, 10000);
            Player player2 = new AI(b, 10000);

            Player currentPlayer = player1;
            while (true)
            {
                b.PrintBoard();
                Move m = currentPlayer.GetMove();
                if (m == null)
                    break;
                m.Apply(b);
                b.currentColor = (b.currentColor == Color.White ? Color.Black : Color.White);
                currentPlayer = (currentPlayer == player1 ? player2 : player1);
            }
        }
예제 #2
0
파일: Move.cs 프로젝트: sander2/draughts
        /// <summary>
        /// Undo the move
        /// </summary>
        /// <param name="b">the board.</param>
        /// <param name="hash">Hash.</param>
        public override void Undo(Board b, ulong hash = 0)
        {
            #if CHECK_APPLY_UNDO
                
                Piece[,] pieces3 = new Piece[10,10];
                for (int q = 0; q < 10; q++)
                    for (int j = 0; j < 10; j++)
                        if (b.pieces[q,j] != null)
                            pieces3[q,j] = new Piece(q, j, b.pieces[q,j].color, b.pieces[q,j].type);

                for (int q = 0; q < 10; q++)
                    for (int j = 0; j < 10; j++)
                        if (b.pieces [q, j] != null)
                            if (pieces4 [q, j].color != b.pieces [q, j].color || (pieces4 [q, j].color != Color.None && b.pieces [q, j].type != pieces4 [q, j].type))
                            {
                                b.PrintBoard();
                                int qewqwe = 5;
                            }
            #endif

            int len = hops.Count;

            // required to do in steps for the case when begin == end
            
            Color c = b.pieces [hops [len - 1].targetX, hops [len - 1].targetY].color;
            b.pieces [hops [len - 1].targetX, hops [len - 1].targetY].color = Color.None;
            b.pieces [x, y].color = c;
            b.pieces [x, y].type = typePriorToApply;

            Color victimColor = (c == Color.Black ? Color.White : Color.Black);
            for (int i = 0; i < len; i++)
            {
                b.pieces [hops [i].victimX, hops [i].victimY].color = victimColor;
                b.pieces [hops [i].victimX, hops [i].victimY].type = hops[i].victimType;
            }

#if CHECK_APPLY_UNDO
            for (int q = 0; q < 10; q++)
                for (int j = 0; j < 10; j++)
                    if (b.pieces [q, j] != null)
                        if (pieces2 [q, j].color != b.pieces [q, j].color || (pieces2 [q, j].color != Color.None && b.pieces [q, j].type != pieces2 [q, j].type))
                        {
                            b.PrintBoard();
                            int qewqwe = 5;
                        }
#endif
        }