Almost done with implementing bitboards. Reversi is broken and artifical players don't work yet.

This commit is contained in:
2025-12-04 14:19:48 +01:00
parent f4ee992166
commit 21b489bbe7
21 changed files with 804 additions and 286 deletions

View File

@@ -1,12 +1,9 @@
package org.toop.game;
import org.toop.framework.gameFramework.GameState;
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
import org.toop.framework.gameFramework.model.player.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public abstract class BitboardGame<T extends BitboardGame<T>> implements TurnBasedGame<T> {
private final int columnSize;
@@ -21,9 +18,7 @@ public abstract class BitboardGame<T extends BitboardGame<T>> implements TurnBas
public BitboardGame(int columnSize, int rowSize, int playerCount, Player<T>[] players) {
this.columnSize = columnSize;
this.rowSize = rowSize;
this.players = players;
this.playerBitboard = new long[playerCount];
this.currentTurn = 0;
@@ -60,12 +55,13 @@ public abstract class BitboardGame<T extends BitboardGame<T>> implements TurnBas
return output;
}
public BitboardGame(BitboardGame other) {
public BitboardGame(BitboardGame<T> other) {
this.columnSize = other.columnSize;
this.rowSize = other.rowSize;
this.playerBitboard = Arrays.copyOf(other.playerBitboard, other.playerBitboard.length);
this.currentTurn = other.currentTurn;
this.players = Arrays.copyOf(other.players, other.players.length); // TODO: Make this a deep copy
}
public int getColumnSize() {

View File

@@ -20,9 +20,8 @@ public class LocalThreadBehaviour<T extends TurnBasedGame<T>> extends AbstractTh
* Creates a new behaviour for a local turn-based game.
*
* @param game the game instance
* @param players the list of players in turn order
*/
public LocalThreadBehaviour(T game, Player<T>[] players) {
public LocalThreadBehaviour(T game) {
super(game);
}

View File

@@ -5,6 +5,8 @@ import org.toop.framework.gameFramework.model.game.PlayResult;
import org.toop.framework.gameFramework.model.player.Player;
import org.toop.game.BitboardGame;
import java.util.Arrays;
public class BitboardReversi extends BitboardGame<BitboardReversi> {
@Override
@@ -62,6 +64,7 @@ public class BitboardReversi extends BitboardGame<BitboardReversi> {
@Override
public int[] getLegalMoves(){
System.out.println(Arrays.toString(translateLegalMoves(getLegalMoves2())));
return translateLegalMoves(getLegalMoves2());
}