Fruitbots, a JS bot challenge

Fruitbots challengeI sometimes like to join bot challenges to improve my programming skills and logic reasoning.

Last week I discovered Fruitbots, a JavaScript bot challenge created by the Scribd staff. Like every good challenge of its type, it features simple rules and a clear bot API, also it can be scripted in 4 languages: Python, Lua, Ruby and JavaScript.

The Fruitbots world is a board with different kind of fruits lying around. The goal is to collect more fruits than the opponent bot, of many types as possible.

At the moment I developed just a simple-sample JavaScript bot called Look a Lot, with a clean strategy:

  • If on a useful fruit, eat it!
  • Else, go to the best direction, looking at:
    • nearer and rarer fruits
    • bonus for disputed fruits, if nearer than the opponent
    • avoid previous position, out of the border moves and to PASS

The bot seems good enough to get into the Top 50. If you’re curious the code is here, but if you like programming I invite you first to join the challenge and find your preferred bot rules!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.