Debug in CodinGame Scala Kit
Contents
In CodinGame, code is executed on server side. This makes debugging a luxury. In this post, I’ll share how to debug your Bot with Scala’s case class.
Feed Game State to Bot
In CodinGame Scala Kit, we model Bot as a function which maps game state to actions. Therefore, to debug the Bot locally, we only need to feed it with the game state. The following example shows how I debug my Caribbean Bot:
1 | object CaribbeanPlayerDebug { |
Data as Code
In scala, when you print a case class, you get a magic string because it can re-instantiate the case class itself. To feed your bot, just print the game state.
As shown in the GameLoop, we print the game state at line13.
1 | class GameLoop[C, S, A]( |
Another real-world example in Ghost-in-the-Cell contest:
