Example #1
0
        public override ulong GetMove(ulong board)
        {
            ulong player_board, opp_board;
            int   player_piecestoplace, opp_piecestoplace;

            if (Board.IsWhiteTurn(board))
            {
                player_board         = Board.WhiteBoard(board);
                opp_board            = Board.BlackBoard(board);
                player_piecestoplace = Board.WhitePiecesLeftToPlace(board);
                opp_piecestoplace    = Board.BlackPiecesLeftToPlace(board);
            }
            else
            {
                player_board         = Board.BlackBoard(board);
                opp_board            = Board.WhiteBoard(board);
                player_piecestoplace = Board.BlackPiecesLeftToPlace(board);
                opp_piecestoplace    = Board.WhitePiecesLeftToPlace(board);
            }

            ulong new_player_board;

            if (Board.IsPlacementPhase(board))
            {
                var new_piece = InterpretInput("Place piece at: ");

                new_player_board = player_board | new_piece;
                player_piecestoplace--;
            }
            else
            {
                var old_piece = InterpretInput("Take piece from: ");
                var new_piece = InterpretInput("And place at: ");
                new_player_board = player_board & ~old_piece | new_piece;
            }
            throw new NotImplementedException();

            // see if we made a run
            var   old_runs      = Board.GetRunPieces(player_board);
            var   new_runs      = Board.GetRunPieces(new_player_board);
            ulong new_opp_board = opp_board;

            if (new_runs != old_runs && Board.CountBits(new_runs) >= Board.CountBits(old_runs))
            {
                var remove_piece = InterpretInput("Remove piece at: ");

                new_opp_board &= ~remove_piece;
            }

            return(Board.CreateBoardForNextTurn(IsWhite, new_player_board, new_opp_board, player_piecestoplace, opp_piecestoplace));
        }
Example #2
0
        private void DumpMove(ulong board, ulong move)
        {
            if (Board.IsWhiteTurn(board))
            {
                Console.Write("White");
            }
            else
            {
                Console.Write("Black");
            }

            // get bits set in original that are no longer set
            var unset_bits = board & ~move;
            var set_bits   = move & ~board;

            ulong player_set;
            ulong player_unset;
            ulong opp_unset;

            if (Board.IsWhiteTurn(board))
            {
                player_set   = Board.WhiteBoard(set_bits);
                player_unset = Board.WhiteBoard(unset_bits);
                opp_unset    = Board.BlackBoard(unset_bits);
            }
            else
            {
                player_set   = Board.BlackBoard(set_bits);
                player_unset = Board.BlackBoard(unset_bits);
                opp_unset    = Board.WhiteBoard(unset_bits);
            }

            Console.Write(": ");
            if (player_unset != 0)
            {
                DumpPlace(player_unset);
                Console.Write(" -> ");
            }
            DumpPlace(player_set);
            if (opp_unset != 0)
            {
                Console.Write(" (");
                DumpPlace(opp_unset);
                Console.Write(")");
            }

            Console.WriteLine();
        }