computer_player
= cluster is create, opponent_moved, make_move, reset_state, get_options, set_options, get_name, set_name, get_evaluator,
set_evaluator, get_color
- Overview
- computer_player is a mutable data type representing a computer anti-chess player. Given the state of an anti-chess game, it is able to propose an "intelligent" move. The related machine_player data structure is implemented as a wrapper around this data structure and the chess_board data structure.
- We use this, rather than machine_player, for two reasons. First, since the arbiter can pass our computer_player the chess_board data structure, we don't have to keep a redundant copy of all that information (as we would have to with machine_player). Second, machine_player requires you to pass information to it in a human-readable format, which is silly, and it breaks down the abstraction barrier between the strategy and interface modules.
- Uses the same options data structure as machine_player
- written by stevenj
- create = proc(the_options: options, the_name: string) returns(cvt)
- effects: returns a new computer_player with options described by the_options and name the_name. It will have the default static_evaluator to start with.
- get_name = proc(p: cvt) returns(string)
- effects: Returns a string name for the computer player
- set_name = proc(p: cvt, new_name: string)
- modifies: p
- effects: Sets the string name for the computer player
- get_options = proc(p: cvt) returns(options)
- effects: Returns the options for p
- set_options = proc(p: cvt, new_opts: options)
- modifies: p
- effects: Sets p's options
- get_evaluator = proc(p: cvt) returns(static_evaluator)
- effects: Returns the static evaluator p uses
- set_evaluator = proc(p: cvt, e: static_evaluator)
- modifies: p
- effects: Sets the static evaluator used by p
- reset_state = proc(p: cvt)
- modifies: p
- effects: Resets any internal state that p may be holding regarding the current game. This must be done when a new game is started, for example.
- opponent_moved = proc(p: cvt, m: moveData)
- requires: m is a valid move for p's opponent
- modifies: p
- effects: Updates p's internal state to reflect the fact that p's opponent has made the move m.
- make_move = proc(p: cvt, tleft: int, board: chess_board) returns(moveData)
- requires: p's state must be current for the given board; i.e. either opponent_moved was called for each move of p's opponent, or reset_state was called since the last move or change to the board. tleft is the amount of time the computer player has left on its clock (millisecs).
- modifies: p
- effects: Given p's internal state, and the chess_board, board, returns p's move. May change p's internal state.
- get_color = proc(p: cvt) returns(piececolor)
- effects: returns the color of p.