Skip to content

Method: chooseRandomMove(KopfundZahlundKantePlayer, KopfundZahlundKanteState)

1: package de.fhdw.gaming.ipspiel22.kopfundzahlundkante.domain.impl;
2:
3: import java.util.Map;
4: import java.util.Optional;
5:
6: import de.fhdw.gaming.core.domain.DefaultGame;
7: import de.fhdw.gaming.core.domain.ObserverFactoryProvider;
8: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.domain.KopfundZahlundKanteGame;
9: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.domain.KopfundZahlundKanteMoveChecker;
10: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.domain.KopfundZahlundKantePlayer;
11: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.domain.KopfundZahlundKanteState;
12: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.domain.KopfundZahlundKanteStrategy;
13: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.moves.KopfundZahlundKanteMove;
14: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.moves.factory.KopfundZahlundKanteMoveFactory;
15: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.moves.impl.DefaultKopfundZahlundKanteMoveFactory;
16:
17: /**
18: * Implements a KopfundZahl game.
19: */
20: public final class KopfundZahlundKanteGameImpl extends DefaultGame<KopfundZahlundKantePlayer,
21: KopfundZahlundKanteState,
22: KopfundZahlundKanteMove,
23: KopfundZahlundKanteStrategy>
24: implements KopfundZahlundKanteGame {
25:
26: /**
27: * The move Factory.
28: */
29: private final KopfundZahlundKanteMoveFactory moveFactory;
30:
31: /**
32: * Creates a KopfundZahl game.
33: *
34: * @param id The ID of this game.
35: * @param initialState The initial state of the game.
36: * @param strategies The players' strategies.
37: * @param maxComputationTimePerMove The maximum computation time per move in seconds.
38: * @param moveChecker The move checker.
39: * @param observerFactoryProvider The maximum computation time per move in seconds.
40: * @throws IllegalArgumentException if the player sets do not match.
41: * @throws InterruptedException if creating the game has been interrupted.
42: */
43: KopfundZahlundKanteGameImpl(final int id, final KopfundZahlundKanteState initialState, final Map<String,
44: KopfundZahlundKanteStrategy> strategies,
45: final long maxComputationTimePerMove, final KopfundZahlundKanteMoveChecker moveChecker,
46: final ObserverFactoryProvider observerFactoryProvider)
47: throws IllegalArgumentException, InterruptedException {
48: super(id, initialState, strategies, maxComputationTimePerMove, moveChecker, observerFactoryProvider);
49: this.moveFactory = new DefaultKopfundZahlundKanteMoveFactory();
50: }
51:
52: @Override
53: public Optional<KopfundZahlundKanteMove> chooseRandomMove(final KopfundZahlundKantePlayer player,
54: final KopfundZahlundKanteState state) {
55: return Optional.of(this.moveFactory.createTailMove());
56: }
57:
58: @Override
59: public String toString() {
60: return String.format("KopfundZahlundKanteGame[id=%d, %s]", this.getId(), this.gameToString());
61: }
62:
63: }