The bot implementation of the Scala Basic Workshop had some drawbacks:
- it only knew about 'W' (Walls) and was not aware of other entities (such as good and bad plants, good and bad beasts)
- it got trapped easily by certain wall constellations and could not escape
Our aim is to implement an energy saving bot. It should become aware of the other entities in its surrounding and try to eat good things to gain energy, while avoiding bad things that draw energy.
The different kinds of plants and beasts, aka entities, are documented in the Scalatron Game Rules and Protocol.
The implementation uses abstract classes and case classes to categorize the kinds of fields a bot can encounter in its surrounding. Combined with matchers, these provide the opportunity to decide on a moving strategy.
Optional tasks were:
- to find out how to escape from room-like wall-fragments ✅
- use Mini-Bots ❎
- try out strategies ❎ (requires Mini-Bots)
- change Scalatron server parameters ❎
- Unit tests for the implementation ✅
- Bot code ✅
- A short README.md (this file) ✅
4. How to run the bot (see also: bot development README)
Given that you've already setup your JVM, Scala and sbt installation, these are the commands required to run the bot.
In the project's root directory, run sbt test
to run all tests.
Then run sbt deploy
to compile the bot code.
The Scalatron game server can be started with
./server/bin/startScalatronServer.sh
Enjoy!
- The bot keeps a global state with its moving direction. Its moving direction can be changed in order to react properly to entities on the game board.
- When finding a Zugar or Fluppet in its surrounding, the bot changes its moving direction to collect it.
- The bot tries to avoid walls, Toxiferae and Snorgs. When finding one (or more) of these in its current moving direction, it randomly chooses a free cell to move into, resulting in a random change in moving direction.
- Because this moving direction change is done at random, the bot can usually escape room-like wall fragments in just a few steps.