@@ -117,11 +117,16 @@ void start(InputStream is, PrintStream out) {
117
117
swapInfoAndViewData ();
118
118
log .info ("Turn " + turn );
119
119
newTurn = true ;
120
- outputsRead = false ; // Set as true after first getOutputs() to forbib sendInputs
120
+ outputsRead = false ; // Set as true after first getOutputs() to forbid sendInputs
121
121
122
122
referee .gameTurn (turn );
123
123
registeredModules .forEach (Module ::onAfterGameTurn );
124
124
125
+ // Create a frame if no player has been executed
126
+ if (!players .isEmpty () && players .stream ().noneMatch (p -> p .hasBeenExecuted ())) {
127
+ execute (players .get (0 ), 0 );
128
+ }
129
+
125
130
// reset players' outputs
126
131
for (AbstractPlayer player : players ) {
127
132
player .resetOutputs ();
@@ -163,8 +168,10 @@ void start(InputStream is, PrintStream out) {
163
168
*
164
169
* @param player
165
170
* Player to execute.
171
+ * @param nbrOutputLines
172
+ * The amount of expected output lines from the player.
166
173
*/
167
- void execute (T player ) {
174
+ protected void execute (T player , int nbrOutputLines ) {
168
175
if (!this .initDone ) {
169
176
throw new RuntimeException ("Impossible to execute a player during init phase." );
170
177
}
@@ -180,7 +187,7 @@ void execute(T player) {
180
187
dumpView ();
181
188
dumpInfos ();
182
189
dumpNextPlayerInput (player .getInputs ().toArray (new String [0 ]));
183
- if (player . getExpectedOutputLines () > 0 ) {
190
+ if (nbrOutputLines > 0 ) {
184
191
addTurnTime ();
185
192
}
186
193
dumpNextPlayerInfos (player .getIndex (), player .getExpectedOutputLines (), player .hasNeverBeenExecuted () ? firstTurnMaxTime : turnMaxTime );
@@ -203,6 +210,16 @@ void execute(T player) {
203
210
newTurn = false ;
204
211
}
205
212
213
+ /**
214
+ * Executes a player for a maximum of turnMaxTime milliseconds and store the output. Used by player.execute().
215
+ *
216
+ * @param player
217
+ * Player to execute.
218
+ */
219
+ void execute (T player ) {
220
+ execute (player , player .getExpectedOutputLines ());
221
+ }
222
+
206
223
/**
207
224
* Swap game summary and view.
208
225
*
0 commit comments