no doc in git and add tokens on players

This commit is contained in:
Aubin DORIVAL
2025-04-07 10:00:50 +02:00
parent 25279e30e3
commit cdf1699559
77 changed files with 17 additions and 8887 deletions

View File

@@ -12,8 +12,8 @@ public class GomokuAI extends Player {
* @param name The name of the player.
* @param color The color of the player.
*/
public GomokuAI(String name, Color color) {
super(name, color);
public GomokuAI(String name, Color color, int tokens) {
super(name, color, tokens);
}
/**

View File

@@ -39,19 +39,19 @@ public class GomokuGame {
g.renderer.update();
}
public void newGame(boolean bot, String name1, String name2) {
public void newGame(boolean bot, String name1, String name2, int tokens) {
Color[] possible = { Color.WHITE, Color.BLACK };
int rnd = new Random().nextInt(possible.length);
Color colorPlayer1 = possible[rnd];
Color colorPlayer2 = colorPlayer1.inverse();
this.player1 = new Human(name1, colorPlayer1);
this.player1 = new Human(name1, colorPlayer1, tokens);
if (bot) {
this.player2 = new GomokuAI(name2, colorPlayer2);
this.player2 = new GomokuAI(name2, colorPlayer2, tokens);
} else {
this.player2 = new Human(name2, colorPlayer2);
this.player2 = new Human(name2, colorPlayer2, tokens);
}
this.board = new GomokuBoard(15, 15);
@@ -71,6 +71,9 @@ public class GomokuGame {
System.out.println("c'est gangée !");
}
*/
while(this.nbTokens1 > 0 && this.nbTokens2 > 0){
}
GomokuCell currentPlay = null;
while (currentPlay == null) {
currentPlay = this.play(this.currentPlayer);
@@ -80,6 +83,7 @@ public class GomokuGame {
if( NB_CELL_PLAY <= board.countMax(board.countAlignedCells(currentPlay)))
{
System.out.println("c'est gangée !");
return;
}
}

View File

@@ -11,8 +11,8 @@ public class Human extends Player {
* @param name The name of the player.
* @param color The color of the player.
*/
public Human(String name, Color color) {
super(name, color);
public Human(String name, Color color, int tokens) {
super(name, color, tokens);
}
/**

View File

@@ -13,6 +13,8 @@ abstract class Player{
/** The color of the Player */
protected Color color;
int tokens;
//------------------Constructors--------------------------
@@ -21,9 +23,10 @@ abstract class Player{
* @param name The name of the player.
* @param color The color of the player.
*/
public Player(String name,Color color){
public Player(String name,Color color, int tokens){
this.name = name;
this.color = color;
this.tokens= tokens;
}
//------------------Gets--------------------------