@jutge.org/toolkit 4.2.22 → 4.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/assets/problems/games/the-walking-dead.pbm/README.md +12 -0
  2. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/Makefile +6 -0
  3. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/api.tex +246 -0
  4. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/defs.tex +2 -0
  5. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/main.tex +63 -0
  6. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/programming.tex +452 -0
  7. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/rules.tex +222 -0
  8. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/screenshot.png +0 -0
  9. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/tips.tex +81 -0
  10. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/twd.png +0 -0
  11. package/assets/problems/games/the-walking-dead.pbm/ca/Doc/viewer.tex +41 -0
  12. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/Makefile +6 -0
  13. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/api.tex +246 -0
  14. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/defs.tex +2 -0
  15. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/main.tex +63 -0
  16. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/programming.tex +176 -0
  17. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/rules.tex +194 -0
  18. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/screenshot.png +0 -0
  19. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/tips.tex +85 -0
  20. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/twd.png +0 -0
  21. package/assets/problems/games/the-walking-dead.pbm/ca/Doc-eng/viewer.tex +36 -0
  22. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/AIDummy.o.Linux64 +0 -0
  23. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/AIDummy.o.Linux64.Debug +0 -0
  24. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/AIDummy.o.MacOS +0 -0
  25. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/AIDummy.o.MacOS.ARM +0 -0
  26. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/AIDummy.o.MacOS.ARM.Debug +0 -0
  27. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/AIDummy.o.MacOS.Debug +0 -0
  28. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/Board.o.Linux64 +0 -0
  29. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/Board.o.Linux64.Debug +0 -0
  30. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/Board.o.MacOS +0 -0
  31. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/Board.o.MacOS.ARM +0 -0
  32. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/Board.o.MacOS.ARM.Debug +0 -0
  33. package/assets/problems/games/the-walking-dead.pbm/ca/Obj/Board.o.MacOS.Debug +0 -0
  34. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/AIDemo.cc +89 -0
  35. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/AIDummy.cc +202 -0
  36. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/AINull.cc +37 -0
  37. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Action.cc +34 -0
  38. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Action.hh +107 -0
  39. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Board.cc +975 -0
  40. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Board.hh +287 -0
  41. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Defs.hh +2 -0
  42. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Game.cc +55 -0
  43. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Game.hh +23 -0
  44. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Info.cc +174 -0
  45. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Info.hh +129 -0
  46. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Main.cc +83 -0
  47. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Makefile +56 -0
  48. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Player.cc +66 -0
  49. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Player.hh +63 -0
  50. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/README.txt +9 -0
  51. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Random.cc +3 -0
  52. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Random.hh +88 -0
  53. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Registry.cc +28 -0
  54. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Registry.hh +42 -0
  55. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/SecGame.cc +368 -0
  56. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/SecGame.hh +90 -0
  57. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/SecMain.cc +99 -0
  58. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Settings.cc +67 -0
  59. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Settings.hh +175 -0
  60. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/State.cc +3 -0
  61. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/State.hh +188 -0
  62. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Structs.cc +3 -0
  63. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Structs.hh +377 -0
  64. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Utils.cc +3 -0
  65. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/Utils.hh +77 -0
  66. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/default-fixed.cnf +120 -0
  67. package/assets/problems/games/the-walking-dead.pbm/ca/Runner/default.cnf +17 -0
  68. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  69. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  70. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  71. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  72. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  73. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  74. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  75. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  76. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  77. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  78. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  79. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  80. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  81. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  82. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/css/ui-lightness/jquery-ui-1.8.18.custom.css +310 -0
  83. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/help.html +18 -0
  84. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/img/but_close.png +0 -0
  85. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/img/but_end.png +0 -0
  86. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/img/but_help.png +0 -0
  87. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/img/but_pause.png +0 -0
  88. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/img/but_play.png +0 -0
  89. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/img/but_refresh.png +0 -0
  90. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/img/but_start.png +0 -0
  91. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/img/logo.png +0 -0
  92. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/js/jquery-1.7.1.min.js +4 -0
  93. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/js/jquery-ui-1.8.18.custom.min.js +49 -0
  94. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/sample.out +52807 -0
  95. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/viewer.html +118 -0
  96. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/viewer.js +846 -0
  97. package/assets/problems/games/the-walking-dead.pbm/ca/Viewer/viewer.sh +28 -0
  98. package/assets/problems/games/the-walking-dead.pbm/ca/handler.yml +6 -0
  99. package/assets/problems/games/the-walking-dead.pbm/ca/problem.ca.yml +3 -0
  100. package/assets/prompts/creators/create-solution.tpl.txt +15 -8
  101. package/assets/prompts/proglangs/cc.md +6 -2
  102. package/assets/prompts/proglangs/py.md +10 -6
  103. package/dist/index.js +370 -366
  104. package/docs/getting-started-guide.md +1 -1
  105. package/docs/install-linux.md +1 -1
  106. package/docs/install-macos.md +1 -1
  107. package/docs/install-windows.md +1 -1
  108. package/package.json +11 -11
  109. package/toolkit/ask.ts +0 -2
  110. package/toolkit/doctor.ts +1 -1
  111. package/toolkit/make.ts +2 -2
