Term paper presentation, Artificial Intelligence class, 2009




  Development of an Artificial Player
       for Connect-(4|n) game
                    Alessandro Manfredi
                          256479
The Connect-(4|n) game
• Implementation of game dynamics with
  dynamic board size and required connections
  for the game to be won.

• Different playing modes
  • Human vs Human
  • Human vs AI
  • Simulations: AI vs AI
        (Useful to obtain wide range of moves computed by
        the algorithm as possible input for an automatic
        learning tool, or just to cache precomputed moves)
Mini-Max Algorithm

• Implementations in PHP and Java
• Game dynamics are implemented as a PHP script
• An external Java jar is used to compute moves
  • Chance to train or precompute moves outside
    the actual game simulations (?)
connectMinimax usage

$ java -jar connectMinimax.jar
    <rows> <columns> <connections> <depth-limit>
           <heuristic-exp> <board-dump> <player>

   <rows>            # Board rows
   <columns>         # Board columns
   <connections>     # Required connections to win
   <depth-limit>     tree depth limit
   <heuristic-exp>   Heuristic exponent
   <board-dump>      Game state representation
   <player>          Player for which compute the move
Mini-Max for non-perfect decisions
 • Need an heuristic
 • Evaluation of game state or evaluation of possible
   further moves?

 • Incremental evaluation: estimate value of chances
   opened by a move

   • NB: a winning move has an infinite (positive)
      evaluation

   • NB: moves which bring to (even slightly) better
      game states must have a relevant surplus of
      evaluation
Moves’ Heuristic
• Consider the 4 dimensions
  separately

• For each, consider any
  window including the move

• For each window available to
  be completed, sum player’s
  pieces raised to the
  parametric heuristic exponent

• The evaluation of a move is
  the sum of all these
  components
Improvements

• Raise tree depth
    • Better results, longer time to wait for each
       non-precomputed move :(

• Max depth can be increased as the game moves on
  (less possibilities to compute)

    • Time to wait almost not affected
• Alfa-Beta Pruning
Results and future dev.
• AI beats Human in 60-65% of cases.
 • NB: Initial player is pseudo-random

• Time-to-wait is still too long: 17-19 sec.
• How about a machine learning tool trained with
  the move computation component?

 • A classifier ( Decision-Tree ?)
 • Neural network ( Multilayer perceptron with
    backpropagation ?)

Connect (4|n)

  • 1.
    Term paper presentation,Artificial Intelligence class, 2009 Development of an Artificial Player for Connect-(4|n) game Alessandro Manfredi 256479
  • 2.
    The Connect-(4|n) game •Implementation of game dynamics with dynamic board size and required connections for the game to be won. • Different playing modes • Human vs Human • Human vs AI • Simulations: AI vs AI (Useful to obtain wide range of moves computed by the algorithm as possible input for an automatic learning tool, or just to cache precomputed moves)
  • 3.
    Mini-Max Algorithm • Implementationsin PHP and Java • Game dynamics are implemented as a PHP script • An external Java jar is used to compute moves • Chance to train or precompute moves outside the actual game simulations (?)
  • 4.
    connectMinimax usage $ java-jar connectMinimax.jar <rows> <columns> <connections> <depth-limit> <heuristic-exp> <board-dump> <player> <rows> # Board rows <columns> # Board columns <connections> # Required connections to win <depth-limit> tree depth limit <heuristic-exp> Heuristic exponent <board-dump> Game state representation <player> Player for which compute the move
  • 5.
    Mini-Max for non-perfectdecisions • Need an heuristic • Evaluation of game state or evaluation of possible further moves? • Incremental evaluation: estimate value of chances opened by a move • NB: a winning move has an infinite (positive) evaluation • NB: moves which bring to (even slightly) better game states must have a relevant surplus of evaluation
  • 6.
    Moves’ Heuristic • Considerthe 4 dimensions separately • For each, consider any window including the move • For each window available to be completed, sum player’s pieces raised to the parametric heuristic exponent • The evaluation of a move is the sum of all these components
  • 7.
    Improvements • Raise treedepth • Better results, longer time to wait for each non-precomputed move :( • Max depth can be increased as the game moves on (less possibilities to compute) • Time to wait almost not affected • Alfa-Beta Pruning
  • 8.
    Results and futuredev. • AI beats Human in 60-65% of cases. • NB: Initial player is pseudo-random • Time-to-wait is still too long: 17-19 sec. • How about a machine learning tool trained with the move computation component? • A classifier ( Decision-Tree ?) • Neural network ( Multilayer perceptron with backpropagation ?)