doc and remove unused file dans method
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
|
||||
public class GomokuAI extends Player {
|
||||
|
||||
@@ -9,7 +9,8 @@ public class GomokuAI extends Player {
|
||||
|
||||
/**
|
||||
* The constructor of the GomokuAI.
|
||||
* @param name The name of the player.
|
||||
*
|
||||
* @param name The name of the player.
|
||||
* @param color The color of the player.
|
||||
*/
|
||||
public GomokuAI(String name, Color color, int tokens) {
|
||||
@@ -37,7 +38,7 @@ public class GomokuAI extends Player {
|
||||
public GomokuCell chooseMove(GomokuBoard board) {
|
||||
|
||||
List<GomokuCell> playableCell = board.getPlayableCells();
|
||||
GomokuCell playCell= null;
|
||||
GomokuCell playCell = null;
|
||||
int x = 0, y = 0;
|
||||
|
||||
switch (difficulty) {
|
||||
@@ -45,7 +46,7 @@ public class GomokuAI extends Player {
|
||||
playCell = playableCell.get(random.nextInt(playableCell.size()));
|
||||
break;
|
||||
case 1:
|
||||
Map<GomokuCell, Integer> map = GetCellPoint(board,this.color);
|
||||
Map<GomokuCell, Integer> map = GetCellPoint(board, this.color);
|
||||
int max = 0;
|
||||
for (Map.Entry<GomokuCell, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() > max) {
|
||||
@@ -55,15 +56,14 @@ public class GomokuAI extends Player {
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
Map<GomokuCell, Integer> map2 = GetCellPoint(board,this.color);
|
||||
Color other = null;
|
||||
if(this.color == Color.WHITE) {
|
||||
Map<GomokuCell, Integer> map2 = GetCellPoint(board, this.color);
|
||||
Color other = null;
|
||||
if (this.color == Color.WHITE) {
|
||||
other = Color.BLACK;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
other = Color.WHITE;
|
||||
}
|
||||
Map<GomokuCell, Integer> map3 = GetCellPoint(board,other);
|
||||
Map<GomokuCell, Integer> map3 = GetCellPoint(board, other);
|
||||
|
||||
int max3 = 0;
|
||||
int max2 = 0;
|
||||
@@ -81,7 +81,6 @@ public class GomokuAI extends Player {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
@@ -98,7 +97,7 @@ 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,Color color) {
|
||||
public Map<GomokuCell, Integer> GetCellPoint(GomokuBoard board, Color color) {
|
||||
// Prout
|
||||
List<GomokuCell> playableCell = board.getPlayableCells();
|
||||
Map<GomokuCell, Integer> map = new HashMap<>();
|
||||
@@ -124,11 +123,23 @@ public class GomokuAI extends Player {
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
// ------------------Getter--------------------------
|
||||
/**
|
||||
* Return the difficulty of the AI.
|
||||
*
|
||||
* @return 0: easy, 1: medium, 2: hard
|
||||
*/
|
||||
public int GetDifficulty() {
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
// ------------------Setter--------------------------
|
||||
/**
|
||||
* Change Difficulty of the AI.
|
||||
*
|
||||
* @param difficulty 0: easy, 1: medium, 2: hard
|
||||
*/
|
||||
public void SetDifficulty(int difficulty) {
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user