# AI Olympics 1998: MITosis The Programming Contest

Write a piece of code to control a small group of organisms which will compete against other players' life forms for survival.

There was an informational session about this event on Sunday, Jan 25, 1:30 PM in the 7th floor playroom. Talk to your teammates who attended to get up to speed.

## Objective:

Survive as long as possible with as much energy as possible.   The contest will be a tournament of games, where each game is held between four players; the two top players of each game continue into the next stage.

## Time line:

You may start writing code at any time.  Final submissions must be in by 5:00 pm on Saturday, Jan. 31. Submit the executable produced by build_script by copying it to your team's subdirectory in the directory linked to by submissions (untarred with the tarball); and additionally, mail source code to aio@ai.mit.edu when you submit.

## Basic Game Elements:

• Entity:  an instance of your player, created by taking a Split action; you may have as many of these as your energy and time allows
• Field of food: source of energy for entity
• Ditches of toxin: source of pain for entity (takes away energy)
• Playing board:  100x100 field of squares with food, toxin and entities. Coordinates: the upper left is (0,0), the upper right (99,0), the lower left (0,99). The player knows its own coordinates.
• On each round, every organism in each player's group of life forms gets one turn (the highest energy life form goes first within the round, etc.).
• The first round is round 1; play stops after round 1000.
• When an entity runs out of energy, it dies.
• The entities have the following senses: Look, Smell, and Feel.
• The entities can take the following actions on each round: Look, Split, Move, and Stay.

## Energy Calculations:

Begin each game with 200 calories, then
• -1 for moving or staying in place (charged even if move fails)
• +10 for eating food (food is consumed as soon as you touch it)
• -20 for standing on toxin (toxin is not depleted)
• -10 for MITosis (splitting), then remaining energy is evenly divided among daughters

## Entity's Senses:

• Look:  if you execute a Look action (and pay for it), on the next move you get a map of the exact contents of the grid (current as of when you get it) in a square region centered on you, side length (2*radius+1). You get back a 2-D array (NOTE: this is indexed [y][x]) and the grid location of its upper-left corner (the entity is in the middle). Remember, this costs your entity a turn to take the Look action.
• Smell:  on every move each entity is provided for free with numbers representing three smells, sensing the presence of food, toxin, and foe (opponents' entities). The sense of smell is non-directional, and is the Sum{1/r^2} of all locations on the whole board of the object you're smelling. (Special Case: if you're on a toxin, you can't smell that one bit of toxin, so the number returned is the Sum{1/r^2} of all the other toxin on the board.)
• Feel: along with smell, on every you move you get to know the most recent contents of that grid square (other than you) -- or empty if it were unoccupied before your prior turn. This costs no energy.

## Entity's Actions:

• Move: either one square up, down, left, right, or stay
• Split:  clone this entity (perform 'MITosis')
• Look:  you can choose to perform a look instead of a move or split as the action for a round. On that entity's next turn, they will get the result of the look. You pay the energy penalty immediately, which depends on the "radius" you specify.

## Scoring:

### The player's score is:

(player's total energy) + (last round alive)
• The "player's total energy" is the sum of all that player's (surviving) entities' energy at the end of the game. This is 0 if no entities survive until the end of the game.
• The "last round alive" is the latest round in which any of the player's entities were alive (still had nonzero energy). This is 1000 if some entities survive all the way through.
• The player's score is equal to what the simulator reports plus 1000.
• This score determines the top two from each game who proceed on to the next stage.

### The team's score is:

• The sum of the players' scores.
• Note that entering a player will never decrease a team's score. The scoring system rewards both participation and performance.
• The two ways of helping your team are to earn points, or alternatively to prevent opponents from doing so...

## Game Hints:

• Food is located in fields -- contiguous "fat" blobs of reasonable size (green)
• Toxin is located in trenches -- "thin" lines of poison (maroon)
• Splitting allows for more searching and eating (each of your entities can eat food, or perform a Look, on every turn), but burns more total energy (each entity expends its energy every turn)
• By Looking, it is possible to avoid toxin, but it costs energy and a turn
• There are no walls inside the playing field; everything outside is wall.
• You might want to make sure your player works for all for corners, and not just the upper left...

## Other Details:

• Code only runs on Solaris; the contest will be run on wheaties.
• Only allowed 5 seconds per 50 rounds of compute time on wheaties, otherwise player forfeits.
• The program you write remains running for the duration of the game, and the move routine is called once per entity per round, with an ID number specifying which entity the move is for.
• Cannot move into another square that is occupied by another  entity or a wall (though you still expend energy trying).
• Need to have a unoccupied (no other entities or wall, but may contain food or toxin) neighboring square to split. If your split fails, it's the same as a Stay.
• The moving energy cost is assessed independently of other adjustments; i.e., moving into a square with food looks like a net gain of 9 calories, moving into a square with (or staying in a square with) toxin looks like a net loss of 21.
• Look results are available at the start of the next round.
• Can print up to 10 messages per game; demonstrate your bravado, cunning or wit.
• Your routine gets called one more time after an instance dies, with a flag set telling you that it has died (e.g., for cleanup).
• Communication between entities of the same player is legal; communication between players (i.e., on the same team) is not. Also, don't save state between games; it won't be useful.
• Code should be written by the entering player. Collaboration within the teams is encouraged; you may share useful subroutines, and some ideas, but there must be some original code of your own in anything you submit -- do not put your name on a player you didn't write.

## Contest Supplies:

Updates and clarifications will be posted here during the contest. You will want to check periodically to stay current.
• [1/25]  The original version of this document had errors in: the score formula, the energy for moving, and the submission procedure (email source code too now). This should all have been clarified at the information session, and has been fixed on this page.
• [1/25]  BUG!! As documented, the look_info_ptr is supposed to be NULL unless it's returning a valid pointer to the results of a Look. This does not seem to be true! If do you a look, the results are valid; but sometimes if you didn't, it seems that you get a wild pointer rather than NULL.
• [1/25]  NOTE! The 2-D array squares in the Look_Info struct is indexed as [y][x]. The original example code released has misleading variable names in the Look_Info_Print() routine; there is a new version now (7pm, Sunday 1/25) with this fixed and the header file commented to explain this and the above non-NULL pointer bug.
• [1/27]  BUG!! The special case of the toxin smell being 1000 if you're on toxin is wrong. Instead, it appears that if you're on a toxin, that bit of toxin just doesn't figure into the smell at all, and it reports what would otherwise be the smell score if the toxin you're sitting on weren't there. (Note that you can still tell you're on a toxin, as the square_contents shows Toxin.) These docs were fixed accordingly.
• [1/27]  Added a "Detail" clarifying that move costs are assessed independently of food/toxin adjustments.
• [1/27]  Clarified that for splits, "unoccupied" means no other entities or wall, but does not exclude food or toxin.
• [1/28]  Added the "Detail" about communication between entities/players (as discussed in the info meeting).

## Contact:

Contact Mike Bosse or Greg Galperin for any more questions or clarifications.

Special thanks to Mil3, who developed this contest and the software for it!