Re: scala1

From Jahu, 1 Year ago, written in Plain Text, viewed 2 times. This paste will run down the curtain in 1 Second. This paste is a reply to scala1 from Jahu - view diff
URL https://paste.paivola.fi/view/fdec3be0 Embed
Download Paste or View Raw
  1. import scala.collection.mutable.Buffer
  2. import scala.util.Random
  3.  
  4. object MyBot extends App {
  5.     println("bot is running...")
  6.     new AntsGame().run(new MyBot)
  7.     println("bot is finished...")
  8. }
  9.  
  10. class MyBot extends Bot {
  11.  
  12.   def ordersFrom(game: Game): Set[Order] = {
  13.     // Your logic goes here.
  14.     // for example ...
  15.    
  16.    
  17.     val directions = List(North, East, South, West)
  18.     val ants = game.board.myAnts.values
  19.     ants.flatMap{ant =>
  20.       val dirs = Random.shuffle(directions)
  21.       val direction = dirs.find{aim =>
  22.         val targetTile = game.tile(aim).of(ant.tile)
  23.         !game.board.water.contains(targetTile)
  24.       }
  25.       direction.map{d => Order(ant.tile, d)}
  26.     }.toSet
  27.   }
  28. }

Reply to "Re: scala1"

Here you can reply to the paste above