Skip to content

Method: VGStrategyEins(VGMoveFactory)

1: package de.fhdw.gaming.ipspiel22.VGStrategyEins.strategy;
2:
3: import java.util.Optional;
4:
5: import de.fhdw.gaming.core.domain.GameException;
6: import de.fhdw.gaming.ipspiel22.searchtree.algorithm.MinMaxAlgorithm;
7: import de.fhdw.gaming.ipspiel22.vierGewinnt.domain.VGPlayer;
8: import de.fhdw.gaming.ipspiel22.vierGewinnt.domain.VGState;
9: import de.fhdw.gaming.ipspiel22.vierGewinnt.domain.VGStrategy;
10: import de.fhdw.gaming.ipspiel22.vierGewinnt.moves.VGMove;
11: import de.fhdw.gaming.ipspiel22.vierGewinnt.moves.factory.VGMoveFactory;
12:
13: /**
14: * VGStrategyEins.
15: *
16: * @author DonPablo
17: *
18: */
19: public class VGStrategyEins implements VGStrategy {
20:
21: /**
22: * VGMoveFactory.
23: */
24: private final VGMoveFactory movesFactory;
25:
26: /**
27: * VGStrategyEins Constructor.
28: *
29: * @param moveFactory
30: */
31: public VGStrategyEins(final VGMoveFactory moveFactory) {
32: this.movesFactory = moveFactory;
33: }
34:
35: @Override
36: public Optional<VGMove> computeNextMove(final int gameId, final VGPlayer player, final VGState state)
37: throws GameException, InterruptedException {
38: final Bewertung vgGame = new Bewertung(player, state, movesFactory);
39: final MinMaxAlgorithm<VGPlayer, VGState, VGMove, Bewertung> vg = new MinMaxAlgorithm<>(vgGame);
40: System.out.print(
41: "Gewählter move: " + vg.getBestMove(4) + ", Spielerfarbe: "
42: + (player.isUsingRedChips() ? "Rot" : "Gelb"));
43: return vg.getBestMove(4);
44: }
45:
46: @Override
47: public String toString() {
48: return VGStrategyEins.class.getSimpleName();
49: }
50:
51: }