Search in sources :

Example 1 with Move

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();
    }
}
Also used : Message(com.janfic.games.computercombat.network.Message) Move(com.janfic.games.computercombat.model.moves.Move)

Example 2 with Move

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;
}
Also used : Move(com.janfic.games.computercombat.model.moves.Move) Json(com.badlogic.gdx.utils.Json)

Example 3 with Move

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;
}
Also used : Move(com.janfic.games.computercombat.model.moves.Move) ComponentFilter(com.janfic.games.computercombat.util.ComponentFilter) MatchState(com.janfic.games.computercombat.model.match.MatchState) MoveResult(com.janfic.games.computercombat.model.moves.MoveResult) Component(com.janfic.games.computercombat.model.Component)

Example 4 with Move

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;
}
Also used : Move(com.janfic.games.computercombat.model.moves.Move) ComponentFilter(com.janfic.games.computercombat.util.ComponentFilter) MatchState(com.janfic.games.computercombat.model.match.MatchState) MoveResult(com.janfic.games.computercombat.model.moves.MoveResult) Component(com.janfic.games.computercombat.model.Component)

Example 5 with Move

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;
}
Also used : MatchComponentsMove(com.janfic.games.computercombat.model.moves.MatchComponentsMove) MatchComponentsMove(com.janfic.games.computercombat.model.moves.MatchComponentsMove) UseAbilityMove(com.janfic.games.computercombat.model.moves.UseAbilityMove) Move(com.janfic.games.computercombat.model.moves.Move) UseAbilityMove(com.janfic.games.computercombat.model.moves.UseAbilityMove)

Aggregations

Move (com.janfic.games.computercombat.model.moves.Move)9 MatchState (com.janfic.games.computercombat.model.match.MatchState)4 MoveResult (com.janfic.games.computercombat.model.moves.MoveResult)4 Component (com.janfic.games.computercombat.model.Component)3 ArrayList (java.util.ArrayList)3 MatchComponentsMove (com.janfic.games.computercombat.model.moves.MatchComponentsMove)2 UseAbilityMove (com.janfic.games.computercombat.model.moves.UseAbilityMove)2 Message (com.janfic.games.computercombat.network.Message)2 ComponentFilter (com.janfic.games.computercombat.util.ComponentFilter)2 List (java.util.List)2 Action (com.badlogic.gdx.scenes.scene2d.Action)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 Json (com.badlogic.gdx.utils.Json)1 Ability (com.janfic.games.computercombat.model.Ability)1 Card (com.janfic.games.computercombat.model.Card)1 GameRules (com.janfic.games.computercombat.model.GameRules)1 ConsumeProgressAnimation (com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation)1 MoveAnimation (com.janfic.games.computercombat.model.moves.MoveAnimation)1