debut de l'ia 2
This commit is contained in:
@@ -24,7 +24,7 @@ public class GomokuAI extends Player {
|
||||
/** The random initialization */
|
||||
Random random = new Random();
|
||||
/** The difficulty of the GomokuAI */
|
||||
private int difficulty = 1;
|
||||
private int difficulty = 2;
|
||||
|
||||
// ------------------Methods--------------------------
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ public class GomokuAI extends Player {
|
||||
playCell = playableCell.get(random.nextInt(playableCell.size()));
|
||||
break;
|
||||
case 1:
|
||||
Map<GomokuCell, Integer> map = GetCellPoint(board);
|
||||
Map<GomokuCell, Integer> map = GetCellPoint(board,this.color);
|
||||
int max = 0;
|
||||
for (Map.Entry<GomokuCell, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() > max) {
|
||||
@@ -53,6 +53,35 @@ public class GomokuAI extends Player {
|
||||
playCell = entry.getKey();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
Map<GomokuCell, Integer> map2 = GetCellPoint(board,this.color);
|
||||
Color other = null;
|
||||
if(this.color == Color.WHITE) {
|
||||
other = Color.BLACK;
|
||||
}
|
||||
else{
|
||||
other = Color.WHITE;
|
||||
}
|
||||
Map<GomokuCell, Integer> map3 = GetCellPoint(board,other);
|
||||
|
||||
int max3 = 0;
|
||||
int max2 = 0;
|
||||
for (Map.Entry<GomokuCell, Integer> entry : map2.entrySet()) {
|
||||
if (entry.getValue() > max2) {
|
||||
max2 = entry.getValue();
|
||||
playCell = entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<GomokuCell, Integer> entry : map3.entrySet()) {
|
||||
if (entry.getValue() > max3) {
|
||||
max3 = entry.getValue();
|
||||
playCell = entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
@@ -69,8 +98,8 @@ public class GomokuAI extends Player {
|
||||
* @param board The actual Gomoku board.
|
||||
* @return the Map of all Cell playable, and their point.
|
||||
*/
|
||||
public Map<GomokuCell, Integer> GetCellPoint(GomokuBoard board) {
|
||||
|
||||
public Map<GomokuCell, Integer> GetCellPoint(GomokuBoard board,Color color) {
|
||||
// Prout
|
||||
List<GomokuCell> playableCell = board.getPlayableCells();
|
||||
Map<GomokuCell, Integer> map = new HashMap<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user