How to properly implement getPossibleMoves() in MinMax checkers?
I am trying to write Checkers with AI for computer moves. I have already finished the game for human players. I want to use the MinMax function for computer movements. I’ve seen many examples on the web, and in every algorithm, developers use the "getAllMoves()" method. From what I understand, this method is to return possible moves for all pieces on the checker. Before I implement the MinMax algorithm, which seems relatively understandable to me I need to implement that "getAllMoves()" function because i dont have something like that. I have only getMoveForPiece().
So the question is: What exactly this getAllMoves() should return for this "Checkers" game?
First of all:
- From what I understand it is necessary to take into account forced beatings and in this case return the possibility of killing a pawn?
- In the case of a simple move, all I have to do is return the field where did the pawn move from and where did it move?
- What should I return if a pawn has forced beating? Where did he go, where did he go, and who did he beat?
I think about something like that:
Dictionary<Tuple<int,int>, List<int>>
Explain:
Tuple<int, int>
// first int – from which field the piece was moved
// second int – If the pawn has a beat, it will be the number of the field that will be beaten, otherwise 0
List<int>
int – list of fields to which the piece may move.
This is my current MinMax template:
private Integer minimax(Board board, int depth, string color, bool maximizingPlayer) { Integer bestValue; if (0 == depth) if (maximizingPlayer) { for (var move : board.getPossibleMoves(color)) { } return bestValue; } else { for (var move : board.getPossibleMoves(color)) { } return bestValue; } }
I am asking for any tips on what will be necessary in this getPossibleMoves() method.