@@ -0,0 +1,175 @@
1
+ #ifndef Settings_hh
2
+ #define Settings_hh
3
+
4
+
5
+ #include "Structs.hh"
6
+
7
+
8
+ /** \file
9
+ * Contains a class to store all the game settings that do not change
10
+ * during a game, except the names of the players.
11
+ */
12
+
13
+
14
+ /**
15
+ * Stores most of the game settings.
16
+ */
17
+ class Settings {
18
+
19
+ public:
20
+ /**
21
+ * Returns a string with the game name and version.
22
+ */
23
+ static string version ();
24
+
25
+ /**
26
+ * Returns the number of players in the game.
27
+ */
28
+ int num_players () const;
29
+
30
+ /**
31
+ * Returns the number of rounds a match lasts.
32
+ */
33
+ int num_rounds () const;
34
+
35
+ /**
36
+ * Returns the number of rows of the board.
37
+ */
38
+ int board_rows () const;
39
+
40
+ /**
41
+ * Returns the number of columns of the board.
42
+ */
43
+ int board_cols () const;
44
+
45
+ /**
46
+ * Returns the initial number of units per clan
47
+ */
48
+ int num_ini_units_per_clan () const;
49
+
50
+ /**
51
+ * Returns the initial number of zombies on the board
52
+ */
53
+ int num_ini_zombies () const;
54
+
55
+ /**
56
+ * Returns the initial number of food items on the board
57
+ */
58
+ int num_ini_food () const;
59
+
60
+ /**
61
+ * Returns the initial strength of each clan
62
+ */
63
+ int clan_ini_strength () const;
64
+
65
+ /**
66
+ * Returns the points obtained after killing a person
67
+ */
68
+ int points_for_killing_person () const;
69
+
70
+ /**
71
+ * Returns the points obtained after killing a zombie
72
+ */
73
+ int points_for_killing_zombie () const;
74
+
75
+ /**
76
+ * Returns the points obtained for each owned cell at the end of a round
77
+ */
78
+ int points_per_owned_cell () const;
79
+
80
+ /**
81
+ * Returns the units of strenght obtained by eating an item of food
82
+ */
83
+ int food_strength () const;
84
+
85
+ /**
86
+ * Returns the number of rounds before a bitten/dead person becomes a zombie
87
+ */
88
+ int rounds_before_becoming_zombie () const;
89
+
90
+ /**
91
+ * Returns whether pl is a valid player identifier.
92
+ */
93
+ bool player_ok (int pl) const;
94
+
95
+ /**
96
+ * Returns whether (i, j) is a position inside the board.
97
+ */
98
+ bool pos_ok (int i, int j) const;
99
+
100
+ /**
101
+ * Returns whether p is a position inside the board.
102
+ */
103
+ bool pos_ok (Pos p) const;
104
+
105
+ private:
106
+
107
+ friend class Info;
108
+ friend class Board;
109
+ friend class Game;
110
+ friend class SecGame;
111
+ friend class Player;
112
+
113
+ int NUM_PLAYERS;
114
+ int NUM_ROUNDS;
115
+ int BOARD_ROWS;
116
+ int BOARD_COLS;
117
+ int NUM_INI_UNITS_PER_CLAN;
118
+ int NUM_INI_ZOMBIES;
119
+ int NUM_INI_FOOD;
120
+ int CLAN_INI_STRENGTH;
121
+ int POINTS_FOR_KILLING_PERSON;
122
+ int POINTS_FOR_KILLING_ZOMBIE;
123
+ int POINTS_PER_OWNED_CELL;
124
+ int FOOD_STRENGTH;
125
+ int ROUNDS_BEFORE_BECOMING_ZOMBIE;
126
+
127
+ /**
128
+ * Reads the settings from a stream.
129
+ */
130
+ static Settings read_settings (istream& is);
131
+
132
+
133
+ bool ok () const;
134
+ };
135
+
136
+
137
+ inline string Settings::version () {
138
+ return "TheWalkingDead 1.0";
139
+ }
140
+
141
+ inline int Settings::num_players () const { return NUM_PLAYERS ;}
142
+ inline int Settings::num_rounds () const { return NUM_ROUNDS ;}
143
+ inline int Settings::board_rows () const { return BOARD_ROWS ;}
144
+ inline int Settings::board_cols () const { return BOARD_COLS ;}
145
+ inline int Settings::num_ini_units_per_clan () const { return NUM_INI_UNITS_PER_CLAN ;}
146
+ inline int Settings::num_ini_zombies () const { return NUM_INI_ZOMBIES ;}
147
+ inline int Settings::num_ini_food () const { return NUM_INI_FOOD ;}
148
+ inline int Settings::clan_ini_strength () const { return CLAN_INI_STRENGTH ;}
149
+ inline int Settings::points_for_killing_person () const { return POINTS_FOR_KILLING_PERSON ;}
150
+ inline int Settings::points_for_killing_zombie () const { return POINTS_FOR_KILLING_ZOMBIE ;}
151
+ inline int Settings::points_per_owned_cell () const { return POINTS_PER_OWNED_CELL ;}
152
+ inline int Settings::food_strength () const { return FOOD_STRENGTH ;}
153
+ inline int Settings::rounds_before_becoming_zombie () const { return ROUNDS_BEFORE_BECOMING_ZOMBIE ;}
154
+
155
+
156
+ inline bool Settings::player_ok (int pl) const {
157
+ return pl >= 0 and pl < num_players();
158
+ }
159
+
160
+ inline bool Settings::pos_ok (int i, int j) const {
161
+ return i >= 0 and i < board_rows() and j >= 0 and j < board_cols();
162
+ }
163
+
164
+ inline bool Settings::pos_ok (Pos p) const {
165
+ return pos_ok(p.i, p.j);
166
+ }
167
+
168
+
169
+ inline bool Settings::ok() const {
170
+ if (num_players() != 4) return false;
171
+ return true;
172
+ }
173
+
174
+
175
+ #endif
@@ -0,0 +1,3 @@
1
+ //////// STUDENTS DO NOT NEED TO READ BELOW THIS LINE ////////
2
+
3
+ #include "State.hh"
@@ -0,0 +1,188 @@
1
+ #ifndef State_hh
2
+ #define State_hh
3
+
4
+
5
+ #include "Structs.hh"
6
+ #include "Settings.hh"
7
+
8
+ /**
9
+ * Contains a class to store the current state of a game.
10
+ */
11
+
12
+
13
+ /**
14
+ * Stores the game state.
15
+ */
16
+ class State {
17
+
18
+ public:
19
+
20
+ /**
21
+ * Returns the current round.
22
+ */
23
+ int round () const;
24
+
25
+ /**
26
+ * Returns a copy of the cell at (i, j).
27
+ */
28
+ Cell cell (int i, int j) const;
29
+
30
+ /**
31
+ * Returns a copy of the cell at p.
32
+ */
33
+ Cell cell (Pos p) const;
34
+
35
+ /**
36
+ * Returns the a copy of the unit with identifier id.
37
+ */
38
+ Unit unit (int id) const;
39
+
40
+ /**
41
+ * Returns the ids of the alive units of a player
42
+ */
43
+ vector<int> alive_units (int pl) const;
44
+
45
+ /**
46
+ * Returns the ids of the dead units of a player
47
+ */
48
+ vector<int> dead_units (int pl) const;
49
+
50
+ /**
51
+ * Returns the ids of the zombies
52
+ */
53
+ vector<int> zombies () const;
54
+
55
+ /**
56
+ * Returns the current strength of a player ( strength_points/alive_units )
57
+ */
58
+ int strength (int pl) const;
59
+
60
+ /**
61
+ * Returns the current score of a player.
62
+ */
63
+ int score (int pl) const;
64
+
65
+ /**
66
+ * Returns the percentage of cpu time used so far, in the
67
+ * range [0.0 - 1.0] or a value lesser than 0 if the player is dead.
68
+ */
69
+ // NOTE: only returns a sensible value in server executions.
70
+ // In local executions the returned value is meaningless.
71
+ double status (int pl) const;
72
+
73
+
74
+ //////// STUDENTS DO NOT NEED TO READ BELOW THIS LINE ////////
75
+
76
+ private:
77
+
78
+ friend class Info;
79
+ friend class Board;
80
+ friend class Game;
81
+ friend class SecGame;
82
+ friend class Player;
83
+
84
+ vector< vector<Cell> > grid;
85
+
86
+ vector<int> scr; // score of each player
87
+ vector<int> scr_accumulated; // score referring to units and zombies killed
88
+ vector<int> nb_cells; // current number of cells conquered by player
89
+ vector<int> overall_strength; // strength of player (to be distributed among units)
90
+
91
+ vector<double> stats; // -1 -> dead, 0..1 -> % of cpu time limit
92
+ int rnd;
93
+
94
+ map<int, Unit> units;
95
+ vector< set<int> > player2alive_units;
96
+ vector< set<int> > player2dead_units;
97
+ set<int> zombies_;
98
+
99
+ /**
100
+ * Returns whether id is a valid citizen identifier.
101
+ */
102
+ inline bool unit_ok (int id) const {
103
+ return units.count(id);
104
+ }
105
+ };
106
+
107
+ inline int State::round () const {
108
+ return rnd;
109
+ }
110
+
111
+ inline Cell State::cell (int i, int j) const {
112
+ if (i >= 0 and i < (int)grid.size() and j >= 0 and j < (int)grid[i].size())
113
+ return grid[i][j];
114
+ else {
115
+ cerr << "warning: cell requested for position " << Pos(i, j) << endl;
116
+ return Cell();
117
+ }
118
+ }
119
+
120
+ inline Cell State::cell (Pos p) const {
121
+ return cell(p.i, p.j);
122
+ }
123
+
124
+ inline Unit State::unit (int id) const {
125
+ auto it = units.find(id);
126
+ if (it != units.end()) {
127
+ return it->second;
128
+ }
129
+ else {
130
+ cerr << "warning: unit requested for identifier " << id << endl;
131
+ return Unit();
132
+ }
133
+ }
134
+
135
+ inline vector<int> State::alive_units (int pl) const {
136
+ if (pl >= 0 and pl < (int) player2alive_units.size())
137
+ return vector<int>(player2alive_units[pl].begin(), player2alive_units[pl].end());
138
+ else {
139
+ cerr << "warning: alive units requested for player " << pl << endl;
140
+ return vector<int>();
141
+ }
142
+ }
143
+
144
+ inline vector<int> State::dead_units (int pl) const {
145
+ if (pl >= 0 and pl < (int) player2dead_units.size())
146
+ return vector<int>(player2dead_units[pl].begin(), player2dead_units[pl].end());
147
+ else {
148
+ cerr << "warning: dead units requested for player " << pl << endl;
149
+ return vector<int>();
150
+ }
151
+ }
152
+
153
+ inline vector<int> State::zombies () const {
154
+ return vector<int>(zombies_.begin(), zombies_.end());
155
+ }
156
+
157
+ inline int State::strength (int pl) const {
158
+ if (pl >= 0 and pl < (int) scr.size()) {
159
+ if (player2alive_units[pl].size() == 0) return 0;
160
+ else return overall_strength[pl]/player2alive_units[pl].size();
161
+ }
162
+ else {
163
+ cerr << "warning: strength requested for player " << pl << endl;
164
+ return -1;
165
+ }
166
+ }
167
+
168
+
169
+ inline int State::score (int pl) const {
170
+ if (pl >= 0 and pl < (int) scr.size())
171
+ return scr[pl];
172
+ else {
173
+ cerr << "warning: score requested for player " << pl << endl;
174
+ return -1;
175
+ }
176
+ }
177
+
178
+
179
+ inline double State::status (int pl) const {
180
+ if (pl >= 0 and pl < (int)stats.size())
181
+ return stats[pl];
182
+ else {
183
+ cerr << "warning: status requested for player " << pl << endl;
184
+ return -2;
185
+ }
186
+ }
187
+
188
+ #endif
@@ -0,0 +1,3 @@
1
+ //////// STUDENTS DO NOT NEED TO READ BELOW THIS LINE ////////
2
+
3
+ #include "Structs.hh"