@@ -117,11 +117,16 @@ void start(InputStream is, PrintStream out) {
117117 swapInfoAndViewData ();
118118 log .info ("Turn " + turn );
119119 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
121121
122122 referee .gameTurn (turn );
123123 registeredModules .forEach (Module ::onAfterGameTurn );
124124
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+
125130 // reset players' outputs
126131 for (AbstractPlayer player : players ) {
127132 player .resetOutputs ();
@@ -163,8 +168,10 @@ void start(InputStream is, PrintStream out) {
163168 *
164169 * @param player
165170 * Player to execute.
171+ * @param nbrOutputLines
172+ * The amount of expected output lines from the player.
166173 */
167- void execute (T player ) {
174+ protected void execute (T player , int nbrOutputLines ) {
168175 if (!this .initDone ) {
169176 throw new RuntimeException ("Impossible to execute a player during init phase." );
170177 }
@@ -180,7 +187,7 @@ void execute(T player) {
180187 dumpView ();
181188 dumpInfos ();
182189 dumpNextPlayerInput (player .getInputs ().toArray (new String [0 ]));
183- if (player . getExpectedOutputLines () > 0 ) {
190+ if (nbrOutputLines > 0 ) {
184191 addTurnTime ();
185192 }
186193 dumpNextPlayerInfos (player .getIndex (), player .getExpectedOutputLines (), player .hasNeverBeenExecuted () ? firstTurnMaxTime : turnMaxTime );
@@ -203,6 +210,16 @@ void execute(T player) {
203210 newTurn = false ;
204211 }
205212
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+
206223 /**
207224 * Swap game summary and view.
208225 *
0 commit comments