Skip to content

Package: FGmixedFootballStrategy

FGmixedFootballStrategy

nameinstructionbranchcomplexitylinemethod
FGmixedFootballStrategy(FGMoveFactory)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
computeNextMove(int, FGPlayer, FGState, long)
M: 16 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
toString()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1:
2: package de.fhdw.gaming.ipspiel24.fg.strategy;
3:
4: import java.security.SecureRandom;
5: import java.util.Optional;
6:
7: import de.fhdw.gaming.ipspiel24.fg.domain.FGPlayer;
8: import de.fhdw.gaming.ipspiel24.fg.domain.FGState;
9: import de.fhdw.gaming.ipspiel24.fg.domain.FGStrategy;
10: import de.fhdw.gaming.ipspiel24.fg.moves.FGMove;
11: import de.fhdw.gaming.ipspiel24.fg.moves.factory.FGMoveFactory;
12:
13: /**
14: * Implements {@link FGStrategy} by always saying "no".
15: */
16: public final class FGmixedFootballStrategy implements FGStrategy {
17:
18: /**
19: * The factory for creating FG moves.
20: */
21: private final FGMoveFactory moveFactory;
22: private final SecureRandom random;
23:
24: /**
25: * Creates an {@link FGmixedFootballStrategy}.
26: *
27: * @param moveFactory The factory for creating FG moves.
28: */
29: FGmixedFootballStrategy(final FGMoveFactory moveFactory) {
30: this.moveFactory = moveFactory;
31: this.random = new SecureRandom();
32: }
33:
34: @Override
35: public Optional<FGMove> computeNextMove(
36: final int gameId,
37: final FGPlayer player,
38: final FGState state,
39: final long maxComputationTimePerMove) {
40:• if (random.nextInt(3) < 2) {
41: return Optional.of(this.moveFactory.createFootballMove());
42: } else {
43: return Optional.of(this.moveFactory.createCinemaMove());
44: }
45: }
46:
47: @Override
48: public String toString() {
49: return FGmixedFootballStrategy.class.getSimpleName();
50: }
51: }