use of com.janfic.games.computercombat.model.moves.Move in project computercombat by janfic.
the class MatchScreen method playerMatchComponentsMoveCheck.
private void playerMatchComponentsMoveCheck() {
if (board.attemptedMove() && matchData.getCurrentState().currentPlayerMove.equals(game.getCurrentProfile().getUID())) {
Move move = board.getMove();
game.getServerAPI().sendMessage(new Message(Type.MOVE_REQUEST, json.toJson(move)));
board.consumeMove();
}
}
use of com.janfic.games.computercombat.model.moves.Move in project computercombat by janfic.
the class Match method isValidMove.
public boolean isValidMove(Move move) {
List<Move> moves = GameRules.getAvailableMoves(currentState);
boolean found = moves.contains(move);
Json j = new Json();
return found;
}
use of com.janfic.games.computercombat.model.moves.Move in project computercombat by janfic.
the class IncreaseComponentTypeHeuristicAnalyzer method analyze.
@Override
public float analyze(List<MoveResult> results) {
float r = 0;
MoveResult start = results.get(0);
MoveResult end = results.get(results.size() - 1);
ComponentFilter filter = new ComponentFilter() {
@Override
public boolean filter(Component component, MatchState state, Move move) {
return component.getColor() == color;
}
};
int endAmount = end.getState().countComponents(filter, end.getMove());
int startAmount = start.getState().countComponents(filter, start.getMove());
r = Math.min(Math.max(0, (endAmount - startAmount) / 3f), 1);
return r;
}
use of com.janfic.games.computercombat.model.moves.Move in project computercombat by janfic.
the class KeepComponentTypeHeuristicAnalyzer method analyze.
@Override
public float analyze(List<MoveResult> results) {
float r = 0;
MoveResult end = results.get(results.size() - 1);
ComponentFilter filter = new ComponentFilter() {
@Override
public boolean filter(Component component, MatchState state, Move move) {
return component.getColor() == color;
}
};
int amount = end.getState().countComponents(filter, end.getMove());
r = Math.min(amount / 25f, 1);
return r;
}
use of com.janfic.games.computercombat.model.moves.Move in project computercombat by janfic.
the class GameRules method getAvailableMoves.
public static List<Move> getAvailableMoves(MatchState state) {
List<Move> moves = new ArrayList<>();
// Get MatchComponentsMoves
List<Integer[]> matches = areAvailableComponentMatches(state);
for (Integer[] match : matches) {
Component a = state.getComponentBoard()[match[0]][match[1]];
Component b = state.getComponentBoard()[match[2]][match[3]];
MatchComponentsMove m = new MatchComponentsMove(state.currentPlayerMove, a, b);
moves.add(m);
}
// Get UseAbilityMoves
String uid = state.currentPlayerMove;
for (Card card : state.activeEntities.get(uid)) {
if (card.getRunProgress() >= card.getRunRequirements()) {
List<UseAbilityMove> generatedMoves = generateMovesWithSelection(0, card, state, new ArrayList<>(), new ArrayList<>());
moves.addAll(generatedMoves);
}
}
Card c = state.computers.get(uid);
if (c.getRunProgress() >= c.getRunRequirements()) {
UseAbilityMove m = new UseAbilityMove(uid, c, null, null);
moves.add(m);
}
return moves;
}
Aggregations