Skip to content

Method: FGmixedCinemaStrategy(FGMoveFactory)

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: /**
22: * Generates random numbers.
23: */
24: private final SecureRandom random;
25:
26: /**
27: * Creates an {@link FGSayYesStrategy}.
28: *
29: * @param moveFactory The factory for creating FG moves.
30: */
31: FGmixedCinemaStrategy(final FGMoveFactory moveFactory) {
32: this.moveFactory = moveFactory;
33: this.random = new SecureRandom();
34: }
35:
36: @Override
37: public Optional<FGMove> computeNextMove(
38: final int gameId,
39: final FGPlayer player,
40: final FGState state,
41: final long maxComputationTimePerMove) {
42: if (this.random.nextInt(3) < 2) {
43: return Optional.of(this.moveFactory.createCinemaMove());
44: }
45: return Optional.of(this.moveFactory.createFootballMove());
46: }
47:
48: @Override
49: public String toString() {
50: return FGmixedCinemaStrategy.class.getSimpleName();
51: }
52: }