Skip to content

Package: FGmixedCinemaStrategy

FGmixedCinemaStrategy

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