#define RATI0 0.5 /* Number of lumberjacks to number of planters */
#define BLOCK 3 /* Area around the gamer to consider */
#define TREE_ZONE 0.4 /* Max percentage of trees in a zone */
-#define AGEUPDATETHRESHOLD 10 /* How frequently/how many rounds to increment age of tree */
+#define AGEUPDATETHRESHOLD 16 /* How frequently/how many rounds to increment age of tree */
#define MAXAGE 100 /* Max age of a tree */
maxValue = COLUMN -1;
int col = (rand.nextInt(Math.abs(maxValue - minValue) + 1)) + minValue;
int person;
- if((id&1) == 0) { //same as id%2
+ if((id&1) != 0) { //same as id%2
person = LUMBERJACK;
} else {
person = PLANTER;
}
Player gamer = new Player(person, row, col, ROW, COLUMN, BLOCK);
+
+ //
+ // Debug
+ // System.println("Player= "+ person+ " PosX= "+row+" PosY= "+col);
+ //
//Do N rounds
//do one move per round and synchronise
atomic {
doOneMove(land, gamer);
}
- Barrier.enterBarrier(barr);
if((i&15) == 0 && id == 0) { //same as i%AGEUPDATETHRESHOLD
/* Update age of all trees in a Map */
atomic {
barrserver.updateAge(land, MAXAGE, ROW, COLUMN);
}
}
+ Barrier.enterBarrier(barr);
}
}
/* Reset state if there in no path from start to goal */
if(newpath == null) {
- /* System.println("Path from ("+currx+","+curry+") to ("+gamer.getGoalX()+","+gamer.getGoalY()+") is null"); */
+ //
+ // Debug
+ // System.println("Path from ("+currx+","+curry+") to ("+gamer.getGoalX()+","+gamer.getGoalY()+") is null");
+ //
+
gamer.reset(land, ROW, COLUMN, BLOCK);
gamer.setState(INIT);
return;
//If tree present, cut
if (land[currx][curry].hasTree()) {
land[currx][curry].cutTree();
+ //
+ // Debug
+ // System.println("Cut tree");
+ //
}
} else { // PLANTER
// If empty, plant tree
if(hasMoreTrees(land, currx, curry) == false) {
TreeType t = global new TreeType();
land[currx][curry].putTree(t);
+ //
+ // Debug
+ // System.println("Put tree");
+ //
}
}
}
gamer.setState(INIT);
} else if(land[currx][curry].hasTree() && gamer.kind() == LUMBERJACK) { //Cut trees along the way
land[currx][curry].cutTree();
+ //
+ // Debug
+ // System.println("Cut tree while moving");
+ //
}
// Not at destination - do nothing
return;
areaCount++;
}
}
- if(treeCount > (TREE_ZONE * areaCount)) {
+ if(treeCount >= (TREE_ZONE * areaCount)) {
return true;
}
return false;
Node.java \
AStarPathFinder.java
-FLAGS1=-dsm -optimize -transstats -mainclass ${MAINCLASS}
+FLAGS1=-dsm -optimize -mainclass ${MAINCLASS}
FLAGS2=-dsm -dsmcaching -optimize -mainclass ${MAINCLASS}
FLAGS3=-dsm -dsmcaching -prefetch -optimize -mainclass ${MAINCLASS} -trueprob 0.90
-FLAGS4=-dsm -dsmcaching -rangeprefetch -optimize -mainclass ${MAINCLASS} -trueprob 0.90
default:
cpp ${MAINCLASS}.java > tmp1${MAINCLASS}.java
./extractLines
../../../../buildscript ${FLAGS1} -o ${MAINCLASS}NPNC ${SRC}
+ ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NPC ${SRC1}
../../../../buildscript ${FLAGS3} -o ${MAINCLASS}N ${SRC}
clean:
+ rm tmp1RainForest.java
+ rm tmpRainForest.java
rm -rf tmpbuilddirectory
rm *.bin