From c5bad831e6457da52c931236bf867a33f273be14 Mon Sep 17 00:00:00 2001 From: Malte Tammena Date: Fri, 27 Oct 2017 10:51:09 +0200 Subject: [PATCH] Did commenting --- src/player/malte/MalteAI.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/player/malte/MalteAI.java b/src/player/malte/MalteAI.java index 6dae82f..2c8f6e5 100644 --- a/src/player/malte/MalteAI.java +++ b/src/player/malte/MalteAI.java @@ -128,6 +128,15 @@ public class MalteAI implements Player{ return weight; } + /** + * Calculates basic weight for two opposing directions in a position on the board. + * The sequences are analysed in order to find patterns in them, that influence the + * weight. + * + * @param x The first sequence. + * @param y The second sequence. + * @return The calculated weight. + */ private double getBaseWeightForSequences(Sequence x, Sequence y) { double W_PRIORITY_1 = 2 << 8; double W_PRIORITY_2 = 2 << 6; @@ -197,7 +206,11 @@ public class MalteAI implements Player{ } /** + * Returns the last empty Position in this column. * + * @param board The current board. + * @param column The column to dive into. + * @return The position on top of the first piece in this column. */ private Position getLastEmpty(int[][] board, int column) { if (board[column][0] != 0) { @@ -212,7 +225,10 @@ public class MalteAI implements Player{ } /** + * Returns whether this position is in the boundaries of the board. * + * @param pos The Position to be checked. + * @return Is the position on the board. */ private boolean isPosOnBoard(Position pos) { if (pos.getPosX() <= Game.GAME_COLUMNS - 1 && @@ -225,7 +241,11 @@ public class MalteAI implements Player{ } /** + * Returns the ID at the given Position on the given board. * + * @param board The current game's board. + * @param pos The position to be checked. + * @param board[pos.X][pos.Y]; */ private int getIDFromBoard(int[][] board, Position pos) { return board[pos.getPosX()][pos.getPosY()];