merge
This commit is contained in:
@@ -129,6 +129,8 @@ public class GomokuBoard{
|
|||||||
* @return GomokuCell in the position.
|
* @return GomokuCell in the position.
|
||||||
*/
|
*/
|
||||||
public GomokuCell get(int x, int y){
|
public GomokuCell get(int x, int y){
|
||||||
|
if (x < 0 || x >= this.boardWidth) return null;
|
||||||
|
if (y < 0 || y >= this.boardHeight) return null;
|
||||||
int i = 0, j = 0;
|
int i = 0, j = 0;
|
||||||
GomokuCell act = this.firstCell;
|
GomokuCell act = this.firstCell;
|
||||||
while (i != x || j != y){
|
while (i != x || j != y){
|
||||||
|
|||||||
@@ -31,14 +31,67 @@ public class GomokuGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
int sizeX = 0;
|
||||||
|
int sizeY = 0;
|
||||||
|
int nbToken = 0;
|
||||||
|
int nbJetonsAligne = 0;
|
||||||
|
boolean renderer = false;
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
switch (args[i]) {
|
||||||
|
case "--save":
|
||||||
|
if (i + 1 < args.length) {
|
||||||
|
//load(g.load(Path.of(".cache/test.dat")));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "--size":
|
||||||
|
if (i + 2 < args.length) {
|
||||||
|
sizeX = Integer.parseInt(args[++i]);
|
||||||
|
sizeY = Integer.parseInt(args[++i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "--nbToken":
|
||||||
|
if (i + 1 < args.length) {
|
||||||
|
nbToken = Integer.parseInt(args[++i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "--nbTokenToWin":
|
||||||
|
if (i + 1 < args.length) {
|
||||||
|
nbJetonsAligne = Integer.parseInt(args[++i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "--renderer":
|
||||||
|
if (i + 1 < args.length) {
|
||||||
|
String bool = args[++i];
|
||||||
|
if(bool=="true"){
|
||||||
|
renderer = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
renderer=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
System.out.println("Invalid option : " + args[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
GomokuGame g = new GomokuGame(false);
|
GomokuGame g = new GomokuGame(renderer);//metre true ou fals si in veut l'affichage ou non
|
||||||
System.out.println(g.load(Path.of(".cache/test.dat")));
|
|
||||||
g.renderer = new ConsoleRenderer();
|
g.renderer = new ConsoleRenderer();
|
||||||
g.renderer.init(g);
|
|
||||||
g.renderer.update();
|
g.renderer.update();
|
||||||
g.board.expandBoard(Cardinal.SE);
|
g.board.expandBoard(Cardinal.SE);
|
||||||
g.renderer.update();
|
g.renderer.update();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,13 +219,13 @@ public class GomokuGame {
|
|||||||
// Write the board
|
// Write the board
|
||||||
for (int i = 0; i < this.getBoard().getHeight(); ++i) {
|
for (int i = 0; i < this.getBoard().getHeight(); ++i) {
|
||||||
for (int j = 0; j < this.getBoard().getWidth(); ++j) {
|
for (int j = 0; j < this.getBoard().getWidth(); ++j) {
|
||||||
char c = ' ';
|
char c;
|
||||||
switch (board.get(i, j).getState()) {
|
switch (board.get(i, j).getState()) {
|
||||||
case BLACK:
|
case BLACK:
|
||||||
c = 'X';
|
c = 'X';
|
||||||
break;
|
break;
|
||||||
case WHITE:
|
case WHITE:
|
||||||
|
c = 'O';
|
||||||
break;
|
break;
|
||||||
case NIL:
|
case NIL:
|
||||||
c = '.';
|
c = '.';
|
||||||
|
|||||||
Reference in New Issue
Block a user