LES COULEURS
This commit is contained in:
@@ -14,7 +14,6 @@ public class ConsoleRenderer extends GomokuRenderer {
|
||||
public void update() {
|
||||
// Print the board to the console
|
||||
|
||||
//clear la console
|
||||
System.out.print("\033[H\033[2J");
|
||||
System.out.flush();
|
||||
|
||||
@@ -25,7 +24,7 @@ public class ConsoleRenderer extends GomokuRenderer {
|
||||
|
||||
// Print a separator line, followed by the game infos
|
||||
System.out.println(horizontalLine);
|
||||
System.out.println("|" + String.format(" %-" + (width*4 - 2) + "s", "Gomoku Game!") + "|");
|
||||
System.out.println("|" + String.format(" %-" + (width*4 - 2) + "s", "Gomoku Game!") + "|"+" y");
|
||||
// System.out.println("Current player: " + game.getCurrentPlayer().getName());
|
||||
// System.out.println("Number of tokens left: " + game.getCurrentPlayer().getTokensLeft());
|
||||
|
||||
@@ -33,13 +32,23 @@ public class ConsoleRenderer extends GomokuRenderer {
|
||||
System.out.println(horizontalLine);
|
||||
for (int i = 0; i < height; i++) {
|
||||
System.out.print("|");
|
||||
|
||||
for (int j=0; j<width; j++) {
|
||||
System.out.print(" "+board[i].charAt(j)+" |");
|
||||
switch (board[i].charAt(j)) {
|
||||
case 'X':
|
||||
System.out.print(" \u001B[31m" + board[i].charAt(j) + "\u001B[0m |");
|
||||
break;
|
||||
case 'O':
|
||||
System.out.print(" \u001B[32m" + board[i].charAt(j) + "\u001B[0m |");
|
||||
break;
|
||||
default:
|
||||
System.out.print(" " + board[i].charAt(j) + " |");
|
||||
}
|
||||
}
|
||||
System.out.println(" "+i);
|
||||
System.out.println(horizontalLine);
|
||||
}
|
||||
System.out.print(" ");
|
||||
System.out.print("x");
|
||||
for (int i = 0; i < height; i++) {
|
||||
if(i<10) {
|
||||
System.out.print(" "+i+" ");
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GomokuAI extends Player {
|
||||
/** The random initialization */
|
||||
Random random = new Random();
|
||||
/** The difficulty of the GomokuAI */
|
||||
private int difficulty = 0;
|
||||
private int difficulty = 1;
|
||||
|
||||
// ------------------Methods--------------------------
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ public class GomokuAI extends Player {
|
||||
public GomokuCell chooseMove(GomokuBoard board) {
|
||||
|
||||
List<GomokuCell> playableCell = board.getPlayableCells();
|
||||
GomokuCell playCell;
|
||||
GomokuCell playCell= null;
|
||||
int x = 0, y = 0;
|
||||
|
||||
switch (difficulty) {
|
||||
@@ -53,6 +53,7 @@ public class GomokuAI extends Player {
|
||||
playCell = entry.getKey();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,10 @@ import java.util.Map;
|
||||
* This class is cell of the board of the Gomoku game.
|
||||
*/
|
||||
public class GomokuCell{
|
||||
|
||||
public static final String RESET = "\u001B[0m";
|
||||
public static final String ROUGE = "\u001B[31m";
|
||||
public static final String VERT = "\u001B[32m";
|
||||
/** Enumerate neighbor with key in Cardinal direction and key representing the cell in that direction. */
|
||||
private EnumMap<Cardinal,GomokuCell> neighbour;
|
||||
/** The state of the cell represented by the enumerate Color, Nil is empty, white and black for the color of a token */
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Human extends Player {
|
||||
}
|
||||
} while (!pass);
|
||||
|
||||
cell = board.get(y, x);
|
||||
cell = board.get(x, y);
|
||||
pass = cell == null ? false : cell.isPlayable();
|
||||
if (!pass) {
|
||||
System.out.println("Cette case n'est pas jouable !");
|
||||
|
||||
Reference in New Issue
Block a user