Kalah tournament thread

Disclaimer: Dieser Thread wurde aus dem alten Forum importiert. Daher werden eventuell nicht alle Formatierungen richtig angezeigt. Der ursprüngliche Thread beginnt im zweiten Post dieses Threads.

Kalah tournament thread
I’m starting this for general questions on A.4.4 as those questions are best directed at the tutor running the competition.

A first question posted in a different thread:

Points
Agents that don’t crash and do anything smarter than play randomly received 100 base points.

The top 10 of the tournament additionally receive 10, 20, …, 100 points.

All points are bonus points.

Project import
Hello!
How do I import this repo in Intellij (or other IDE)? Anyone has maybe a guide or so how to this?
I never programmed with Scala and I am not really into Java programming. :smiley:
Thanks in advance!

Usage of Libraries
Are we allowed to use Libraries?
I plan to do a little bit of math and while I could probably implement everything I need from scratch, it would take some time. (obviously, I won’t use the library “Kalah-solver 2.0” or a gigantic monolith like Akka…)
There’s also an inconsistency in the requirements for Kalah-Framework on the Github page:
It reads that .scala files should be compatible with Scala 2.10, but the SBT requires 2.12, which makes more sense: 2.10 is end of life (as far as I know) and 2.13 has (small) breaking changes.
Is it fine if we use Scala 2.12 ?

P.S. If somebody has trouble getting Kalah to run: Try using java 8 or java 11, scala/sbt had some issues compiling with later java releases for me.

Regarding problems with the framework
A student told me that the Framework fails in Eclipse, but works fine with “IntelliJ Ultimate” which students can get for free, so there’s that.


Can you add a description how to build/run this from commandline in the CIP? I tried but it did not work.
Thank you


If someone still needs help setting up the Kalah project here is how I did it:

  1. Download/Clone/Fork the repository
  2. Open the project in Intellij Idea Ultimate
  3. Right-click on the project and select “open module settings”
  4. Under “Project Settings” go to “Project” and set Project SDK to 1.8
  5. And in modules set the language level of Kalah to 8
  6. Go to src>main>scala>info.kwarc.teaching.AI.Kalah and right-click on Test and select “Run Test”
  7. In the Agents folder you can create your own agent in scala or in java. I did it in Java. Just extend the Agent class in your implementation.
  8. Profit

Hope it helps

1 „Gefällt mir“

Thanks a lot, really. Finally got it Running :3
I will compile the instructions into an extended Readme file for the GIT repository, should I create a Pull Request on GitHub or send it by Mail? (@Tutors)
I am not into java that much, so if somebody else got it running in Eclipse or VSCode would you mind posting how you did so? I will try it out and add it to the instructions.
Hopefully, that will help all fellow students in the future.


Is Scala itself a broken language? I can’t even seem to compile a simple hello world. You’d think that a language has it’s standard library, added by default, but even after adding [m]-cp /usr/share/scala/lib/scala-library.jar[/m] to scalac, I still get

error: error while loading package, Missing dependency 'object java.lang.Object in compiler mirror', required by /usr/share/scala/lib/scala-library.jar(scala/package.class)
error: error while loading package, Missing dependency 'object java.lang.Object in compiler mirror', required by /usr/share/scala/lib/scala-library.jar(scala/runtime/package.class)
error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
	at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:16)
	at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:17)
	at scala.reflect.internal.Mirrors$RootsBase$$anonfun$getModuleOrClass$3.apply(Mirrors.scala:49)
	at scala.reflect.internal.Mirrors$RootsBase$$anonfun$getModuleOrClass$3.apply(Mirrors.scala:49)
...

I’d like to compile and run this without having to use tools like “Intel Ultimum”.


@zge Scala programs compiled by scalac have a runtime dependency on scala-library.jar. You have to invoke the [m]java[/m] command with your .class file (or JAR) with scala-library.jar being on classpath. Alternatively, use sbt for compiling and running.
Or use IntelliJ. I see how one can design algorithms without autocompletion, but not how one can code without it :slight_smile:


It took me a while, but I finally managed to create a makefile to build and start the project. The only issue is that I can’t build the „Fancy“ class, so I removed it. Here’s the diff, so do the same.

The main problem is that, as far as I see, the entire project has to be recompiled every time, but maybe that can be fixed somehow? Patches and improvements are gladly appriciated!

Usually a sane language would help, but I guess that not a viable option anymore. But either way, I’d rather stick to a normal work environment, where I don’t have to use the Hazmat suit-equivalent of a text editor.

Update: I fix the incremental update issue, should only rebuild the necessary files now.

1 „Gefällt mir“

Getting Fancy to run
Try using an older version of java: It seems that scala 12.10 is quite old and uses some libraries that are deprecated in java 14.
Switching from 14 to 11 or 8 did the job for me.
To prevent recompilation of the entire project after every change: use the sbt. Scala is pretty much built from the ground up to use maven/sbt. Using sbt, compiling takes about 5s for me. Also try using IntelliJ or something that does type checking on-the-fly: The advantage of functional programming languages is that you don’t need to “test-compile-test” your code as often (if you use the type checker to your advantage).

For the AI team: you should consider updating Kalah to scala 13.xx for next year. There are a few breaking changes from 12->13 but in general 13 is much more stable and runs with current java versions. (there are also only ~3-4 breaking changes so it should be possible to update)

1 „Gefällt mir“

Scala is an extremely good language. But setting up new projects in a new language is always a little painful.

Regarding problems with the framework
Hello all.

I have just setup Kalah framework in both eclipse and intelliJ. This was no problem at all:
Eclipse:
right click on project folder → import the .jar → right click on imported .jar → Add it to build path
Intellij:
right click on project folder → open module settings → libraries → click ‘+’ to add .jar

Anyway after extending a class from Agent and trying to start a game, i get the same exception thrown in both IDEs:

Eclipse:

  Caused by: java.lang.NoClassDefFoundError: scala/Product

IntelliJ:

  Exception in thread "main" java.lang.NoClassDefFoundError: scala.Product

Switching to java 11 and lower didn’t help… Appreciate any help :slight_smile:
Thanks in advance

Submission site
Hello all,

is the submission site already online? If yes, could someone provide me a link?

Many thanks in advance!


What happens to the threads after the timeout? Are they killed after the timeoutMove was read or do they still wait for move() to terminate?


I’m no tutor but I think they told us that the thread will be killed and the volatile variable will be read. Next move = new Thread.

Kalaha capture enemy pit
I have a question regarding the “capture move”. According to wikipedia one does only catch when the last seed lands in an empty pit of the active player (not when it lands in an empty pit of the enemy, capturing its own seeds).
However the provided environment allows capturing own seeds. Is this intended to be so?


Are you sure? I could not reproduce this in „two human player mode“.