debut d'une ia par point

This commit is contained in:
Cyprien111
2025-03-31 11:01:12 +02:00
parent 4d1481d634
commit 12d4b2014a
4 changed files with 76 additions and 13 deletions

View File

@@ -1,7 +1,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class GomokuAI{
public class GomokuAI extends Player{
/**
* This class is an extends of the class Player, this allows the GomokuAI to choose his move.
@@ -16,7 +18,7 @@ public class GomokuAI{
/**
* Return the coordinate of the move played by the Gomoku AI.
* @param Board The actual Gomoku board.
* @return The coordinate of the move played.
* @return The Cell of the move played.
*/
public GomokuCell chooseMove(GomokuBoard board){
@@ -39,4 +41,37 @@ public class GomokuAI{
return playCell;
}
/**
* Return a Map of all Cell playable, and their point.
* @param Board The actual Gomoku board.
* @return the Map of all Cell playable, and their point.
*/
public Map<GomokuCell, Integer> GetCellPoint(GomokuBoard board){
List<GomokuCell> playableCell = board.getPlayableCells();
Map<GomokuCell, Integer> map = new HashMap<>();
for (GomokuCell gomokuCell : playableCell) {
switch(this.color){
case Color.WHITE:
gomokuCell.setState(Color.BLACK);
break;
case Color.BLACK:
gomokuCell.setState(Color.WHITE);
break;
default:
throw new AssertionError();
}
map.put(gomokuCell, board.countMax(board.countAlignedCells(gomokuCell)));
gomokuCell.setState(Color.NIL);
}
return map;
}
}