made more classes deepClonable.

This commit is contained in:
2025-12-04 21:23:26 +01:00
parent 6607918635
commit 76f836b1c1
13 changed files with 66 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
package org.toop.framework.gameFramework.model.game;
public interface DeepCopyable<T extends TurnBasedGame<T>> {
public interface DeepCopyable<T> {
T deepCopy();
}

View File

@@ -0,0 +1,7 @@
package org.toop.framework.gameFramework.model.player;
import org.toop.framework.gameFramework.model.game.DeepCopyable;
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
public interface AI<T extends TurnBasedGame<T>> extends MoveProvider<T>, DeepCopyable<AI<T>> {
}

View File

@@ -12,6 +12,6 @@ import org.toop.framework.gameFramework.model.game.TurnBasedGame;
*
* @param <T> the specific type of game this AI can play, extending {@link GameR}
*/
public abstract class AbstractAI<T extends TurnBasedGame<T>> implements MoveProvider<T> {
public abstract class AbstractAI<T extends TurnBasedGame<T>> implements AI<T> {
// Concrete AI implementations should override findBestMove(T game, int depth)
}

View File

@@ -16,15 +16,17 @@ import org.toop.framework.gameFramework.model.game.TurnBasedGame;
* </p>
*/
public abstract class AbstractPlayer<T extends TurnBasedGame<T>> implements Player<T> {
private int playerIndex = -1;
private Logger logger = LogManager.getLogger(this.getClass());
private final Logger logger = LogManager.getLogger(this.getClass());
private final String name;
protected AbstractPlayer(String name) {
this.name = name;
}
protected AbstractPlayer(AbstractPlayer<T> other) {
this.name = other.name;
}
/**
* Determines the next move based on the provided game state.
* <p>

View File

@@ -2,6 +2,6 @@ package org.toop.framework.gameFramework.model.player;
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
public interface MoveProvider<T extends TurnBasedGame> {
public interface MoveProvider<T extends TurnBasedGame<T>> {
int getMove(T game);
}

View File

@@ -1,6 +1,7 @@
package org.toop.framework.gameFramework.model.player;
import org.toop.framework.gameFramework.model.game.DeepCopyable;
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
public interface Player<T extends TurnBasedGame<T>> extends NameProvider, MoveProvider<T> {
public interface Player<T extends TurnBasedGame<T>> extends NameProvider, MoveProvider<T>, DeepCopyable<Player<T>> {
}