Exemple #1
0
        // Deep copy board
        public Board(Board board)
        {
            this.game = board.game;

            foreach (KeyValuePair<char, Vehicle> pair in board.vehicles)
            {
                this.vehicles[pair.Key] = pair.Value.Copy();
            }
            this.ownVehicle = this.vehicles['x'];

            this.board = new Vehicle[board.board.GetLength(0), board.board.GetLength(1)];

            for (int x = 0; x < board.board.GetLength(0); x++)
            {
                for (int y = 0; y < board.board.GetLength(1); y++)
                {
                    Vehicle v = board.board[x, y];
                    if (v != null)
                    {
                        v = this.vehicles[v.identity];
                    }
                    this.board[x, y] = v;
                }
            }

            switch (game.outputMode)
            {
                case Game.OutputMode.Solve:
                    this.appliedMoves.AddRange(board.appliedMoves);
                    break;
                case Game.OutputMode.Count:
                    this.generation = board.generation + 1;
                    break;
            }
        }
Exemple #2
0
        public void TestBoard(Board originalBoard, Move move)
        {
            if (this.foundTarget != null)
                return;

            TestBoard(originalBoard.BoardForMove(move));
        }
Exemple #3
0
        public void TestBoard(Board board)
        {
            if (this.foundTarget != null)
                return;

            int boardHash = board.GetHashCode();
            if (!testedBoardHashes.Add(boardHash))
            {
                return;
            }

            if (board.IsTarget())
            {
                this.foundTarget = board;
                return;
            }

            foreach (Move move in board.getMoves())
            {
                this.movesQueue.Enqueue(new Tuple<Board, Move>(board, move));
            }
        }
Exemple #4
0
 public Game(OutputMode outputMode, Position targetPos, string[] boardString)
 {
     this.outputMode = outputMode;
     this.targetPos = targetPos;
     this.board = new Board(this, boardString);
 }