Work Hard, plAI Harder!

Gokul and I came first for plAI this Apogee. Here are a few details:

plAI was a competition where we had to create artificially intelligent bots to collect as many resources as possible in a given environment. In addition, we had to compete against another AI bot in this task. There could be two possible ways of achieving victory:
  1. Based on the number of resources (“fish”) collected: Whichever bot collects the maximum number of fish before the time runs out would win. In the case of a tie, the bot which collected the first fish would win.
  2. Based on health: Each bot was equipped with a cannon, which could be fired to attack another bot. Getting hit by a cannon ball would cost the bot health. If one of the bots loses all its health, then it loses the game, irrespective of how many fish it has collected. Hitting land would also cost the bot/raft to lose health.
Thus, there were two aspects to the game: who can traverse the given terrain optimally and collect as many fish as possible, and an adversarial aspect: who would win in an encounter.
The bot is not given knowledge about its surrounding, but only about its immediate terrain- parameters like its current position in the map, whether any canon balls within its visibility range are flying towards it, whether there any any obstacles, enemies or fish in its immediate field of view, its current health, etc.
There were 4 primary parameters we could control: the direction of acceleration of the bot, whether or not its brakes are applied, whether or not its canon is firing and the direction at which its canon fires.
There were several other factors that we had to keep in mind, though, such as mathematical equations representing the viscosity of the water, which meant that we would always have to apply an acceleration, and the equation that gave the braking force.
Our strategy was two-fold:
  1. With regards to collecting the fish, we would make the bot traverse the terrain in a random fashion for a certain interval of time (say, 5 seconds), and if the bot remained in approximately the same region, we would then make it choose a direction at random, and continue in that direction. In case it no longer remains stuck (i.e., it was stuck in that location purely due to the random nature of traversal), then the random traversal of the terrain is resumed. In case it remains stuck however, i.e., it encounters an obstacle, it would travel parallel to that obstacle with a left arm on the wall approach, checking for cycles by keeping its starting position in mind. Thus, in a terrain with sparsely distributed obstacles, this algorithm would, in general, cause a randomized traversal of the map such that the bot doesn’t remain stuck in one location, while in the case of a map with a large number of obstacles, the bot would effectively take a left-arm-on-the-wall approach, which would be reasonably efficient in a maze-like environment, for example.
  2. With regards to firing the canon, at the start of the game, we randomly fired the canon to the diagonally opposite corner of the screen, where our opponents would likely start, hoping for some stray hits. Then, after we encountered the opponent, and they left our field of view, we would fire in the direction in which we last saw them, hoping for a few more stray hits.

There were several other minor details we had to take care of as well, such as ensuring that the bot takes the fish as soon as it sees it, irrespective of where any incoming canon balls are headed, ensuring that the bot ignore the fish if there’s an obstacle in between it and the fish, and ensuring that it ignores the enemy if there’s an obstacle between it and the enemy.

All in all, it was a ridiculously fun experience.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: