Package: slime-mind
Slime MindIntroductionWe made this game structure to allow us to write and test AI programs. Writers can use the example code to explore making their own AI. As a writer's code  advances they should submit it to be tested against other AI. Eventually tournaments will be run between all submissions.The current game is still being balanced and many of the parameters will likely be changed. Changes will be made in an attempt to balance the system but not destroy certain strategies. If someone figures out a way to win no matter what through complex AI or an out of the box strategy then good for them.Eventually additional game mechanics may be added, and a new game with the same basic structure but additional mechanics may be released.SetupSuggested IDEYou are free to use whatever editor you want to create your AI. If you don't know where to start, we recommendvisual studio codeInstalling pythonYou must install Python 3.6 or later. See thisguidefor steps.Installing librariesYou must installarcadeto visualize the game.Running MatchesRunnersThere are multiple ways to run AIs against each other. All of them are available inmain.py. For instructions trypython main.py --helpConfigurationThere are some configuration options inconfig.ini, such as the ability to turn off visualization.
Note: the multi-match runner does not visualize matches, regardless of therenderconfiguration.Game MechanicsSetupSlime Mind is played on a map that is broken into squares with a set number of columns and rows. The exact number of columns and rows may be changed in the config.py file. However the standard number that will be used for tournaments and such is:
30 columns and 15 rows (likely this will be tweaked). At the start of a game plants, rocks, and slimes are put randomly on the map and mirrored across x and y so player's have an even playing field.TurnsPlayer AIs control each individual slime from their team every turn. Once a game begins each object will be given a single round per turn.Rocks go first and do nothing.Plants will go next and run on a defined AI described in the Game Pieces section of this document.Slimes will then go alternating between each team until all slimes have gone.
Then the map will update and the turn will be completed.Game PiecesThere are three types of game piece in this game. All of them are given the following attributes:x - This is the column index of the game piece (starting from 0)
y - This is the row index of the game piece (starting from 0)RocksRocks are only meant to get in the way. They are placed at the beginning of the game and cannot be moved or destroyed.PlantsPlants are the food source for the slimes. All plants have the following attributes:max_level - This is the highest level a plant can reach.
level - Used to calculate the maximum health of the plant. 
max_hp - This is the most health a plant can have.
current_hp - This is the current health of a plant.Plants are placed at the beginning of the game at level 1 with a set amount of health. Every round the plant has a % chance to level up, which increases maximum health regains some lost health. Once a plant reaches its maximum level it will gain the ability to spread seeds. Every round a max level plant has a % chance to spread a seed to one of the 8 squares surrounding it. If a plant succeeds in seeding another plant at level 1 will be placed in the target square. Plants at maximum level will change color in the visualizer.SlimesSlimes are the gamepieces controlled by the submitted AI code and will be used to determine which AI wins a game. Each slime has the following attributes:xp - Used to calculate the level of a slime.
max_level - This is the highest level a slime can reach.
level - Used to calculate the attack and maximum health of the slime. 
maximum_hp - This is the most health a slime can have.
current_hp - This is the current health of a slime.
attack -  This is the amount of health a slime or plant will lose when this slime bites it.Slimes are placed at the beginning of the game at level 1. A slimes attack and maximum HP increase as they level up. The table below shows the minimum XP for a slime to become each level and the other attributes for that level. The full equation can be found in the code.xp	level	attack	max_hp
1	1	3	11
2	2	4	13
6	3	7	18
15	4	10	23
33	5	13	31
62	6	16	40
106	7	20	50
169	8	24	61
254	9	29	75
368	10	33	89
513	11	38	105
695	12	43	122Every turn each slime is given a round to take a single action determined by the submitted AI. Invalid commands and AI that exceed a set timeout are ignored, skipping that slime's round. Valid commands are applied immediately, before the next slime's round begins. Note that the game state given the AI is immutable, so changes are not reflected in the game engine.CommandsThere are only 10 acceptable commands that a slime can accept. They are:LEFT
RIGHT
UP
DOWN
BITELEFT
BITERIGHT
BITEUP
BITEDOWN
SPLIT
MERGEMove CommandsThe four move commands available to slimes are:LEFT
RIGHT
UP
DOWNMove commands attempt to move the slime in the corresponding direction (LEFTmoves the slime to the square that has the same y value but an x value of one less etc...). If the target square is occupied by another game piece or is past the edge of the map the move will be ignored.Bite CommandsThe four bite commands available to slimes are:BITELEFT
BITERIGHT
BITEUP
BITEDOWNBite commands attempt to attack nearby gamepieces in a particular direction. If there is not a valid target in the location then the slime will do nothing for its round. If there is a slime or plant object in the target location then that slime or plant will have itscurrent_healthreduced by the biting slimesattack. The biting slime will also have itscurrent_hpincreased by 1 and itsxpincreased by 1.Split CommandThe only split command available to slimes is:SPLITTo split a slime must be at least level 4. Splitting creates a new level 1 slime in any empty adjacent square. This divides thexpof the splitting slime by 4 (rounding down).Merge CommandsThe only merge command available to slimes is:MERGEThis sets a slime as ready to merge. If an adjacent friendly slime is ready to merge it will be destroyed and the initiating slime will gain itsxp. Every turn all slimes are set to no longer ready to merge, so you must coordinate merging within a single turn.Victory conditionsThe game will continue until turn 1000 or until one team has 0 slimes. Scores for each team are calculated based on the remaining slimes. This score calculation is based solely on the slimes levelnoton its total xp. The table below shows a simplified level to score ratio. The full equation can be found in the code.level	points
1	0.2
2	0.4
3	1.6
4	5.2
5	13.7
6	29.9
7	57.7
8	101.7
9	167.0
10	259.7
11	386.7
12	555.3The team with the most total points at the end of the game wins.Writing a Custom AIYour AI must inherit thePlayerBaseclass and override thecommand_slimemethod. See theplayerCodefolder for examples.PackagingRun the following commands to package this library:rm -rf dist build */*.egg-info *.egg-info
python3 setup.py sdist bdist_wheel
twine upload dist/*