Orasund/elm-game-ai-minimax/1.0.0

MinimaxSearch

This library implements minimax algorithm with alpha-beta pruning.

{ apply : move -> game -> game
, evaluate : game -> Evaluation
, possibleMoves : { isYourTurn : Bool } -> game -> List move
, searchDepth : Int
}
-> game
-> Maybe move

Computes the best move

  • apply - is a function that takes a positon and applies a move
  • evaluate - evaluates the game state
  • possibleMoves - computes all possible next moves
  • game - the game state
  • searchDepth - Defines how deep the algorithm should search. Higher values give better results but are slower.
= Winning
| Loosing
| Score Int

Evaluation of a game

negates a evaluation

negateEvaluation Winning --> Loosing negateEvaluation Loosing --> Winning negateEvaluation (Score 42) --> Score -42