wip: create proper board analyzer for ai
This commit is contained in:
@ -1,20 +1,20 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.ai;
|
||||
|
||||
import uulm.teamname.marvelous.gamelibrary.IntVector2;
|
||||
import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig;
|
||||
import uulm.teamname.marvelous.gamelibrary.config.PartyConfig;
|
||||
import uulm.teamname.marvelous.gamelibrary.config.ScenarioConfig;
|
||||
import uulm.teamname.marvelous.gamelibrary.entities.*;
|
||||
import uulm.teamname.marvelous.gamelibrary.entities.Character;
|
||||
import uulm.teamname.marvelous.gamelibrary.gamelogic.GameStateView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
class Board {
|
||||
private final Piece[][] data;
|
||||
private final EntityType turn;
|
||||
|
||||
private Board(Piece[][] data) {
|
||||
private Board(Piece[][] data, EntityType turn) {
|
||||
this.data = data;
|
||||
this.turn = turn;
|
||||
}
|
||||
|
||||
public static Board generate(GameStateView state, EntityType player) {
|
||||
@ -38,7 +38,7 @@ class Board {
|
||||
case P1, P2 -> {
|
||||
Character character = (Character)entity;
|
||||
data[y][x] = new Piece(
|
||||
entity.id.type == player ? PieceType.Friend : PieceType.Enemy,
|
||||
PieceType.Character,
|
||||
entity.id,
|
||||
character.hp.getValue(),
|
||||
character.hp.getMax(),
|
||||
@ -64,10 +64,37 @@ class Board {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Board(data);
|
||||
return new Board(data, player);
|
||||
}
|
||||
|
||||
public Action analyze(IntVector2 position, EntityType turn, PartyConfig partyConfig, CharacterConfig characterConfig, ScenarioConfig scenarioConfig) {
|
||||
return new Action(ActionType.None);
|
||||
protected ArrayList<Action> generateActions() {
|
||||
ArrayList<Action> result = new ArrayList<>();
|
||||
|
||||
//TODO: generate possible actions
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Board applyAction(Action action) {
|
||||
Piece[][] clone = new Piece[this.data.length][this.data[0].length];
|
||||
|
||||
for(int x = 0; x < this.data[0].length; x++) {
|
||||
for(int y = 0; y < this.data.length; y++) {
|
||||
clone[y][x] = this.data[y][x].clone();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: apply action
|
||||
|
||||
return new Board(clone, turn == EntityType.P1 ? EntityType.P2 : EntityType.P1);
|
||||
}
|
||||
|
||||
protected int calculateScore() {
|
||||
//TODO: create score calculation
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int calculateHash() {
|
||||
return Objects.hash(super.hashCode(), data);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user