|
@@ -25,8 +25,8 @@ using namespace std;
|
|
|
|
|
|
// Typical cost
|
|
|
#define FLOOR_COST 0.04f
|
|
|
-#define HOLE_COST -1.0f
|
|
|
-#define TARGET_COST 1.0f
|
|
|
+#define HOLE_COST -1.1f
|
|
|
+#define TARGET_COST 1.01f
|
|
|
|
|
|
unsigned int identifyTile(unsigned int y, unsigned int x, unsigned int l) {
|
|
|
return y * l + x;
|
|
@@ -106,6 +106,23 @@ class World
|
|
|
|
|
|
for (int k(0); k < size; k++) {
|
|
|
board[k] = other.board[k];
|
|
|
+ cost[k] = other.cost[k];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Display the costs
|
|
|
+ void displayCosts() {
|
|
|
+ int current;
|
|
|
+ for (unsigned int i = 0; i < h; i++) {
|
|
|
+ for (unsigned int j = 0; j < l; j++) {
|
|
|
+ current = identifyTile(i, j, l);
|
|
|
+ cout << '|';
|
|
|
+ if (board[current] == WALL_TILE)
|
|
|
+ cout << "- -";
|
|
|
+ else
|
|
|
+ cout << cost[current];
|
|
|
+ }
|
|
|
+ cout << '|' << endl;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -197,6 +214,7 @@ int main()
|
|
|
cout << endl << "Default world" << endl;
|
|
|
w.showProperties();
|
|
|
w.displayBoard();
|
|
|
+ w.displayCosts();
|
|
|
|
|
|
const bool animation(DEFAULT_ANIMATION);
|
|
|
|
|
@@ -205,12 +223,14 @@ int main()
|
|
|
|
|
|
World w1(w);
|
|
|
w1.displayBoard();
|
|
|
+ w1.displayCosts();
|
|
|
|
|
|
// 2
|
|
|
cout << endl << "Policy iteration" << endl;
|
|
|
|
|
|
World w2(w);
|
|
|
w2.displayBoard();
|
|
|
+ w2.displayCosts();
|
|
|
|
|
|
// End
|
|
|
return 0;
|