Package: FGmixedCinemaStrategy
FGmixedCinemaStrategy
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FGmixedCinemaStrategy(FGMoveFactory) |
|
|
|
|
|
||||||||||||||||||||
computeNextMove(int, FGPlayer, FGState, long) |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
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: }