Skip to content

Method: computeNextMove(int, IC4Player, IC4State)

1: package de.fhdw.gaming.ipspiel23.c4.gststrategy;
2:
3: import java.util.ArrayList;
4: import java.util.Collection;
5: import java.util.Optional;
6:
7: import de.fhdw.gaming.core.domain.GameException;
8: import de.fhdw.gaming.core.domain.Move;
9: import de.fhdw.gaming.ipspiel23.c4.domain.IC4Player;
10: import de.fhdw.gaming.ipspiel23.c4.domain.IC4State;
11: import de.fhdw.gaming.ipspiel23.c4.moves.IC4Move;
12: import de.fhdw.gaming.ipspiel23.c4.moves.factory.IC4MoveFactory;
13: import de.fhdw.gaming.ipspiel23.c4.strategies.IC4Strategy;
14: import de.fhdw.gaming.ipspiel23.gst.domain.ICalculatorKopplung;
15: import de.fhdw.gaming.ipspiel23.gst.domain.IKopplung;
16: import de.fhdw.gaming.ipspiel23.gst.domain.impl.GstKopplungsMoveCalculator;
17: import de.fhdw.gaming.ipspiel23.gst.strategies.impl.GstKopplungNegaMax;
18: import de.fhdw.gaming.ipspiel23.gst.strategies.impl.GstKopplungNegaMaxMultithreading;
19:
20:
21:
22: /**
23: * GSTMoveStrategy for C4 Game.
24: */
25: public class C4GSTMoveStrategy implements IC4Strategy {
26:
27:
28:
29:
30: /**
31: * The calculator used for computing the next move.
32: */
33: private ICalculatorKopplung<IC4Player, IC4State> calc;
34:
35:
36: /**
37: * The MoveFactory.
38: */
39: private IC4MoveFactory moveFactory;
40:
41: /**
42: * The C4-GST-Kopplung.
43: */
44: private IKopplung<IC4Player, IC4State> c4Kopplung;
45:
46: /**
47: * .
48: */
49: private GstKopplungNegaMaxMultithreading<IC4Player, IC4State> negamax;
50: //private GstKopplungNegaMax<IC4Player, IC4State> negamax;
51:
52: /**
53: * Creates new C4GSTMoveStrategy with given MoveFactory.
54: * @param moveFactory
55: */
56: public C4GSTMoveStrategy(IC4MoveFactory moveFactory) {
57: this.moveFactory = moveFactory;
58: this.c4Kopplung = new C4GSTKopplung(moveFactory);
59:
60: //this.negamax = new GstKopplungNegaMax<>();
61: this.negamax = new GstKopplungNegaMaxMultithreading<>();
62: this.calc = new GstKopplungsMoveCalculator<>();
63:
64: }
65:
66: @Override
67: public Optional<IC4Move> computeNextMove(int gameId, IC4Player player, IC4State state)
68: throws GameException, InterruptedException {
69:
70: //final Collection<Move<IC4Player, IC4State>> possibleMoves = c4Kopplung.getPossibleMoves(state).get();
71:
72: return Optional.of((IC4Move) calc.calculateMove(c4Kopplung, state, 1000, negamax));
73:
74:
75: }
76:
77: @Override
78: public String toString() {
79: return C4GSTMoveStrategy.class.getSimpleName();
80: }
81:
82: }