ItAI/LS/z2

From WikiZMSI

< ItAI | LS

In class

  • In SaC library, get familiar with classes from the sac.game package - in particular: GameState, GameStateImpl, GameSearchAlgorithm, MinMax, and AlphaBetaPruning.
  • Implement a class representing a state of Connect4 game, your class should extend (inherit from) sac.game.GameStateImpl. Suggestions: (1) introduce constants for 'X' and 'O' symbols, (2) introduce constants representing dimensions of the board - number of rows x number of columns; (3) introduce a method making a particular move on the board i.e. throwing in a symbol to some column (4) implement the toString(...) method - try to make the formatting nice and readable for a human player, (5) - implement the hashCode() method, (6) immplement the generation of descendants - generateChildren().

Homework

  • Think over and implement according to your ideas an evaluation function for positions of Connect4 - attach it via the setHFunction(...) method. Your method shall be used when the "alpha-beta pruning" algorithm reaches the leaves in the tree analysis. In your function you may include: lengths of built sequences (of the same symbol) in different directions, rewards for board center rather than sides (or contrarily), closeness to the ceiling, etc. Attention: in the first order make sure your method returns suitable 'infinities' (Double.POSITIVE_INFINITY lub Double.NEGATIVE_INFINITY) for win positions.
  • Implement a class allowing for conducting the play between human and an artificial intelligence - main playing loop. Make sure it is possible that either player might begin (some switch in your program). During the game display move evaluations discovered by the algorithm.
  • Reading the move for a human player from the keyboard can be done e.g. with the following Java instructions:

BufferedReader inReader = new BufferedReader(new InputStreamReader(System.in), 1); String line = inReader.readLine(); int move = Integer.valueOf(line);