@jutge.org/toolkit 4.2.23 → 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,81 @@
1
+ \section{Consells}
2
+
3
+ \begin{itemize}
4
+
5
+ \item {\bf NO DONEU O DEMANEU EL VOSTRE CODI A NINGÚ}. Ni tan sols una
6
+ versió antiga. Ni fins i tot al vostre millor amic. Ni tans sols
7
+ d'estudiants d'anys anteriors. Utilitzem detectors de plagi per
8
+ comparar els vostres programes, també contra enviaments de jocs
9
+ d’anys anteriors. No obstant, podeu compartir arxius objecte.
10
+
11
+
12
+ Qualsevol plagi implicarà {\bf una nota de 0 en l'assignatura} (no
13
+ només del Joc) de tots els estudiants involucrats. Es podran també
14
+ prendre mesures disciplinàries addicionals. Si els estudiants A i B
15
+ es veuen implicats en un plagi, les mesures s'aplicaran als dos,
16
+ independentment de qui va crear el codi original. No es farà cap
17
+ excepció sota cap circumstància.
18
+
19
+
20
+ \item Abans de competir amb els companys, concentreu-vos en derrotar al Dummy.
21
+
22
+ \item Llegiu les capçaleres de les classes que aneu a utilitzar. No cal que mireu
23
+ les parts privades o la implementació.
24
+
25
+ \item Comenceu amb estratègies simples, fàcils d'implementar i depurar, ja que
26
+ és exactament el que necessitareu al principi.
27
+
28
+ \item Definiu mètodes auxiliars senzills (però útils) i \emph{assegureu-vos
29
+ que funcionin correctament}.
30
+
31
+ \item Intenteu mantenir el vostre codi net. Això farà més fàcil canviar-lo i afegir
32
+ noves estratègies.
33
+
34
+ \item Com sempre, compileu i proveu el vostre codi sovint. És \emph{molt}
35
+ més fàcil rastrejar un error quan només heu canviat poques línies de codi.
36
+
37
+ \item Utilitzeu @cerr@ per produir informació de depuració i afegiu
38
+ \texttt{assert}s per assegurar-vos que el vostre codi fa el que hauria de fer.
39
+
40
+ \item Quan depureu un jugador, elimineu els @cerr@s que tingueu en el codi
41
+ d’altres jugadors, per tal de veure només els missatges que desitgeu.
42
+
43
+ \item Podeu utilitzar comandes com el \texttt{grep} de Linux per tal de filtrar
44
+ la sortida produïda per \texttt{Game}.
45
+
46
+ \item Activeu l'opció \texttt{DEBUG} al Makefile, que us permetrà
47
+ obtenir traces útils quan el vostre programa avorta. També hi ha una opció
48
+ \texttt{PROFILE} que podeu utilitzar per optimitzar codi.
49
+
50
+ \item Si l'ús de @cerr@ no és suficient per depurar el vostre codi, apreneu
51
+ com utilitzar \texttt{valgrind}, \texttt{gdb} o qualsevol altra eina de depuració.
52
+
53
+
54
+ \item Podeu analitzar els arxius produïts per \texttt{Game}, que descriuen com
55
+ evoluciona el tauler a cada ronda.
56
+
57
+ \item Conserveu una còpia de les versions antigues del vostre jugador. Feu-lo lluitar
58
+ contra les seves versions anteriors per quantificar les millores.
59
+
60
+
61
+ \item Assegureu-vos que el vostre programa sigui prou ràpid. El temps de CPU que
62
+ es permet utilitzar és bastant curt.
63
+
64
+ \item Intenteu esbrinar les estratègies dels altres jugadors observant
65
+ diverses partides. D’aquesta manera, podeu intentar reaccionar als
66
+ seus moviments, o fins i tot imiteu-los o milloreu-los amb el vostre
67
+ propi codi.
68
+
69
+ \item No espereu fins al darrer minut per enviar el jugador. Quan hi
70
+ ha molts enviaments al mateix temps, el servidor triga més en
71
+ executar les partides i podria ser ja massa tard!
72
+
73
+ \item Podeu enviar noves versions del vostre programa en qualsevol moment.
74
+
75
+ \item Recordeu: mantingueu el codi senzill, compileu-lo sovint i proveu-lo sovint, o
76
+ us en penedireu.
77
+
78
+ \end{itemize}
79
+
80
+
81
+
@@ -0,0 +1,41 @@
1
+ \section{El Visor}
2
+
3
+ A continuació descrivim el visor de partides:
4
+
5
+ \begin{itemize}
6
+
7
+ \item A la part superior hi ha botons que permeten
8
+ reproduir o pausar la partida, anar al començament o al final de la
9
+ partida, activar o desactivar el mode d’animació o obtenir una
10
+ finestra d'ajuda amb més maneres de controlar com es reprodueix la
11
+ partida. També hi trobareu la ronda actual i un botó per tancar el
12
+ visor.
13
+ Una barra de desplaçament horitzontal mostra visualment en quin punt
14
+ de la partida es troba la ronda actual.
15
+
16
+ \item A la columna de l'esquerra, apareix cada jugador amb el nom i
17
+ color corresponents. A sota es mostra la puntuació actual, el
18
+ nombre d'unitats vives i la força del jugador corresponent. A les
19
+ partides jugades a Jutge.org, també es mostra el percentatge de
20
+ temps de CPU que s’ha consumit fins ara (si està esgotat, s’indica
21
+ amb un 'out'). A la part superior dreta apareixen els colors dels jugadors
22
+ ordenats per puntuació.
23
+
24
+ \item Les cel·les no posseïdes per ningú són de color blanc. En cas contrari, tenen el color del jugador que les posseeix.
25
+
26
+ \item Les cel·les amb deixalles tenen color gris fosc.
27
+
28
+ \item Les unitats vives es representen amb un cercle del color corresponent. En cas d'estar en procés de conversió, a zombi, tenen forma quadrada.
29
+
30
+ \item Les unitats mortes es representen amb una creu.
31
+
32
+ \item Els zombis es representen amb un quadrat vermell i contorn exterior negre.
33
+
34
+ \item Les unitats de menjar es representen amb un cercle vermell i contorn exterior negre.
35
+
36
+ \end{itemize}
37
+
38
+ %%% Local Variables:
39
+ %%% mode: latex
40
+ %%% TeX-master: t
41
+ %%% End:
@@ -0,0 +1,6 @@
1
+ all:
2
+ pdflatex main
3
+ pdflatex main
4
+
5
+ clean:
6
+ rm -rf *.pdf *.log *.aux *.dvi *.synctex.gz auto
@@ -0,0 +1,246 @@
1
+ \documentclass[catalan]{article}
2
+ \pagestyle{plain}
3
+
4
+ \usepackage{float}
5
+ \usepackage[utf8]{inputenc}
6
+ \usepackage{graphicx}
7
+ \usepackage{mdwlist}
8
+ \usepackage{textcomp}
9
+ \usepackage{mathpazo}
10
+ \usepackage{listings}
11
+ \usepackage{parskip}
12
+ \usepackage{color}
13
+ \usepackage{xspace}
14
+ \usepackage{url}
15
+
16
+ \makeatletter
17
+ \usepackage[catalan]{babel}
18
+ \makeatother
19
+
20
+ \newcommand{\warning}[1]{{\color{red} #1}}
21
+
22
+ \input{defs}
23
+
24
+ %%% LISTINGS
25
+
26
+ \lstset{language=C++}
27
+ \lstset{columns=flexible}
28
+ %\lstset{basewidth={1em,1em}}
29
+ \lstset{keepspaces=true}
30
+ \lstset{morekeywords={include,cin,cout,cerr,endl,null,string}}
31
+ \lstset{deletekeywords={for}}
32
+ \lstset{belowskip=0mm}
33
+ \lstset{stringstyle={}}
34
+ \lstset{commentstyle={}}
35
+ \lstset{numberstyle=\tiny\sffamily}
36
+ \lstset{numbersep=-5pt}
37
+ \lstset{keywordstyle=\bfseries}
38
+ \lstset{identifierstyle=\itshape}
39
+ \lstset{showstringspaces=false}
40
+ \lstset{upquote=true}
41
+ \lstset{texcl=true}
42
+ \lstset{mathescape=true}
43
+ \lstset{literate={->}{$\rightarrow$}1 {<=}{$\le$}1 {>=}{$\ge$}1 {!=}{$\neq$}1 {<<}{$<\!\!\!<$}2 {>>}{$>\!\!\!>$}2}
44
+ \lstset{xleftmargin=0.3cm}
45
+ \lstMakeShortInline@
46
+
47
+ \begin{document}
48
+
49
+ \begin{center}
50
+ {\bf \Large{Summarized API for playing The Walking Dead}}
51
+ \end{center}
52
+
53
+ \bigskip
54
+ This short document briefly presents the main types, classes and methods that you
55
+ may need to program your player.
56
+
57
+ {\bf Positions and directions.}
58
+ \begin{lstlisting}
59
+ // Enum to encode directions. Alive units cannot move diagonally
60
+ enum Dir {
61
+ Down, DR, Right, RU, Up, UL, Left, LD
62
+ };
63
+
64
+ // Simple struct to handle positions.
65
+ struct Pos {
66
+ int i, j;
67
+ };
68
+
69
+ Pos (int i, int j);
70
+ // Example: Pos p(3, 6);
71
+
72
+ ostream& operator<< (ostream& os, const Pos& p);
73
+ // Example: cerr $<\!\!<$ p $<\!\!<$ endl;
74
+
75
+ bool operator== (const Pos& a, const Pos& b);
76
+ // Example: if (p == Pos(3, 2)) ...
77
+
78
+ bool operator $!\!=$ (const Pos& a, const Pos& b);
79
+ // Example: if (p != Pos(3, 2)) ...
80
+
81
+ / Compares using lexicographical order (first by i, then by j).
82
+ // If needed, you can sort vectors of positions or build sets of positions.
83
+ bool operator< (const Pos& a, const Pos& b);
84
+ // Example: if (p $<$ Pos(3, 2)) ...
85
+
86
+ Pos& operator+= (Dir d);
87
+ // Example: p += Right;
88
+
89
+ Pos operator+ (Dir d );
90
+ // Example: Pos p2 = p + Left;
91
+
92
+ Pos& operator+= (Pos p);
93
+ // Example: p += Pos(3, 2);
94
+
95
+ Pos operator+ (Pos p );
96
+ // Example: p2 = p + Pos(3, 2);
97
+
98
+ // Returns whether (i, j) is a position inside the board.
99
+ bool pos$\_$ok (int i , int j );
100
+ // Example: if (pos ok(i + 1, j - 1)) ...
101
+
102
+ // Returns whether p is a position inside the board.
103
+ bool pos$\_$ok (Pos p );
104
+ // Example: if (pos ok(p1 + Down)) ...
105
+ \end{lstlisting}
106
+
107
+ \medskip
108
+ {\bf State of the game.}
109
+ \begin{lstlisting}
110
+ // Returns whether pl is a valid player identifier.
111
+ bool player$\_$ok (int pl) const;
112
+
113
+ // Identifier of your player, between 0 and 3.
114
+ int me ();
115
+
116
+ // Defines kinds of cells.
117
+ enum CellType {
118
+ Street,
119
+ Waste
120
+ };
121
+
122
+ // Describes a cell on the board, and its contents.
123
+ struct Cell {
124
+ CellType type; // The kind of cell (street or waste).
125
+ int owner; // The player that owns it, otherwise -1.
126
+ int id; // The id of a unit if present, or -1 otherwise.
127
+ bool food; // Whether it contains food
128
+ };
129
+
130
+ // Defines the type of the unit.
131
+ enum UnitType {
132
+ Alive,
133
+ Dead,
134
+ Zombie
135
+ };
136
+
137
+ // Describes an unit on the board and its properties.
138
+ struct Unit {
139
+ UnitType type; // The type of unit.
140
+ int id; // The unique id of this unit during the game.
141
+ int player; // The player that owns this unit
142
+ // (-1 if is a zombie)
143
+ Pos pos; // The position on the board.
144
+ int rounds$\_$for$\_$zombie; // Rounds before it becomes a zombie
145
+ // (-1 if is not being converted to zombie)
146
+ };
147
+
148
+ // Returns the current round.
149
+ int round () const;
150
+
151
+ // Returns a copy of the cell at (i, j).
152
+ Cell cell (int i, int j) const;
153
+ // Example: Cell c3 = cell(3, 6);
154
+
155
+ // Returns a copy of the cell at p.
156
+ Cell cell (Pos p) const;
157
+ // Example: Cell c2 = cell(p);
158
+
159
+ // Returns a copy of the unit with identifier id.
160
+ Unit unit (int id) const;
161
+ // Example: Unit u2 = unit(23);
162
+
163
+ // Returns the ids of the alive units of a player
164
+ vector$<$int$>$ alive$\_$units (int pl) const;
165
+ // Example: vector$<$int$>$ au = alive$\_$units(3);
166
+
167
+ // Returns the ids of the dead units of a player
168
+ vector$<$int$>$ dead$\_$units (int pl) const;
169
+ // Example: vector$<$int$>$ du = dead$\_$units(0)
170
+
171
+ // Returns the ids of the zombies
172
+ vector$<$int$>$ zombies () const;
173
+ // Example: vector$<$int$>$ z = zombies();
174
+
175
+ // Returns the current strength of a player ( strength$\_$points/alive$\_$units )
176
+ int strength (int pl) const;
177
+
178
+ // Returns the current score of a player.
179
+ int score (int pl) const;
180
+ \end{lstlisting}
181
+
182
+ \bigskip
183
+ {\bf Command actions.}
184
+ \begin{lstlisting}
185
+ // Commands unit with identifier id to move following direction dir.
186
+ void move (int id, Dir dir);
187
+ // Example: move(23,Down);
188
+ \end{lstlisting}
189
+
190
+ \bigskip
191
+ {\bf Initial settings.}
192
+ \begin{lstlisting}
193
+ // Returns the number of players in the game.
194
+ int num$\_$players () const;
195
+
196
+ // Returns the number of rounds a match lasts.
197
+ int num$\_$rounds () const;
198
+
199
+ // Returns the number of rows of the board.
200
+ int board$\_$rows () const;
201
+
202
+ // Returns the number of columns of the board.
203
+ int board$\_$cols () const;
204
+
205
+ // Returns the initial number of units per clan
206
+ int num$\_$ini$\_$units$\_$per$\_$clan () const;
207
+
208
+ // Returns the initial number of zombies on the board
209
+ int num$\_$ini$\_$zombies () const;
210
+
211
+ // Returns the initial number of food items on the board
212
+ int num$\_$ini$\_$food () const;
213
+
214
+ // Returns the initial strength of each clan
215
+ int clan$\_$ini$\_$strength () const;
216
+
217
+ // Returns the points obtained after killing a person
218
+ int points$\_$for$\_$killing$\_$person () const;
219
+
220
+ // Returns the points obtained after killing a zombie
221
+ int points$\_$for$\_$killing$\_$zombie () const;
222
+
223
+ // Returns the points obtained for each owned cell at the end of a round
224
+ int points$\_$per$\_$owned$\_$cell () const;
225
+
226
+ // Returns the units of strenght obtained by eating an item of food
227
+ int food$\_$strength () const;
228
+
229
+ // Returns the number of rounds before a bitten/dead person
230
+ // becomes a zombie
231
+ int rounds$\_$before$\_$becoming$\_$zombie () const;
232
+ \end{lstlisting}
233
+
234
+ \bigskip
235
+ {\bf Random.}
236
+ \begin{lstlisting}
237
+ // Returns a random integer in [l..u]. u - l + 1 must be between 1 and $10^6$ .
238
+ int random (int l , int u );
239
+ // Example: if (random(0, 4) $<$ 2) whatever();
240
+ // This code executes whatever() with probability 2/5.
241
+
242
+ // Returns a random permutation of [0..n-1]. n must be between 0 and $10^6$.
243
+ vector$<$int$>$ random permutation (int n);
244
+ \end{lstlisting}
245
+
246
+ \end{document}
@@ -0,0 +1,2 @@
1
+ \newcommand{\gameName}{The Walking Dead\xspace}
2
+ \newcommand{\gameAuthor}{Albert Oliveras\xspace}
@@ -0,0 +1,63 @@
1
+ \documentclass[english]{article}
2
+ \pagestyle{plain}
3
+
4
+ \usepackage{float}
5
+ \usepackage[utf8]{inputenc}
6
+ \usepackage{graphicx}
7
+ \usepackage{mdwlist}
8
+ \usepackage{textcomp}
9
+ \usepackage{mathpazo}
10
+ \usepackage{listings}
11
+ \usepackage{parskip}
12
+ \usepackage{color}
13
+ \usepackage{xspace}
14
+ \usepackage{url}
15
+
16
+ \makeatletter
17
+ \usepackage[english]{babel}
18
+ \makeatother
19
+
20
+ \newcommand{\warning}[1]{{\color{red} #1}}
21
+
22
+ \input{defs}
23
+
24
+ %%% LISTINGS
25
+
26
+ \lstset{language=C++}
27
+ \lstset{columns=flexible}
28
+ %\lstset{basewidth={1em,1em}}
29
+ \lstset{keepspaces=true}
30
+ \lstset{morekeywords={include,cin,cout,cerr,endl,null,string}}
31
+ \lstset{belowskip=0mm}
32
+ \lstset{stringstyle={}}
33
+ \lstset{commentstyle={}}
34
+ \lstset{numberstyle=\tiny\sffamily}
35
+ \lstset{numbersep=-5pt}
36
+ \lstset{keywordstyle=\bfseries}
37
+ \lstset{identifierstyle=\itshape}
38
+ \lstset{showstringspaces=false}
39
+ \lstset{upquote=true}
40
+ \lstset{texcl=true}
41
+ \lstset{mathescape=true}
42
+ \lstset{literate={->}{$\rightarrow$}1 {<=}{$\le$}1 {>=}{$\ge$}1 {!=}{$\neq$}1 {<<}{$<\!\!\!<$}2 {>>}{$>\!\!\!>$}2}
43
+ \lstset{xleftmargin=0.8cm}
44
+ \lstMakeShortInline@
45
+
46
+ \begin{document}
47
+
48
+ \title{\textbf{\large \gameName}}
49
+ \author{\gameAuthor}
50
+ \maketitle
51
+
52
+ \bigskip
53
+ \begin{center}
54
+ \includegraphics[width=13cm]{twd.png}
55
+ \end{center}
56
+
57
+ \newpage
58
+ \input{rules}
59
+ \input{viewer}
60
+ \input{programming}
61
+ \input{tips}
62
+
63
+ \end{document}
@@ -0,0 +1,176 @@
1
+
2
+ \section{Programming the game}
3
+
4
+ The first thing you should do is downloading the source code. It
5
+ includes a C++ program that runs the games and an HTML viewer to watch
6
+ them in a reasonable animated format. Also, a ``Null'' player and a
7
+ ``Demo'' player are provided to make it easier to start coding your own
8
+ player.
9
+
10
+ \subsection{Running your first game}
11
+
12
+ Here, we will explain how to run the game under Linux, but it should
13
+ work \mbox{under} Windows, Mac, FreeBSD, OpenSolaris, \dots You only need a
14
+ recent \texttt{g++} version, \texttt{make} installed in your system, plus a
15
+ modern browser like Firefox or Chrome.
16
+
17
+
18
+ \begin{enumerate}
19
+
20
+ \item Open a console and \texttt{cd} to the directory where you
21
+ extracted the source code.
22
+
23
+ \item If, for example, you are using a 64-bit Linux version, run:
24
+
25
+ \texttt{cp AIDummy.o.Linux64 AIDummy.o}
26
+
27
+ \texttt{cp Board.o.Linux64 Board.o}
28
+
29
+ If you use any other architecture, choose the right objects you will
30
+ find in the directory.
31
+
32
+ \item Run
33
+
34
+ \texttt{make all}
35
+
36
+ to build the game and all the players. Note that \texttt{Makefile}
37
+ identifies as a player any file matching \texttt{AI*.cc}.
38
+
39
+ \item This creates an executable file called
40
+ \texttt{Game}. This executable allows you to run a game using a command
41
+ like:
42
+
43
+ \texttt{./Game Demo Demo Demo Demo -s 30 -i default.cnf -o default.res}
44
+
45
+ This starts a match, with random seed 30, of four instances of the
46
+ player Demo, in the board defined in \texttt{default.cnf}. The output of
47
+ this match is redirected to \texttt{default.res}.
48
+
49
+ \item To watch a game, open the viewer file \texttt{viewer.html} with
50
+ your browser, for example by running \texttt{firefox viewer.html},
51
+ and load the file \texttt{default.res}.
52
+
53
+ \end{enumerate}
54
+
55
+
56
+ Use
57
+
58
+ \texttt{./Game --help}
59
+
60
+ to see the list of parameters that you can use. Particularly useful is
61
+
62
+ \texttt{./Game --list}
63
+
64
+ to show all the recognized player names.
65
+
66
+ \medskip
67
+
68
+ If needed, remember that you can run
69
+
70
+ \texttt{make clean}
71
+
72
+ to delete the executable and object files and start over the build.
73
+
74
+
75
+ \begin{center}
76
+ \includegraphics[width=12cm]{screenshot.png}
77
+ \end{center}
78
+
79
+
80
+ \subsection{Adding your player}
81
+
82
+ To create a new player with, say, name \texttt{Rick},
83
+ copy \texttt{AINull.cc} (an empty player that is provided as a template)
84
+ to a new file \texttt{AIRick.cc}.
85
+ Then, edit the new file and change the
86
+
87
+ \begin{center}
88
+ @#define PLAYER_NAME Null@
89
+ \end{center}
90
+
91
+ line to
92
+
93
+ \begin{center}
94
+ @#define PLAYER_NAME Rick@
95
+ \end{center}
96
+
97
+ The name that you choose for your player must be unique, non-offensive
98
+ and at most 12 characters long. This name will be shown in the website
99
+ and during the matches.
100
+
101
+ \medskip
102
+
103
+ Afterwards, you can start implementing the virtual method @play()@,
104
+ inherited from the base class @Player@. This method, which will be
105
+ called every round, must decide the orders to give to your units.
106
+
107
+ \medskip
108
+
109
+ You can define auxiliary type definitions, variables and methods inside
110
+ your player class, but the entry point of your code will always be the
111
+ @play()@ method.
112
+
113
+ \medskip
114
+
115
+ From your player class you can also call functions that you will find in the following files:
116
+
117
+ \begin{itemize}
118
+ \item \texttt{State.hh}: consulting the state of the game.
119
+ \item \texttt{Action.hh}: giving orders to your units.
120
+ \item \texttt{Structs.hh}: useful data structures.
121
+ \item \texttt{Settings.hh}: consulting the initial parameters of the game.
122
+ \item \texttt{Player.hh}: method @me()@.
123
+ \item \texttt{Random.hh}: random number generation.
124
+ \end{itemize}
125
+
126
+ You will find a summary of this information in the file \texttt{api.pdf}.
127
+ You can also examine the code of the ``Demo'' player in \texttt{AIDemo.cc}
128
+ as an example of how to use these functions.
129
+
130
+ \medskip
131
+
132
+ Note that you must not edit the @factory()@ method of your player
133
+ class, nor the last line that adds your player to the list of available
134
+ players.
135
+
136
+
137
+
138
+ \subsection{Restrictions when submitting your player}
139
+
140
+ When you think that your player is strong enough to enter the
141
+ competition, you can submit it to the Jutge. Since it will run in a
142
+ secure environment to prevent cheating, some restrictions apply to your
143
+ code:
144
+
145
+ \begin{itemize}
146
+
147
+ \item All your source code must be in a single file (like AIRick.cc).
148
+
149
+ \item You cannot use global variables (instead, use attributes in your
150
+ class).
151
+
152
+ \item You are only allowed to use standard libraries like
153
+ \texttt{iostream}, \texttt {vector}, \texttt {map}, \texttt {set},
154
+ \texttt {queue}, \texttt {algorithm}, \texttt {cmath}, \dots In many
155
+ cases, you don't even need to include the corresponding library.
156
+
157
+ \item You cannot open files nor do any other system calls (threads,
158
+ forks, \dots).
159
+
160
+ \item Your CPU time and memory usage will be limited, while they are
161
+ not in your local environment when executing with \texttt{./Game}.
162
+
163
+ \item Your program should not write to @cout@ nor read from @cin@. You
164
+ can write debug information to @cerr@, but remember that doing so in
165
+ the code that you upload can waste part of your limited CPU time.
166
+
167
+ \item Any submission to the Jutge must be an honest attempt to play the
168
+ game. Any try to cheat in any way will be severely penalized.
169
+
170
+ \item Once you have submitted a player to Jutge that has defeated the Dummy
171
+ player, you can send more submissions but you will have to change the
172
+ player name. That is, once a player has defeated Dummy, his name is
173
+ blocked and cannot be reused.
174
+
175
+ \end{itemize}
176
+