import Move;
import GameState;
import Rules;

/**
 * Extends ComputerPlayer
 * Computer Player:
 * An artificial intelligence that can make or suggest moves.
 * The field skill level sets how deep recursion can go, i.e.
 * how many moves in the future should the computer look?
 * the color can be anything.
 *
 * @ author Paul Bailey, Mark French, Mark Nordheim, Andrew Gorski
 * @ version 1.0 of March 2000
 */

public class CompPlayer extends ComputerPlayer {
    /**
     * Welcome to our code. Please find the fields skillLevel and color in
     * the fields department. Moving down you will see our constructor
     * which takes two parameters, a color and a skill level, both as
     * ints. The getMove method, our exclusive method, returns a valid
     * move better than you can think of.
     */
    // +--------+--------------------------------------------------
    // | Fields |
    // +--------+

    /**The skill level: */
    int skillLevel = 0;
    /**The color: */
    int color = 0;

    // +--------------+----------------------------------------------
    // | Constructors |
    // +--------------+

    /**
     * parameters:
     * skill level, how deep should the recursion be?
     * color, what color is the computer going to be?
     * purpose:
     * generates a new computer player that has a given color and a given
     * skill level as defined in the call.
     * pre:
     * -skillLevel is a small positive integer
     * -color is a small positive integer
     * post:
     * a new computer player exists that can use implimentations of this class
     * problems:
     * pre conditions are not satisfied.
     * produces:
     * orange juice!
     * a new computer player object
     *
     */
    public CompPlayer(int newSkillLevel, int newColor) {
        skillLevel = newSkillLevel;
        color = newColor;
        Scorer score
    }

    // +---------+------------------------------------------------
    // | Methods |
    // +---------+

    /**
     * Purpose:
     * returns a good move.
     * produces:
     * a valid move
     * pre:
     * there is a valid move
     * post:
     * the move that it returns is valid
     * problems:
     * there are no legal moves
     * parameters:
     * a GameState class and a Rules class.
     */

    public Move getMove(GameState gs, Rules rules){
        //the row the move will be on
        int moveRow;
        //the column the move will be on
        int moveColumn;
        //the array from rules
        boolean[] moves = rules.getLegalMoves();
        //the number of rows and columns
        int rows = board.getRow();
        int columns = board.getColumns();

        //this will be the value of the best move
        int value = play(gs,1,1);

        //the for loop that searches for possiable moves
        //and tries all legal moves, picking the best one
        //by leaving moveRow and moveColumn as the best move's
        //row and column respectively.
        for (int i = 1; i < rows; i++) {
            for (int k = 1; i < columns; k++) {
                //if the move is legal
                if (moves[i,k] == true) {
                    ikValue = play(gs,i,k);
                    //and if the move has a better score
                    if (ikValue > value) {
                        //then update the fields.
                        value = ikValue;
                        moveRow = i;
                        moveColumn = k;
                    }//if
                }//if (moves[i,k] == true)
            }//for (int k = 0; i < columns; k++)
        }//for (int i = 0; i < rows; i++
        Move move = new Move(moveRow,moveColumn);
        return move;
    }//public Move getMove(Board board, Rules rules)


    // +---------+------------------------------------------------
    // | Helpers |
    // +---------+

    /**
     * Tries the specified move and returns the resulting score
     * Pre: row and col are valid, and specify a legal move
     * Produces: an integer score
     */
    protected int play(GameState gamestate, int row, int col) {
        //The score value for this move
        int score;
        Piece thePiece = 
            new Piece(row, col, gamestate.color, gamestate.board);
        score = scorer.scoreThis(gamestate);
        return score;
    }
}//class CompPlayer

