First draft of 2nd version

This commit is contained in:
2020-12-06 23:03:49 +02:00
parent c14d1d812f
commit d581bd6c02
6 changed files with 310 additions and 31 deletions
+44 -17
View File
@@ -13,6 +13,7 @@ package host.labyrinth;
import java.util.ArrayList;
import java.util.Collections;
import java.util.function.IntFunction;
/**
* Class to hold constant values for entire application
@@ -20,8 +21,14 @@ import java.util.Collections;
class Const {
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 double opponentFactor =1.0;
static final double supplyFactor =0.65;
}
/**
* Application wide object to hold settings like values for the session.
@@ -34,23 +41,6 @@ class Session {
static boolean interactive = false; /**< When true each round of the game requires user input */
}
/**
* Helper C++-like enumerator class to hold direction
*/
class Direction {
static final int UP =1; /**< North direction */
static final int RIGHT =3; /**< East direction */
static final int DOWN =5; /**< South direction */
static final int LEFT =7; /**< West 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; }
}
/**
* Helper C++ like enumerator class for direction ranged loops.
*
@@ -69,6 +59,36 @@ class DirRange {
static final int Step =2; /**< Step for iterator style direction */
}
/**
* Helper C++-like enumerator class to hold direction
*/
class Direction {
static final int UP =1; /**< North direction */
static final int RIGHT =3; /**< East direction */
static final int DOWN =5; /**< South direction */
static final int LEFT =7; /**< West 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 get (int fromId, int toId) {
if (Position.toID(Position.toRow(fromId), Position.toCol(fromId)-1) == toId)
return Direction.LEFT;
else if (Position.toID(Position.toRow(fromId), Position.toCol(fromId)+1) == toId)
return Direction.RIGHT;
else if (Position.toID(Position.toRow(fromId)+1, Position.toCol(fromId) ) == toId)
return Direction.UP;
else if (Position.toID(Position.toRow(fromId)-1, Position.toCol(fromId) ) == toId)
return Direction.DOWN;
else
return DirRange.End;
}
}
/**
* @brief
* An Application wide board position implementation holding just the id coordinate.
@@ -200,6 +220,13 @@ class Range {
return Const.EOR;
}
/**
* @return The size of the underline structure
*/
int size () {
return numbers.size();
}
/** @name protected data types */
/** @{ */
protected ArrayList<Integer> numbers; /**< handle to range */