Trying to do Task 11 Link
Signed-off-by: Immanuel Alvaro Bhirawa <u7280427@anu.edu.au>
This commit is contained in:
@@ -551,12 +551,217 @@ public class State {
|
||||
* @param playerID int player to score
|
||||
* @return int score
|
||||
*/
|
||||
|
||||
// public boolean isAdjacent(Coord coord) {
|
||||
// if (this.y == coord.y) {
|
||||
// return (this.x == coord.x - 1 || this.x == coord.x + 1);
|
||||
// }
|
||||
// if (this.x == coord.x) {
|
||||
// return (this.y == coord.y - 1 || this.y == coord.y + 1);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Check if two coordinates are adjacent (includes diagonals)
|
||||
// * @param coord Coord object to compare to
|
||||
// */
|
||||
// public boolean isAdjacentDiagonal(Coord coord){
|
||||
// if (isAdjacent(coord)) return true;
|
||||
// if (this.x == coord.x - 1 && this.y == coord.y - 1) return true;
|
||||
// if (this.x == coord.x - 1 && this.y == coord.y + 1) return true;
|
||||
// if (this.x == coord.x + 1 && this.y == coord.y - 1) return true;
|
||||
// return (this.x == coord.x + 1 && this.y == coord.y + 1);
|
||||
// }
|
||||
|
||||
// public Player(int playerID) {
|
||||
// this.playerID = playerID;
|
||||
// this.score = 0;
|
||||
// this.numCoconuts = 0;
|
||||
// this.numBamboo = 0;
|
||||
// this.numWater = 0;
|
||||
// this.numPreciousStones = 0;
|
||||
// this.numStatuette = 0;
|
||||
// this.settlers = new Coord[0];
|
||||
// this.villages = new Coord[0];
|
||||
// }
|
||||
// // endregion
|
||||
// // region Getters and Setters
|
||||
//
|
||||
// /**
|
||||
// * Get the player's ID
|
||||
// * @return int player ID
|
||||
// */
|
||||
// public int getPlayerID() {
|
||||
// return playerID;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Get the player's settlers
|
||||
// * @return Coord[] list of the player's settlers coords
|
||||
// */
|
||||
// public Coord[] getSettlers() {
|
||||
// return settlers;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get the player's villages
|
||||
// * @return Coord[] list of the player's villages coords
|
||||
// */
|
||||
// public Coord[] getVillages() {
|
||||
// return villages;
|
||||
// }
|
||||
|
||||
// public Coord[] getPieces() {
|
||||
// Coord[] pieces = new Coord[settlers.length + villages.length];
|
||||
// for (int i = 0; i < settlers.length; i++) {
|
||||
// pieces[i] = settlers[i];
|
||||
// }
|
||||
// for (int i = 0; i < villages.length; i++) {
|
||||
// pieces[settlers.length + i] = villages[i];
|
||||
// }
|
||||
// return pieces;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get number of pieces on island
|
||||
// * @param island Island island to check
|
||||
// * @return int number of pieces on island
|
||||
// */
|
||||
// public int getNumPiecesOnIsland(Island island) {
|
||||
// int numPieces = 0;
|
||||
// for (Coord piece : getPieces()) {
|
||||
// if (island.containsCoord(piece)) {
|
||||
// numPieces++;
|
||||
// }
|
||||
// }
|
||||
// return numPieces;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Get the coordinates of the island
|
||||
// * @return Coord[] coordinates of the island
|
||||
// */
|
||||
// public Coord[] getCoords() {
|
||||
// return coords;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Check if the island contains a coordinate
|
||||
// * @param coord the coordinate to be checked
|
||||
// * @return boolean true if the island contains the coordinate
|
||||
// */
|
||||
// public boolean containsCoord(Coord coord) {
|
||||
// for (Coord c : this.coords) {
|
||||
// if (c.equals(coord)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
public int scoreLinks(int playerID) {
|
||||
int maxIslands = 0;
|
||||
int distinctIslandsCounter = 0;
|
||||
int score = 0;
|
||||
|
||||
Coord[] playerCoords = players[playerID].getPieces(); // playerCoords
|
||||
|
||||
for(Island island : islands) {
|
||||
Coord[] islandCoords = island.getCoords();
|
||||
|
||||
for ( Coord playerCoord : playerCoords ) {
|
||||
if (island.containsCoord(playerCoord)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(Island island : islands) {
|
||||
// Coord[] islandCoords = island.getCoords(); // Island Coords
|
||||
//
|
||||
// for ( Coord playerCoord : playerCoords) {
|
||||
// for( Coord islandCoord : islandCoords) {
|
||||
// if (playerCoord.areTwoCoordsLink(islandCoord) && )
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
return maxIslands * 5; //! TODO
|
||||
}
|
||||
|
||||
// public boolean areTwoCoordsLink ( Coord coord) {
|
||||
// if(isAdjacent(coord) || isAdjacentDiagonal(coord)) return true;
|
||||
// else return false;
|
||||
// }
|
||||
//
|
||||
// public Coord[] longestLink ( Coord coord) {
|
||||
// ArrayList<Coord> linkContainer = new ArrayList<>();
|
||||
// if (areTwoCoordsLink(coord)) {
|
||||
// linkContainer.add(coord);
|
||||
// }
|
||||
//
|
||||
// Coord[] endLinkContainer = new Coord[linkContainer.size()];
|
||||
// return endLinkContainer;
|
||||
// }
|
||||
|
||||
// Score Links
|
||||
// * A (potentially) branching path of neighbouring settlers and villages
|
||||
// * belonging to a player forms a chain. Players earn points from the chain
|
||||
// * of their pieces which links the most islands. Players earn 5 points
|
||||
// * per linked island in this chain.
|
||||
|
||||
// public int scoreTotalIslands(int playerID) {
|
||||
// int score = 0;
|
||||
// int islandCount = 0;
|
||||
// for (Island island : islands) {
|
||||
// // Get island coords
|
||||
// Coord[] islandCoords = island.getCoords();
|
||||
// // Get player's coords
|
||||
// Coord[] playerCoords = players[playerID].getPieces();
|
||||
// // Check if player has a piece on the island
|
||||
// boolean hasPiece = false;
|
||||
// for (Coord playerCoord : playerCoords) {
|
||||
// for (Coord islandCoord : islandCoords) {
|
||||
// if (playerCoord.equals(islandCoord)) {
|
||||
// hasPiece = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (hasPiece) break;
|
||||
// }
|
||||
// if (hasPiece) islandCount++;
|
||||
// }
|
||||
//
|
||||
// if (islandCount >= 8) score = 20;
|
||||
// else if (islandCount == 7) score = 10;
|
||||
//
|
||||
// return score;
|
||||
// }
|
||||
|
||||
// public boolean isAdjacent(Coord coord) {
|
||||
// if (this.y == coord.y) {
|
||||
// return (this.x == coord.x - 1 || this.x == coord.x + 1);
|
||||
// }
|
||||
// if (this.x == coord.x) {
|
||||
// return (this.y == coord.y - 1 || this.y == coord.y + 1);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Check if two coordinates are adjacent (includes diagonals)
|
||||
// * @param coord Coord object to compare to
|
||||
// */
|
||||
// public boolean isAdjacentDiagonal(Coord coord){
|
||||
// if (isAdjacent(coord)) return true;
|
||||
// if (this.x == coord.x - 1 && this.y == coord.y - 1) return true;
|
||||
// if (this.x == coord.x - 1 && this.y == coord.y + 1) return true;
|
||||
// if (this.x == coord.x + 1 && this.y == coord.y - 1) return true;
|
||||
// return (this.x == coord.x + 1 && this.y == coord.y + 1);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Score resources
|
||||
* @param playerID int player to score
|
||||
|
||||
Reference in New Issue
Block a user