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