Skip to content

Method: evalC4State(IC4State)

1: package de.fhdw.gaming.ipspiel23.c4.gststrategy;
2:
3: import java.util.Set;
4: import java.util.stream.Collectors;
5:
6: import de.fhdw.gaming.ipspiel23.c4.domain.IC4Solution;
7: import de.fhdw.gaming.ipspiel23.c4.domain.IC4State;
8:
9: /**
10: * .
11: */
12: public class SimpleC4GSTEvaluation {
13:
14: /**
15: * .
16: * @param state
17: * @return
18: */
19: public Integer evalC4State(final IC4State state) {
20:
21: int evaluation = 0;
22:
23: final Set<IC4Solution> playerASolutions = state.getBoard().findAllSolutions()
24: .stream()
25: .filter(s -> s.getOwner().equals(state.getCurrentPlayer()))
26: .collect(Collectors.toSet());
27:
28: final Set<IC4Solution> playerBSolutions = state.getBoard().findAllSolutions()
29: .stream()
30: .filter(s -> !s.getOwner().equals(state.getCurrentPlayer()))
31: .collect(Collectors.toSet());
32:
33: final int playerASolutionCount = playerASolutions.size();
34: final int playerBSolutionCount = playerBSolutions.size();
35:
36: evaluation += playerASolutionCount * 1000;
37: evaluation -= playerBSolutionCount * 1000;
38:
39: evaluation *= state.getBoard().countEmptyPositions();
40:
41:
42:
43:
44: return evaluation;
45:
46: }
47:
48: }