Skip to content

tlasica/ScalatronBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScalatronBot

Bot for the Scalatron game.

Codacy Badge

Master Bot

MasterBot follows simple algorithm:

  1. calculate distance to all interesting visible objects on the battlefield
  2. let CV = value(situation)
  3. for each possible move:
  • simulate move
  • let MV = value(situation)
  • if MV is better than current best value remember MV and the move
  1. if move is not 'stay' (so it is possible to improve) move else go ESCAPE mode
  2. if Snorgs are approaching spawn an explosive GuardianMiniBot
  3. it there are goods (Fluppets or Zugars) spawn a HarvesterMiniBot

Harvester Mini Bot

  1. if only 500 rounds left return to Master (enforced)
  2. if energy is very high => try to return to Master, else
  3. if sth to harvest is near => go and harvest, else
  4. if snorgs are approaching => try to escape, else
  5. if energy is enough => try to return to Master, else
  6. move randomly :-)

How to run

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.

Code Structure

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

About

Bot for the Scalatron game. It's decisions are based on a simple value+distance function.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages