Cg-brutaltester, because you love to be brutal

You can also get that error if the referee doesn’t run correctly - which is very common on cg-mm.jar as it’s compiled with a very recent version of java so most people get a version error.

Oh. Nice to know :smiley:

Same here :

01:04:26,797 ERROR [com.magusgeek.brutaltester.GameThread] Exception in game 100
java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Unknown Source) ~[?:1.8.0_131]
at com.magusgeek.brutaltester.GameThread.run(GameThread.java:86) [cg-brutaltester-0.0.1.jar:?]

:"(

A quick message just to say that brutaltester can now handle the “new referees”. Just see the README.md file to know how to create the referees.

As always, i’m open to Pull Requests :stuck_out_tongue:

3 Likes

Oh that’s great, i just wrote my own UTTT referee for brutaltester in c++ yesterday.

Problem seem’s to be -l “./logs/” , if you run without it, it should work. I had the same problem.

If anybody else was stuck trying to run UTTT referee with this cryptic error

13:32:31,563 ERROR [com.magusgeek.brutaltester.GameThread] Negative score during game 1

Then the solution is to provide -Dleague.level=2 to your tictactoe.jar referee.

Full command example:

java -jar cg-brutaltester-1.0.0-SNAPSHOT.jar -r "java -jar -Dleague.level=2 tictactoe.jar" -p1 "cmake-build-debug/uttt" -p2 "cmake-build-debug/uttt" -t 1 -n 1

And if you’re wondering how would I know that, then it’s buried deep deep in the CG game engine sources:

Wow nice catch. I think i’ll update my github to set the default league level at 2.
Thanks you.

No problem, I wanted to do that and submit a PR, but couldn’t figure out a clean way to set it (as you can see they call System.getProperty every time)…

While we’re on the subject of updating UTTT referee, maybe change timeout to 1000ms globally as it seemed to crash for me with default 100ms (even though bot itself has strict 95ms limit).

I had to change this for the logs:

--- a/src/main/java/com/magusgeek/brutaltester/GameThread.java
+++ b/src/main/java/com/magusgeek/brutaltester/GameThread.java
@@ -47,7 +47,7 @@ public class GameThread extends Thread {
                }

                if (logs != null) {
-                       command[playersCount * 2 + 2] = "-l";
+                       command[splitted.length + playersCount * 2] = "-l";
                }
        }

Oh yes i forgot to test logs with new referees :smiley:

Hi Magus,
I’ve updated game-ultimate-tictactoe and cg-brutaltester from your github and still have ‘Negative score during game 1’ running with
C:\Programs\JDK8\bin\java.exe -jar C:\Projects\cg-brutaltester\target\cg-brutaltester-1.0.0-SNAPSHOT.jar -r "java -jar C:\Projects\game-ultimate-tictactoe\target\tictactoe-1.0-SNAPSHOT.jar" -p1 test_p1.bat -p2 test_p2.bat -t 1 -n 1
I’ve also tried to pass -Dleague.level=2 to referee java call, but it doesn’t change anything. Is there something else that should be done?
Thanks.

First, don’t forget the -Dleague.level=2 in the referee command line.

Second, if you are on windows like me, the codingame SDK got a big problem to measure time. So most of the time the game is finished with a timeout at first round …

To avoid that i changed the timeouts constants in the referee. Just replace them with a very big number :smiley:

I’m having almost the same issue using cg-brutaltester for the first time on the current contest Code of Kutulu.
I program in Groovy

java -jar cg-brutaltester.jar -r "java -jar cok-referee.jar" -p1 "src/CodeOfKutulu.groovy" -p2 "src/CodeOfKutulu.groovy" -p3 "src/CodeOfKutulu.groovy" -p4 "src/CodeOfKutulu.groovy" -n 1 -v

21:11:00,257 INFO [com.magusgeek.brutaltester.Main] Verbose mode activated
21:11:00,258 INFO [com.magusgeek.brutaltester.Main] Referee command line: java -jar cok-referee.jar
21:11:00,259 INFO [com.magusgeek.brutaltester.Main] Player 1 command line: src/CodeOfKutulu.groovy
21:11:00,260 INFO [com.magusgeek.brutaltester.Main] Player 2 command line: src/CodeOfKutulu.groovy
21:11:00,261 INFO [com.magusgeek.brutaltester.Main] Player 3 command line: src/CodeOfKutulu.groovy
21:11:00,261 INFO [com.magusgeek.brutaltester.Main] Player 4 command line: src/CodeOfKutulu.groovy
21:11:00,261 INFO [com.magusgeek.brutaltester.Main] Number of games to play: 1
21:11:00,264 INFO [com.magusgeek.brutaltester.Main] Number of threads to spawn: 1
21:11:00,364 ERROR [com.magusgeek.brutaltester.GameThread] Exception in game 1
java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862) ~[?:1.8.0_112]
at java.util.Scanner.next(Scanner.java:1485) ~[?:1.8.0_112]
at java.util.Scanner.nextInt(Scanner.java:2117) ~[?:1.8.0_112]
at java.util.Scanner.nextInt(Scanner.java:2076) ~[?:1.8.0_112]
at com.magusgeek.brutaltester.GameThread.run(GameThread.java:85) [cg-brutaltester.jar:?]
21:11:00,369 ERROR [com.magusgeek.brutaltester.GameThread] If you want to replay and see this game, use the following command line:
21:11:00,371 ERROR [com.magusgeek.brutaltester.GameThread] java -jar cok-referee.jar -p1 src/CodeOfKutulu.groovy -p2 src/CodeOfKutulu.groovy -p3 src/CodeOfKutulu.groovy -p4 src/CodeOfKutulu.groovy -s
21:11:00,372 INFO [com.magusgeek.brutaltester.Main] *** End of games ***
±---------±---------±---------±---------±---------+
| Results | Player 1 | Player 2 | Player 3 | Player 4 |
±---------±---------±---------±---------±---------+
| Player 1 | | NaN% | NaN% | NaN% |
±---------±---------±---------±---------±---------+
| Player 2 | NaN% | | NaN% | NaN% |
±---------±---------±---------±---------±---------+
| Player 3 | NaN% | NaN% | | NaN% |
±---------±---------±---------±---------±---------+
| Player 4 | NaN% | NaN% | NaN% | |
±---------±---------±---------±---------±---------+

The bot works fine in the online CodinGame IDE.
I tried using the following in the beginning:

System.err.flush()
System.out.flush()

but that didn’t help. :neutral_face:
Any idea how to fix this?

Edit: Tried using only Players from the tests here https://github.com/JohnnyGuye/code-of-kutulu/tree/master/codeOfKutulu/src/test/java/runner/tests

java -jar cg-brutaltester.jar -r "java -jar cok-referee.jar" -p1 "Random.java" -p2 "Waiter.java" -p3 "Yell.java" -p4 "Useplan.java"

but same error

I managed to alter Code of Kutulu referee to run it with Cg-brutaltester. Not sure on the moral aspect of sharing the code during the contest (I can put it to github if some admin or Magus says its ok), but I can offer some clues that might be useful also for future contests:

  1. Get the game running locally using the referee only with the CommandLineInterface from Cg-brutaltester.
  • Start by applying the steps on https://github.com/dreignier/cg-brutaltester
  • You can start with some test players if they are provided in tests for referee code.
  • Changing the logging level to ‘trace’ helps for debugging ("rootLogger.level = trace" in log4j2.properties of referee). You might want to revert it once it runs fine.
  • Some method/class names can change comparing to tictactoe in https://github.com/CodinGame/codingame-game-engine . Download it and compare.
  • The lack of stdout flushing of players is a thing to look out for. For python -u option is enough, e.g. python -u kt.py
  • Before trying to run Cg-brutaltester make sure you can run referee with and without -s. E.g. for CoK this should work (depending on your path to test classes):
    java -jar codeOfKutulu-1.0.jar -p1 "java -cp . runner.tests.random.Player" -p2 "java -cp . runner.tests.random.Player" -p3 "java -cp . runner.tests.uselight.Player" -p4 "java -cp . runner.tests.yell.Player" -l ./logs/game1.json -s
    Without -s it should give you the final score and seed only.
  1. Then it should work with Cg-Brutaltester :slight_smile:

I’m not a Java guy, but I was able to that without any Java IDE, just had to get maven to build the packages (go into the directory with pom.xml and run mvn package) and change a name here and there.

As input to -p1, p2… you should provide a string that can be used to create a process. For groovy I guess it would be groovy src/CoK.groovy and for java you have to compile it into .class files and then run like java -cp . Waiter (mind the classpath).

After taking a look, I stumbled on your answer. It doesn’t work anymore. I tried running the referee manually like so but I’m still in league 1 because my first 4,4 move triggers an error.

The command I used is the following one:

java -Dleague.level=2 -jar ../referees/tictactoe.jar -l logs -p1 ../bench/codingame.bench_1-1.0.0.exe -p2 ../bench/codingame.bench_2-1.0.0.exe -d seed=2596996162

Not sure if it’s relevant but I’m on Windows 10 with Java 1.8.0_281.

Hello!!

I have been delaying the use of brutaltester for some time, but at the end I would have found it useful for this latest contest, with pretty bad leadearboard submision times the last three days. So I decided to try to finally install it and test it.

I think I have followed the steps explained in the GitHub.

  • I already had the java jdk 1.8
  • I installed Maven
  • I compiled the brutal tester apparently ok, I got the .jar as expected without errors
  • I also compiled downloaded and compiled the referee (spring2022)

But when I try to execute it with my bots I get an error with the log4j, as class not found:

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil
at org.apache.logging.log4j.jcl.LogAdapter.getContext(LogAdapter.java:39)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:47)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)
at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at com.magusgeek.brutaltester.Main.(Main.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

I am not very good at java environments. I have seen a reference to the log4j in the pom.xml of the brutalforce project, but I do not know how to make it work.

Please, any idea?
Thanks

I had the same problem for this challange. Removing this dependence from the brutalforce project fixed for me:

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-jcl</artifactId>
            <version>2.4.1</version>
        </dependency>

Also make sure you are using a modified spring2022 project where it have the CommandLineInterface main. This is one already modified that i have been using:

Thanks a lot for the answer…

I have done as you said, and now I have a different problem. It “plays” all the games but for each one it gives me an error (and consequently 0,0% victories for everybody):

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property ‘log4j2.debug’ to show Log4j2 internal initialization logging.

Just in case, these are the steps I have followed:

java -jar cg-brutaltester.jar -r “java -jar spider-attack-spring-2022.jar” -p1 “./spring2022.exe” -p2 “spring2022-3.5.exe” -t 2 -n 10

I must be missing something, but I do not know what. Any more ideas?

Thanks a lot

1 Like