/**
* .
*/
private GstKopplungsMoveCalculator<TttPlayer, TttState> calc;
/**
* .
*/
private TttKopplung kopplung;
/**
* .
*/
private TttPlayer playerA;
/**
* .
*/
private TttPlayer playerB;
/**
* .
*/
@Test
void currentPlayerWinsMoveTest() {
/*
* 00 = X, 20 = X, 11 = O, 22= 0
*
* X to move, 01 is a winning move.
*
*/
this.calc = new GstKopplungsMoveCalculator<>();
this.playerA = new TttPlayer(PLAYER_A, 1);
this.playerB = new TttPlayer(PLAYER_B, -1);
this.kopplung = new TttKopplung();
final TttState state = new TttState(this.playerA, this.playerB);
state.getBoard()[0][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[2][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[1][1] = this.playerB.getPlayerSymbolValue();
state.getBoard()[2][2] = this.playerB.getPlayerSymbolValue();
final Move<TttPlayer,
TttState> move = this.calc.calculateMove(this.kopplung, state, 500, new GstKopplungNegaMax<>());
final TttMove tttMove = (TttMove) move;
final TttMove bestMove = new TttPlaceMarkMove(0, 1);
assertEquals(bestMove, tttMove);
}
/**
* .
*/
@Test
void currentPlayerWinsBeforeNextPlayerTest() {
/*
* /*
* 00 = X, 20 = X, 02 = O, 22= 0
*
* X to move, 01 is a winning move.
* O could win with 12, but because X is to move, X needs to win.
*
*/
this.calc = new GstKopplungsMoveCalculator<>();
this.playerA = new TttPlayer(PLAYER_A, 1);
this.playerB = new TttPlayer(PLAYER_B, -1);
this.kopplung = new TttKopplung();
final TttState state = new TttState(this.playerA, this.playerB);
state.getBoard()[0][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[2][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[0][2] = this.playerB.getPlayerSymbolValue();
state.getBoard()[2][2] = this.playerB.getPlayerSymbolValue();
final Move<TttPlayer,
TttState> move = this.calc.calculateMove(this.kopplung, state, 500, new GstKopplungNegaMax<>());
final TttMove tttMove = (TttMove) move;
final TttMove bestMove = new TttPlaceMarkMove(1, 0);
assertEquals(bestMove, tttMove);
}
/**
* .
*/
@Test
void currentPlayerPreventsOtherPlayersWinTest() {
/*
* 00 = X, 11 = X, 02 = O, 22= 0
*
* X to move, 12 is a prevention move.
* O could win with 12, but because X is to move, X needs to prevent that win.
*
*/
this.calc = new GstKopplungsMoveCalculator<>();
this.playerA = new TttPlayer(PLAYER_A, 1);
this.playerB = new TttPlayer(PLAYER_B, -1);
this.kopplung = new TttKopplung();
final TttState state = new TttState(this.playerA, this.playerB);
state.getBoard()[0][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[1][1] = this.playerA.getPlayerSymbolValue();
state.getBoard()[0][2] = this.playerB.getPlayerSymbolValue();
state.getBoard()[2][2] = this.playerB.getPlayerSymbolValue();
final Move<TttPlayer,
TttState> move = this.calc.calculateMove(this.kopplung, state, 500, new GstKopplungNegaMax<>());
final TttMove tttMove = (TttMove) move;
final TttMove bestMove = new TttPlaceMarkMove(1, 2);
assertEquals(bestMove, tttMove);
}
/**
* .
*/
@Test
void currentPlayerWinsMoveTestMT() {
/*
* 00 = X, 20 = X, 11 = O, 22= 0
*
* X to move, 01 is a winning move.
*
*/
this.calc = new GstKopplungsMoveCalculator<>();
this.playerA = new TttPlayer(PLAYER_A, 1);
this.playerB = new TttPlayer(PLAYER_B, -1);
this.kopplung = new TttKopplung();
final TttState state = new TttState(this.playerA, this.playerB);
state.getBoard()[0][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[2][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[1][1] = this.playerB.getPlayerSymbolValue();
state.getBoard()[2][2] = this.playerB.getPlayerSymbolValue();
final Move<TttPlayer,
TttState> move = this.calc.calculateMove(this.kopplung, state, 500,
new GstKopplungNegaMaxMultithreading<>());
final TttMove tttMove = (TttMove) move;
final TttMove bestMove = new TttPlaceMarkMove(0, 1);
assertEquals(bestMove, tttMove);
}
/**
* .
*/
@Test
void currentPlayerWinsBeforeNextPlayerTestMT() {
/*
* /*
* 00 = X, 20 = X, 02 = O, 22= 0
*
* X to move, 01 is a winning move.
* O could win with 12, but because X is to move, X needs to win.
*
*/
this.calc = new GstKopplungsMoveCalculator<>();
this.playerA = new TttPlayer(PLAYER_A, 1);
this.playerB = new TttPlayer(PLAYER_B, -1);
this.kopplung = new TttKopplung();
final TttState state = new TttState(this.playerA, this.playerB);
state.getBoard()[0][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[2][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[0][2] = this.playerB.getPlayerSymbolValue();
state.getBoard()[2][2] = this.playerB.getPlayerSymbolValue();
final Move<TttPlayer,
TttState> move = this.calc.calculateMove(this.kopplung, state, 500,
new GstKopplungNegaMaxMultithreading<>());
final TttMove tttMove = (TttMove) move;
final TttMove bestMove = new TttPlaceMarkMove(1, 0);
assertEquals(bestMove, tttMove);
}
/**
* .
*/
@Test
void currentPlayerPreventsOtherPlayersWinTestMT() {
/*
* 00 = X, 11 = X, 02 = O, 22= 0
*
* X to move, 12 is a prevention move.
* O could win with 12, but because X is to move, X needs to prevent that win.
*
*/
this.calc = new GstKopplungsMoveCalculator<>();
this.playerA = new TttPlayer(PLAYER_A, 1);
this.playerB = new TttPlayer(PLAYER_B, -1);
this.kopplung = new TttKopplung();
final TttState state = new TttState(this.playerA, this.playerB);
state.getBoard()[0][0] = this.playerA.getPlayerSymbolValue();
state.getBoard()[1][1] = this.playerA.getPlayerSymbolValue();
state.getBoard()[0][2] = this.playerB.getPlayerSymbolValue();
state.getBoard()[2][2] = this.playerB.getPlayerSymbolValue();
final Move<TttPlayer,
TttState> move = this.calc.calculateMove(this.kopplung, state, 500,
new GstKopplungNegaMaxMultithreading<>());
final TttMove tttMove = (TttMove) move;
final TttMove bestMove = new TttPlaceMarkMove(1, 2);
assertEquals(bestMove, tttMove);
}
}