Moved IO to main

This commit is contained in:
Armin Friedl 2017-10-30 09:27:02 +01:00
parent a429ffa000
commit 46d70661c3
3 changed files with 8 additions and 15 deletions

View file

@ -15,7 +15,7 @@ object Main {
var input = StdIn.readLine() var input = StdIn.readLine()
while(input != null){ while(input != null){
Parser.dispatch(input) Parser.dispatch(input) foreach (println(_))
input = StdIn.readLine() input = StdIn.readLine()
} }
} }

View file

@ -4,15 +4,10 @@ import scala.util.Random
import bot.dbg import bot.dbg
object Brain { object Brain {
def move(in: Int): String = { def move(time: Int): String = {
val dirs = Array("left", "right", "up", "down") val dirs = Array("left", "right", "up", "down")
val dir = Random.nextInt(4) val dir = Random.nextInt(4)
dbg(Settings.toString)
dbg(CurrentState.board.toString())
dbg(dirs(dir))
dirs(dir) dirs(dir)
} }
} }

View file

@ -4,16 +4,14 @@ import bot.{dbg,log}
object Parser { object Parser {
def dispatch(input: String){ def dispatch(input: String): Option[String] = {
val parts: Seq[String] = input.split(" ") val parts: Seq[String] = input.split(" ")
parts(0) match { parts match {
case "settings" => settings(parts.tail) case Seq("settings", xs@_*) => settings(xs); None
case "update" => update(parts.tail) case Seq("update", xs@_*) => update(xs); None
case "action" => { case Seq("action", "character", _) => Some("bixiette")
if(parts(1) equals "character") println("bixiette") case Seq("action", "move", time) => Some(Brain.move(time.toInt))
else println(Brain.move(parts(2).toInt))
}
} }
} }