Example #1
0
        public override GameState makeMove(GameState state, Object o)
        {
            GameState retVal = new GameState();
            //a move is the board itself
            HexapawnBoard move = ((HexapawnBoard)o).cloneBoard();

            //we need to:
            //find out whose move it is
            string playerToMove = getPlayerToMove(state);

            ArrayList newMoves;

            //set the player whose move is next
            if (playerToMove.Equals("W"))
            {
                retVal.put("player", "B");
                //add the new moves
                newMoves = move.getSuccessorBoards("B");
            }
            else
            {
                retVal.put("player", "W");
                //add the new moves
                newMoves = move.getSuccessorBoards("W");
            }

            retVal.put("moves", newMoves);
            retVal.put("board", move);
            retVal.put("utility", computeUtility(move,
                                                 getPlayerToMove(getState())));
            retVal.put("level", getLevel(state) + 1);
            //if (newMoves.Count != 0)
            presentState = retVal;

            return(retVal);
        }
Example #2
0
		public Hexapawn() 
		{
			ArrayList moves = new ArrayList();
			//first, add all possible moves from the initial state
			//assume white goes first
			//store moves as gameboards
			HexapawnBoard board = new HexapawnBoard();
			moves = board.getSuccessorBoards("W");

			//all the moves from the current state
			initialState.put("moves", moves);
			//the player whose move it is
			initialState.put("player", "W");

			initialState.put("utility", 0);
			//the board
			initialState.put("board", board);
			//the number of moves that have been made so far
			initialState.put("level", 0);
			presentState = initialState;
		}
Example #3
0
        public Hexapawn()
        {
            ArrayList moves = new ArrayList();
            //first, add all possible moves from the initial state
            //assume white goes first
            //store moves as gameboards
            HexapawnBoard board = new HexapawnBoard();

            moves = board.getSuccessorBoards("W");

            //all the moves from the current state
            initialState.put("moves", moves);
            //the player whose move it is
            initialState.put("player", "W");

            initialState.put("utility", 0);
            //the board
            initialState.put("board", board);
            //the number of moves that have been made so far
            initialState.put("level", 0);
            presentState = initialState;
        }