From: JBM Date: Thu, 4 Jun 2020 13:28:07 +0000 (+0200) Subject: Add a side seed for @pb4. Cry before the in-IDE HTML rendering. X-Git-Url: https://troll.desast.re/troll.git/commitdiff_plain/7b8732a6aba5c34e24aa324a25e2fae37f7149a7?ds=inline;hp=bdcfefd6f8535e698dfcd953d1d3944794bf4026 Add a side seed for @pb4. Cry before the in-IDE HTML rendering. --- diff --git a/PLAN.org b/PLAN.org index 91ba14d..6db6e52 100644 --- a/PLAN.org +++ b/PLAN.org @@ -11,7 +11,7 @@ That one's probably never going to be DONE ^^' * DONE left win bias bug * DONE upgrade deps * DONE Timings -* TODO Protocol +* DONE Protocol * DONE fenceposts * Quotes to include Trolls, it is said, were bred by Melkor because he desired a race as powerful as the giant Ents, the Tree-herds. @@ -43,12 +43,13 @@ That one's probably never going to be DONE ^^' Trolls are only counterfeits, made by the Enemy in the Great Darkness, in mockery of Ents, as Orcs were of Elves. J. R. R. Tolkien, The Two Towers (1954), Book III, Chapter 4: "Treebeard" * TODO View settings -- [ ] troll pants colors +- [X] troll pants colors * TODO Internationalised troll quotes - pain au chocolat ou chocolatine * DONE initial model parametrization * DONE view parameterization? * DONE troll races +* TODO html for salting the seed * BUGS ** viewer goes blank <2020-06-03 mer. 22:58> (22:19:12) Astrobytes: JBM, if you're around, the TVC viewer goes blank after a couple of games. Consistently. In Chrome. Other games not doing the same. diff --git a/config/Boss.java b/config/Boss.java index 4c2a766..c85c990 100644 --- a/config/Boss.java +++ b/config/Boss.java @@ -15,7 +15,9 @@ class Player { int roadLength = in.nextInt(); int initialStones = in.nextInt(); - in.nextLong(); + in.nextLong(); // seed + in.nextInt(); // side + nextLine(); while (true) { int trollDistance = in.nextInt(); diff --git a/config/statement_en.html b/config/statement_en.html index edffecf..b5f784b 100644 --- a/config/statement_en.html +++ b/config/statement_en.html @@ -111,9 +111,11 @@
Map Input

- Your first line of input contains three space-separated + Your first line of input contains space-separated parameters: - roadLength initialStones seed + roadLength initialStones + gameSeed gameSide + reserved1reservedN

roadLength
@@ -133,6 +135,19 @@ algorithms, and you're encouraged to do the same! See examples section below for simple ways to achieve that. +
gameSide
+
+ which side you're on, as -1 + or 1. It's not supposed to make a + difference to how you handle the rest of the game, but + you can XOR it to your gameSeed to have a + (reproducible) random that doesn't mecessarily draw + when it plays against itself. +
+
reservedN
+
+ one or more parameters, reserved for future use +
diff --git a/config/stub.txt b/config/stub.txt index 76ff251..67a9f70 100644 --- a/config/stub.txt +++ b/config/stub.txt @@ -1,4 +1,4 @@ -read roadLength:int initialStones:int gameSeed:long +read roadLength:int initialStones:int gameSeed:long gameSide:int reserved:int gameloop read trollDistance:int stones:int opponentStones:int write 1 @@ -10,6 +10,8 @@ INPUT roadLength: the distance (even) between both castles. The troll starts at half that distance. initialStones: the number of stones each castle starts with. gameSeed: a random number to salt and help make your games more reproducible. +gameSide: a suggested partial salt to help make your reproducible games more interesting. +reserved: first unused parameter. There may be more to come. trollDistance: distance between the troll and your castle. Keep it above zero! stones: number of stones you have left. opponentStones: number of stones your opponent has left. diff --git a/src/main/java/com/codingame/game/Player.java b/src/main/java/com/codingame/game/Player.java index 63f9e50..cb5bb4a 100644 --- a/src/main/java/com/codingame/game/Player.java +++ b/src/main/java/com/codingame/game/Player.java @@ -1,6 +1,7 @@ package com.codingame.game; import java.util.List; +import java.util.Random; import java.util.regex.Pattern; import java.util.Scanner; @@ -15,6 +16,7 @@ import com.codingame.gameengine.module.entities.Sprite; public class Player extends AbstractMultiplayerPlayer { Model.Player model; View.Player view; + Random random = new Random(); @Override public int getExpectedOutputLines() { @@ -23,8 +25,12 @@ public class Player extends AbstractMultiplayerPlayer { // same-typed positional parameters… a disaster waiting to happen void gameInit(int roadLength, int initialStones, long seed) { - sendInputLine(String.format("%d %d %d", - roadLength, initialStones, seed)); + int nReserved = random.nextInt(5); + String reserved = ""; + while (nReserved --> 0) reserved += " 0"; + sendInputLine(String.format("%d %d %d %d%s", + roadLength, initialStones, seed, + model.getMultiplier(), reserved)); } void sendGameTurn() { diff --git a/src/test/java/PlayerCheat.java b/src/test/java/PlayerCheat.java index 0f98d3c..555f2a4 100644 --- a/src/test/java/PlayerCheat.java +++ b/src/test/java/PlayerCheat.java @@ -8,6 +8,7 @@ public class PlayerCheat { int roadLength = in.nextInt(); int initialStones = in.nextInt(); + in.nextLine(); while (true) { int trollDistance = in.nextInt(); diff --git a/src/test/java/PlayerRand.java b/src/test/java/PlayerRand.java index a58d673..4dc9103 100644 --- a/src/test/java/PlayerRand.java +++ b/src/test/java/PlayerRand.java @@ -15,6 +15,7 @@ public class PlayerRand { int roadLength = in.nextInt(); int initialStones = in.nextInt(); + in.nextLine(); while (true) { int trollDistance = in.nextInt(); diff --git a/src/test/java/PlayerStupid.java b/src/test/java/PlayerStupid.java index 8cb1ed2..6c62466 100644 --- a/src/test/java/PlayerStupid.java +++ b/src/test/java/PlayerStupid.java @@ -8,6 +8,7 @@ public class PlayerStupid { int roadLength = in.nextInt(); int initialStones = in.nextInt(); + in.nextLine(); while (true) { int trollDistance = in.nextInt(); diff --git a/src/test/java/PlayerTimeout.java b/src/test/java/PlayerTimeout.java index ba337b3..0c3ccb1 100644 --- a/src/test/java/PlayerTimeout.java +++ b/src/test/java/PlayerTimeout.java @@ -8,6 +8,7 @@ public class PlayerTimeout { int roadLength = in.nextInt(); int initialStones = in.nextInt(); + in.nextLine(); while (true) { int trollDistance = in.nextInt();