====== Ants ====== {{ soi:aufgaben:gordianknot.jpg}} Autor(en): Ruben Andrist\\ [[soi:aufgaben:ants:de|deutsch]], [[soi:aufgaben:ants:fr|français]], [[soi:aufgaben:ants:it|italiano]] [[soi:aufgaben:ants:notizen|Notes]] \\ [[soi:aufgaben:ants:eingabe|Game Server]] \\ [[soi:aufgaben:ants:loesung|Solutions]] ===== Introduction ===== In this game you will be guiding an ant population. At the beginning of every game, you are given a set of ants which all start in your own ant hill. You must give appropriate orders to your ants to remain standing as the last team. This can be done by fighting your enemies, by attacking their ant hill and by collecting food resources (to get one additional ant per 8 food collected). ===== Input Format ===== At the beginning of every turn, your program is given the current number //N// of ants, followed by each ant's properties: * The first line contains 3 integer values depicting the ant's relative coordinates (//Xi//, //Yi//) from your ant hill and whether the ant is currently carrying food or not (1 or 0). * On the following 7 lines, the 7x7 surroundings of this particular ant are printed. The surroundings as seen by the ants will be described using these symbols: * ''#'' - solid wall (impenetrable) * ''.'' - empty space (passable) * ''$'' - up to 100 food resources * ''O'' - your own ants (one or more) * ''X'' - enemy ants (one or more) * ''H'' - your own ant hill * ''E'' - an enemy ant hill Note that these symbols are always of qualitative nature: a ''$'' can be any number from 1 to 100 resources of food. Similarly, one can place several ants of the same team on a single tile. If an ant is standing on top of a resource tile, the food is not seen. Also, ants are not seen inside their ant hill. ===== Output Format ===== For every turn, your program has to print a string of the length //N//, consisting of the letters ''N'', ''W'', ''S'', ''E'' and ''H''. These letters are movement orders for North (Up), West (Left), South (Down), East (Right) and Hold (Stay). They are assigned to the ants in the order they were listed. Note that: * Ants may not move onto a solid wall tile '#'. * An ant not carrying food will automatically pick up food (max 1) when moved onto a food tile. * An ant carrying food will automatically unload this resource upon return to the ant hill. * If an ant is moved onto a field containing enemy ants, it kills one of them along with itself, leaving 10 food behind. * If an ant is moved onto the enemy ant hill 'E', it dies and three random ants of the attacked team are killed, leaving no food behind. This occurs even if there are ants currently inside the enemy ant hill! Ants killed in combat will not be listed any more during the next turn. Resources are only left until the tile contains a maximum of 100 food. If all ants of a player are killed, he loses the game and his ant hill is removed from the map. After your program has printed the commands for this turn, it must wait for the input of the next turn. ===== Sample Game ===== A sample game situation can be seen on the following map: ################################# ##........######........$$$$##### #..........##.............$$$$### #....H.....#................$$$## #....O.....#...$$$$X.........$$$# #..O..........$$$$$$.XX.........# #....O........$$$$$$....X.......# #$$$...........$$$$..#...XX.....# ##$$$................#.....E....# ###$$$$............###..........# #####$$$$........######........## ################################# The input generated for the next turn will be: 3 0 -1 0 ....... ....... ...H... ...O... .O..... ...O... $$..... -2 -2 1 #...... #....H. #....O. #..O... #....O. #$$$... ##$$$.. 0 -3 0 ...H... ...O... .O..... ...O... $$..... $$$.... #$$$$.. The above shows the properties of 3 ants for which the program must now produce orders. A possible order string for this situation would be “''SNW''”, moving the first ant down, the second up and the third to the left. ===== Remarks ===== * This is a creative task: You are not asked to find a perfect solution, but rather, you should design a creative strategy to prevail against your opponents. * The dimensions of the map will not exceed 500x500 tiles. * It is vitally important to flush the output stream when printing your orders! cout< ===== Testing Server ===== There is a testing server, on which you can let your ants play against other programs. You can do this on the [[server page]] by uploading your source code and selecting the map/teams from the drop down menu. Please note, that only C/C++ and Pascal are currently supported directly on the server. You are welcome to contact us if you would like to implement your strategy in another programming language of your choice.