src/demo/TicTacToe.java
public void commitAction(Agent agent, int action) {
        gameBoard.makeMove(currentPlayerList.get(currentPlayer), action);
        gameBoard.updateState();
        gameStatus = gameBoard.updateGameStatus(currentPlayerList.get(currentPlayer));

        switch (gameStatus) {
            case ONGOING:
                currentPlayerList.get(currentPlayer).getAgent().respond(rewardStructure.MOVE);
                break;
            case NOUGHT_WON:
                for (Player player : currentPlayerList) {
                    if (!player.isHuman()) {
                        if (player.getPlayerRole() == PlayerRole.NOUGHT) {
                            player.won();
                            player.getAgent().respond(rewardStructure.WIN);
                        }
                        if (player.getPlayerRole() == PlayerRole.CROSS) {
                            player.lost();
                            player.getAgent().respond(rewardStructure.LOST);
                        }
                    }
                }
                break;
            case CROSS_WON:
                for (Player player : currentPlayerList) {
                    if (!player.isHuman()) {
                        if (player.getPlayerRole() == PlayerRole.CROSS) {
                            player.won();
                            player.getAgent().respond(rewardStructure.WIN);
                        }
                        if (player.getPlayerRole() == PlayerRole.NOUGHT) {
                            player.lost();
                            player.getAgent().respond(rewardStructure.LOST);
                        }
                    }
                }
                break;
            case DRAW:
                for (Player player : currentPlayerList) {
                    if (!player.isHuman()) {
                        player.draw();
                        player.getAgent().respond(rewardStructure.DRAW);
                    }
                }
                break;
            default:
                break;
        }
    }
/**
     * Takes specific action.
     *
     * @param agent agent that is taking action.
     * @param action action to be taken.
     */
Takes specific action.
@param agent agent that is taking action.
@param action action to be taken.
Takes specific action . @param agent agent that is taking action . @param action action to be taken .
public void commitAction(Agent agent, int action) {
        gameBoard.makeMove(currentPlayerList.get(currentPlayer), action);
        gameBoard.updateState();
        gameStatus = gameBoard.updateGameStatus(currentPlayerList.get(currentPlayer));
        switch (gameStatus) {
            case ONGOING:
                currentPlayerList.get(currentPlayer).getAgent().respond(rewardStructure.MOVE);
                break;
            case NOUGHT_WON:
                for (Player player : currentPlayerList) {
                    if (!player.isHuman()) {
                        if (player.getPlayerRole() == PlayerRole.NOUGHT) {
                            player.won();
                            player.getAgent().respond(rewardStructure.WIN);
                        }
                        if (player.getPlayerRole() == PlayerRole.CROSS) {
                            player.lost();
                            player.getAgent().respond(rewardStructure.LOST);
                        }
                    }
                }
                break;
            case CROSS_WON:
                for (Player player : currentPlayerList) {
                    if (!player.isHuman()) {
                        if (player.getPlayerRole() == PlayerRole.CROSS) {
                            player.won();
                            player.getAgent().respond(rewardStructure.WIN);
                        }
                        if (player.getPlayerRole() == PlayerRole.NOUGHT) {
                            player.lost();
                            player.getAgent().respond(rewardStructure.LOST);
                        }
                    }
                }
                break;
            case DRAW:
                for (Player player : currentPlayerList) {
                    if (!player.isHuman()) {
                        player.draw();
                        player.getAgent().respond(rewardStructure.DRAW);
                    }
                }
                break;
            default:
                break;
        }
    }
public void commitAction ( Agent agent , int action ) { gameBoard . makeMove ( currentPlayerList . get ( currentPlayer ) , action ) ; gameBoard . updateState ( ) ; gameStatus = gameBoard . updateGameStatus ( currentPlayerList . get ( currentPlayer ) ) ; switch ( gameStatus ) { case ONGOING : currentPlayerList . get ( currentPlayer ) . getAgent ( ) . respond ( rewardStructure . MOVE ) ; break ; case NOUGHT_WON : for ( Player player : currentPlayerList ) { if ( ! player . isHuman ( ) ) { if ( player . getPlayerRole ( ) == PlayerRole . NOUGHT ) { player . won ( ) ; player . getAgent ( ) . respond ( rewardStructure . WIN ) ; } if ( player . getPlayerRole ( ) == PlayerRole . CROSS ) { player . lost ( ) ; player . getAgent ( ) . respond ( rewardStructure . LOST ) ; } } } break ; case CROSS_WON : for ( Player player : currentPlayerList ) { if ( ! player . isHuman ( ) ) { if ( player . getPlayerRole ( ) == PlayerRole . CROSS ) { player . won ( ) ; player . getAgent ( ) . respond ( rewardStructure . WIN ) ; } if ( player . getPlayerRole ( ) == PlayerRole . NOUGHT ) { player . lost ( ) ; player . getAgent ( ) . respond ( rewardStructure . LOST ) ; } } } break ; case DRAW : for ( Player player : currentPlayerList ) { if ( ! player . isHuman ( ) ) { player . draw ( ) ; player . getAgent ( ) . respond ( rewardStructure . DRAW ) ; } } break ; default : break ; } }
Takes specific action.
Takes specific action .