Skip to content

Content of file SimpleC4GSTEvaluation.java

package de.fhdw.gaming.ipspiel23.c4.gststrategy;

import java.util.Set;
import java.util.stream.Collectors;

import de.fhdw.gaming.ipspiel23.c4.domain.IC4Solution;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4State;

/**
 * .
 */
public class SimpleC4GSTEvaluation {

    /**
     * .
     * @param state
     * @return
     */
    public Integer evalC4State(IC4State state) {
Parameter 'state' is not assigned and could be declared final.
A method argument that is never re-assigned within the method can be declared final.
    
        

public void foo1 (String param) {       // do stuff with param never assigning it

}

public void foo2 (final String param) { // better, do stuff with param never assigning it

}

        
    
See PMD documentation.
int evaluation = 0; final Set<IC4Solution> playerASolutions = state.getBoard().findAllSolutions() .stream() .filter(s -> s.getOwner().equals(state.getCurrentPlayer())) .collect(Collectors.toSet()); final Set<IC4Solution> playerBSolutions = state.getBoard().findAllSolutions() .stream() .filter(s -> !s.getOwner().equals(state.getCurrentPlayer())) .collect(Collectors.toSet()); final int playerASolutionCount = playerASolutions.size(); final int playerBSolutionCount = playerBSolutions.size(); evaluation += playerASolutionCount * 1000; evaluation -= playerBSolutionCount * 1000; evaluation *= state.getBoard().countEmptyPositions(); return evaluation; } }