DEV: 3rd assignment draft

This commit is contained in:
2020-12-18 16:34:11 +02:00
parent 2230cac96e
commit c2c5d5e46f
9 changed files with 651 additions and 99 deletions
+15 -4
View File
@@ -19,16 +19,23 @@ import java.util.Collections;
* Class to hold constant values for entire application
*/
class Const {
static final int numOfPlayers = 2;
static final int maxTileWalls = 2; /**< Number of maximum walls for each tile on the board */
static final int noSupply =-1; /**< Number to indicate the absent of supply */
static final int noOpponent =-1; /**< Number to indicate the absent of supply */
static final int noTileId =-1; /**< Number to indicate wrong tileId */
static final int EOR =-1; /**< Number to indicate the End Of Range */
static final int moveItems =4; /**< The number of items return by move() */
static final int viewDistance =3; /**< The max distance of the Heuristic player's ability to see */
static final int noView = viewDistance+1;
static final double opponentFactor =1.0;
static final double supplyFactor =0.65;
/** Parameters to control move evaluation */
/** @{ */
static final double opponentFactor = 1.0; /**< opponent distance factor */
static final double supplyFactor = 0.65; /**< supply distance factor */
static final double preMoveFactor = 0.65; /**< pre move distances factor */
static final double postMoveFactor = 0.35; /**< post move distances factor */
static final int minimaxTreeDepth = 4; /**< The maximum depth of the minimax tree */
/** @} */
}
/**
* Application wide object to hold settings like values for the session.
@@ -68,13 +75,16 @@ class Direction {
static final int RIGHT =3; /**< East direction */
static final int DOWN =5; /**< South direction */
static final int LEFT =7; /**< West direction */
static final int NONE =8; /**< No direction */
/**
* Utility to get the opposite direction.
* @param direction Input direction
* @return The opposite direction
*/
static int opposite (int direction) { return (direction+4)%DirRange.End; }
static int opposite (int direction) {
return (direction != NONE) ? (direction+4)%DirRange.End : NONE;
}
static int get (int fromId, int toId) {
if (Position.toID(Position.toRow(fromId), Position.toCol(fromId)-1) == toId)
@@ -133,6 +143,7 @@ class Position {
case Direction.DOWN: this.id = toID(row-1, col); break;
case Direction.LEFT: this.id = toID(row, col-1); break;
case Direction.RIGHT:this.id = toID(row, col+1); break;
case Direction.NONE: this.id = toID(row, col); break;
}
}