Implement god mode
authorJBM <jbm@codingame.com>
Mon, 8 Jun 2020 15:05:52 +0000 (17:05 +0200)
committerJBM <jbm@codingame.com>
Mon, 8 Jun 2020 15:05:52 +0000 (17:05 +0200)
config/statement_en.html
config/stub.txt
src/main/java/com/codingame/game/Player.java
src/main/java/com/codingame/game/Referee.java
src/test/java/Player1.java

index 05a95cf..45659a2 100644 (file)
      <p>
        This draft's last change is:
        <strong>
      <p>
        This draft's last change is:
        <strong>
-         early game termination.
+         <code>iddqd</code>.
        </strong>
      </p>
    </div>
        </strong>
      </p>
    </div>
index 67a9f70..f19c822 100644 (file)
@@ -1,4 +1,4 @@
-read roadLength:int initialStones:int gameSeed:long gameSide:int reserved:int
+read roadLength:int initialStones:int gameSeed:long gameSide:int reserved:long
 gameloop
 read trollDistance:int stones:int opponentStones:int
 write 1
 gameloop
 read trollDistance:int stones:int opponentStones:int
 write 1
index 936a3f5..79d5aeb 100644 (file)
@@ -23,10 +23,10 @@ public class Player extends AbstractMultiplayerPlayer {
     }
 
     // same-typed positional parameters… a disaster waiting to happen
     }
 
     // same-typed positional parameters… a disaster waiting to happen
-    void gameInit(int roadLength, int initialStones, long seed) {
-        sendInputLine(String.format("%d %d %d %d 0",
+    void gameInit(int roadLength, int initialStones, long seed, long salt) {
+        sendInputLine(String.format("%d %d %d %d %d",
                                     roadLength, initialStones, seed,
                                     roadLength, initialStones, seed,
-                                    model.getMultiplier()));
+                                    model.getMultiplier(), salt));
     }
 
     void sendGameTurn() {
     }
 
     void sendGameTurn() {
@@ -61,7 +61,7 @@ public class Player extends AbstractMultiplayerPlayer {
         catch (NoSuchElementException e) { type = Action.Invalid; return; }
 
         s.useDelimiter(eol);
         catch (NoSuchElementException e) { type = Action.Invalid; return; }
 
         s.useDelimiter(eol);
-        if (s.hasNext(rest)) messageString = s.next(rest);
+        if (s.hasNext(rest)) messageString = s.next(rest).trim();
         else messageString = "";
         type = Action.Throw;
     }
         else messageString = "";
         type = Action.Throw;
     }
index 3aef88d..67d96e0 100644 (file)
@@ -9,17 +9,13 @@ import com.codingame.gameengine.core.AbstractPlayer.TimeoutException;
 import com.codingame.gameengine.core.AbstractReferee;
 import com.codingame.gameengine.core.GameManager;
 import com.codingame.gameengine.core.MultiplayerGameManager;
 import com.codingame.gameengine.core.AbstractReferee;
 import com.codingame.gameengine.core.GameManager;
 import com.codingame.gameengine.core.MultiplayerGameManager;
-import com.codingame.gameengine.module.entities.GraphicEntityModule;
-import com.codingame.gameengine.module.entities.Rectangle;
-import com.codingame.gameengine.module.entities.Sprite;
-import com.codingame.gameengine.module.entities.Text;
-import com.codingame.gameengine.module.entities.Curve;
+import com.codingame.game.GodModeManager;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 
 public class Referee extends AbstractReferee {
     @Inject private MultiplayerGameManager<Player> gameManager;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 
 public class Referee extends AbstractReferee {
     @Inject private MultiplayerGameManager<Player> gameManager;
-    @Inject private GraphicEntityModule graphicEntityModule;
+    @Inject private GodModeManager gm;
 
     @Inject private View view;
     @Inject private Model model;
 
     @Inject private View view;
     @Inject private Model model;
@@ -28,13 +24,14 @@ public class Referee extends AbstractReferee {
 
     @Override
     public void init() {
 
     @Override
     public void init() {
+        gm.init();
         model.init(gameManager.getSeed());
         gameManager.getPlayer(0).model = model.p0;
         gameManager.getPlayer(1).model = model.p1;
 
         for (Player p: gameManager.getPlayers()) {
             p.gameInit(model.roadLength, model.initialStones,
         model.init(gameManager.getSeed());
         gameManager.getPlayer(0).model = model.p0;
         gameManager.getPlayer(1).model = model.p1;
 
         for (Player p: gameManager.getPlayers()) {
             p.gameInit(model.roadLength, model.initialStones,
-                       gameManager.getSeed());
+                       gameManager.getSeed(), gm.getSalt());
         }
 
         view.init(model);
         }
 
         view.init(model);
@@ -71,7 +68,7 @@ public class Referee extends AbstractReferee {
          * least.
          */
         for (Player player : gameManager.getActivePlayers()) {
          * least.
          */
         for (Player player : gameManager.getActivePlayers()) {
-            player.receiveGameTurn();
+            player.receiveGameTurn(); gm.transcend(player);
             switch (player.type) {
             case Timeout:
                 disqualify(player, "T/O", "timed out!");
             switch (player.type) {
             case Timeout:
                 disqualify(player, "T/O", "timed out!");
@@ -122,6 +119,7 @@ public class Referee extends AbstractReferee {
          * exhaustion).
          */
         int delta = 0;
          * exhaustion).
          */
         int delta = 0;
+        gm.update(gameManager.getPlayers());
         for (Player player : gameManager.getActivePlayers()) {
             player.view.throwStones(player.stoneThrow);
             delta += player.model.getMultiplier() * player.stoneThrow;
         for (Player player : gameManager.getActivePlayers()) {
             player.view.throwStones(player.stoneThrow);
             delta += player.model.getMultiplier() * player.stoneThrow;
index bc78cb2..59cbc61 100644 (file)
@@ -9,13 +9,14 @@ public class Player1 {
 
         int roadLength = in.nextInt();
         int initialStones = in.nextInt();
 
         int roadLength = in.nextInt();
         int initialStones = in.nextInt();
+        in.nextLine();
 
         while (true) {
             int trollDistance = in.nextInt();
             int stones = in.nextInt();
             int opponentStones = in.nextInt();
            
 
         while (true) {
             int trollDistance = in.nextInt();
             int stones = in.nextInt();
             int opponentStones = in.nextInt();
            
-            System.out.println(1);
+            System.out.println("1 truc");
         }
     }
 }
         }
     }
 }