Giter VIP home page Giter VIP logo

kalah-framework's Introduction

Kalah-Framework

Kalah framework for the AI course at FAU.

Discussion Forum: https://fsi.cs.fau.de/forum/144-Kuenstliche-Intelligenz

This contains:

  • target/scala-2.12/kalah_2.12-1.0.jar contains the compiled framework in total
  • target/scala-2.12/kalah_2.12-1.0-javadoc.jar contains the packaged (javadoc) documentation
  • target/scala-2.12/api contains the javadoc documentation and
  • src contains source files in scala and (thanks to Marcel Rupprecht for doing all the work!) java interfaces so you don't have to take care of converting scala data structures.

You are free to use scala or java; even though the framework is written in scala, all the interfaces you'll need to use standard java data types only.

To implement your own agent, create a new class/object extending [[info.kwarc.teaching.AI.Kalah.Agents.Agent]] and implement the required methods (init and move). For details see the documentation.

Rules:

  • You can submit a class or (in the case of scala) an object for your agents. If you submit a class, for each game we will create a new instance of this class. If it's an object, make sure that it works with consecutive games (i.e. be careful with states).
  • Please give your class/object a unique name (i.e. not something like MyAgent) and make sure that the name string value of your class/object is identical.
  • You can submit .class, .java, .scala or .jar-files; please put your agent in the classpath info.kwarc.teaching.AI.Kalah.WS2021.agents
  • Your submission may not exceed 200 MB.
  • Your implementation must not interact with external resources, such as the network or other programs.
  • If you use additional objects/classes, please put them in a unique namespace extending info.kwarc.teaching.AI.Kalah.WS2021.agents
  • Agents need to implement two methods: init and move. The first one will be called when the game starts. Your agent will be handed an instance of the Board-class, which contains e.g. the number of houses and starting seeds per house.
  • Your init method has about 10 seconds to terminate. If it doesn't terminate in 10 seconds, that agent will lose the current game.
  • Your move method has about 5 seconds to return a valid move. If it doesn't return a valid move in the time limit, its [[info.kwarc.teaching.AI.Kalah.Agents.Agent.timeoutMove]] variable will be taken instead.
  • The exact time limits may change, make sure your implementations can deal with any provided limit.
  • Given the time restrictions, please make sure your agents are thread-safe and can be forcefully killed in a reasonable time frame.

Agent GUI

Luca Reeb has kindly provided a GUI for debugging purposes in the subfolder KalahGUI. For a description, see KalahGUI/README.md.

Getting started

Tested for Ubuntu (18.04 LTS, 20.04 LTS)

Requirements:

  • Java 8
  • Scala
  • Intelli J IDEA (Community and Ultimate should both work)
  • Git (optional)

The .scala files should be compatible with scala 2.10. If there are any problems with the scala version, let me know as soon as possible via the forum. If there are any other problems with using my framework (like java interfacing) please let me/us know via the forum as soon as possible.

You can install the dependencies and IDE via:

sudo apt install openjdk-8-jdk scala git
sudo snap install intellij-idea-community --classic --edge

Cloning the Repository:

On the website of this repository, you should find the link for pulling in the top right above the code. you can also download the repo as a zip file.

git_pull

Also, you can directly go into the directory you want the repo to be and insert the following command into your terminal.

git clone https://github.com/KWARC/Kalah-Framework.git

Setup of the Project:

  • Open Intelli J and install the Scala plugin and restart Intelli J.
  • Click on open from folder and choose the folder you cloned the Repo into.
  • Intelli J should now install the dependencies for the project from the sbt file, which might take some "long" time.

If this is not happening, you might try these additional steps.

  • Open file "Kalah-Framework/src/main/scala/info/kwarc/teaching/AI/Kalah/Test", you will be ask which scala plugin should be used, choose the installed one.
  • Restart Intelli J
  • You will be ask to set the environments of Java and Scala.

module_settings

  • Set Java to "1.8" and the Scala environment to the system environment you installed.

module_settings

  • Now close Intelli J, delete the cloned repo and clone it fresh again.
  • Open Intelli J, click on open from folder and choose the folder you cloned the Repo into.

Continuing

  • Now you right-click on the top folder in your project browser and on "open module settings".

module_settings

  • In topic "Project" change the "SDK version" in the first drop-down menu to "1.8".
  • On the second drop-down menu change the "Project language level" to "8 - Lambdas, type annotations etc".

project_settings

  • In "Modules" you select "Kalah" and then "language level" to "8 - Lambdas, type annotations etc" in the drop-down menu.

module-settings

Start the Main Program:

  • Build the project
  • Navigate to "Kalah-Framework/src/main/scala/info/kwarc/teaching/AI/Kalah"
  • There you will find the Test.scala, right-click the file and select "Run Test"

run_test

  • The program should now start and show you the game interface. It is possible to enter the moves in the command line.

running

kalah-framework's People

Contributors

jazzpirate avatar jfschaefer avatar shadow992 avatar tkw1536 avatar tobs40 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kalah-framework's Issues

[Discussion] Kalah Network Protocol

Hi,

I have heard the complaint a few times, that the tournament "has to" programmed in Java/Scala (I know there are other JVM based languages, but it's still limiting). One idea was to implement a server, that interfaces with the existing infrastructure, where clients communicate via a network/local connection. I'm not sure if there will be enough time to implement this properly for this cycle, but I wanted to bring the point up anyway.

I've made a few sketches of how this would look like, but skimming the structure of the project, I don't think it can be trivially implemented without some restructuring.

The obvious advantage would be that nobody has to use a language they are uncomfortable with, so there are fewer advantages and disadvantages. The disadvantages would be that some languages can perform faster than others, there might delay, and monitoring the usage or resources could be harder. Also, security-wise, the clients would have to be containerised, to not manipulate the host system.

A protocol shouldn't have to be anything complicated, with some inspiration from using GTP, I could imagine something like, that should be parsable by even a programm written in C, without too much work.

  # this is a comment
  # lines beginning with ">" are client input, "<" are client output
  # the first two charachters of a line aren't part of the protocol
> version 1
> kahla 7 5 # start Kahla(7, 5)
> assign-player south
< sow-pit 3 south
> sow-pit 4 north
...
< resign

If there is any interest, further details could be discussed. I'm neither an expert when it comes to game protocols, nor Kalah, so there are certainly things that could be improved.

Even though there are issues, and work would have to be done, code has to be implemented, I do think it would be interesting. I wouldn't have opened the issue if that wasn't the case.

Illegal move

I noticed that the game continues if an agent does choose an illegal move.
Further, if the move is illegal, some random position is chosen.
Is that the intended behavior?

Prepare the framework so that the tournament can be run on a VM

TODO:

  • Can adding submissions into the project be improved?
  • Log everything, including exceptions.
  • Separate out which agents participate in each round of the tournament. The idea is not to do it automatically, but let the person running the tournament simply list the agent names for the next round in a file, or similar (see Dennis' explanation).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.