Bot for the Scalatron game.
MasterBot follows simple algorithm:
- calculate distance to all interesting visible objects on the battlefield
- let CV = value(situation)
- for each possible move:
- simulate move
- let MV = value(situation)
- if MV is better than current best value remember MV and the move
- if move is not 'stay' (so it is possible to improve) move else go ESCAPE mode
- if Snorgs are approaching spawn an explosive GuardianMiniBot
- it there are goods (Fluppets or Zugars) spawn a HarvesterMiniBot
- if only 500 rounds left return to Master (enforced)
- if energy is very high => try to return to Master, else
- if sth to harvest is near => go and harvest, else
- if snorgs are approaching => try to escape, else
- if energy is enough => try to return to Master, else
- move randomly :-)
Assumed way of working with this project is to:
- import into IDE
- sbt ~package so that all changes are continuously build into JAR file
- in the Scalatron/bots create a directory with the name of your bot (can be any) and link there target JAR as ScalatronBot.jar
Now if you change the code SBT will try to build JAR file and after reloading Scalatrong engine (with R key) all changes will be reflected in your Bot behaviour.
BotCommand.scala include case classes for various commands which can be sent to the environment
Bot.scala contains Bot logic
BotView.scala contains of BotView helper class to find objects on the battle field visible by the Bot
Distance.scala is a helper to calculate distance from given coord on the field to all accessible fields
GoalValue.scala is a definition of the Value(view) function which is used by the Bot to make decisions
ServerCommand.scala contains definitions of commands send by the environment
ServerCommandParser.scala is a parser from text sent by the environment to ServerCommand objects
ControlFunctionFactory.scala is a control function calle by the environment which parse environment signals and pass them to either Master or Mini bot objects