Informational output

This commit is contained in:
Malte Tammena 2017-10-20 22:26:48 +02:00 committed by Maurizio Bruetsch
parent 6a93dd4a05
commit 96758d864d

View file

@ -66,17 +66,20 @@ public class MalteAI implements Player{
// Get options which would lead to instant win. // Get options which would lead to instant win.
Set<Integer> winningOptions = getRowCompletionOptions(options, board, id); Set<Integer> winningOptions = getRowCompletionOptions(options, board, id);
for (Integer i: winningOptions) { for (Integer i: winningOptions) {
System.out.println("Choose to win");
return i.intValue(); return i.intValue();
} }
// Get options which would prevent an instant win of the enemy. // Get options which would prevent an instant win of the enemy.
enemyID = enemyID == 0 ? 1: enemyID; enemyID = enemyID == 0 ? 1: enemyID;
Set<Integer> preventionsOptions = getRowCompletionOptions(options, board, enemyID); Set<Integer> preventionsOptions = getRowCompletionOptions(options, board, enemyID);
for (Integer i: preventionsOptions) { for (Integer i: preventionsOptions) {
System.out.println("Choose to prevent");
return i.intValue(); return i.intValue();
} }
// Choose a move that will continue a sequence that already exists. // Choose a move that will continue a sequence that already exists.
Set<Integer> twoOfFour = getTwoOfFourOptions(options, board, id); Set<Integer> twoOfFour = getTwoOfFourOptions(options, board, id);
for (Integer i: twoOfFour) { for (Integer i: twoOfFour) {
System.out.println("Choose to progress");
return i.intValue(); return i.intValue();
} }
// Choose a move that will not lead to an instant win of the enemy // Choose a move that will not lead to an instant win of the enemy
@ -86,10 +89,12 @@ public class MalteAI implements Player{
choosewisely.remove(i); choosewisely.remove(i);
int[][] fakeBoard = makeMove(copyBoard(board), i, id); int[][] fakeBoard = makeMove(copyBoard(board), i, id);
if (getRowCompletionOptions(options, fakeBoard, enemyID).size() == 0) { if (getRowCompletionOptions(options, fakeBoard, enemyID).size() == 0) {
System.out.println("Choose random but smart");
return i.intValue(); return i.intValue();
} }
} }
// If nothing applies, take a random valied one. // If nothing applies, take a random valied one.
System.out.println("Choose random and stupid");
return takeRandom(options).intValue(); return takeRandom(options).intValue();
} }