#Global Warmth king-of-the-hill
This KOTH takes place on a nicemelting iceberg of. You must stay on it as long as possible, and preferrably, be the last man standing.
The field is a perfectly circular surfaceiceberg which gradually shrinks at a unknown rate, in the center of a 2D plane. The goalGameplay is toexecuted in turns on which your program will be called with the last entry to fall offcurrent status of the iceberg and other participants. Each turn, participants can you may either movechange your movement direction or push someone near you (or neither).
Movement and positioning
Positioning is in a certain2D plane of floating point coordinates, and movement is a speed of x and y components. When issuing a move command, your entry will keep moving in that direction until you explicitly tell it to stop or change direction with another move command (or nonea push, more on this soon). The maximum move speed is 1.0 in magnitude, orand if they are near enoughyou ask to move further than that, your speed will be adjusted to conform this limit.
Pushing
Your program can issue push other participants. Each participant will start atcommands to any entity within a equal distanceradius of 1 from the centeryou, resulting in you and will have accessyour target having your speeds changed to point away from eachother and at a given speed. The push speed is directly adjustable, but the following data:
- Current iceberg radius
- Positions and speeds of the other entries
- Its own position and speed
##Detailsdirection isn't. Push speed is under the same limitations as a move command, and thus can't be stronger than 1.
- Since you're competing on ice, if you don't use your turn to move, you will move on the same direction you were last heading.
- If a competitor falls off the iceberg, it's not mentioned anymore in the entity list.
- All positions are relative to the center of the iceberg.
- A entry is considered to fall off the iceberg if its distance from the center is greater than the iceberg's radius.
- If the distance to any other participant is less than or equal to 1, you may push the participant, forcibly changing its direction of movement. The pushes will be applied after all the move commands, so you will not be penalized for being executed before your target. (The direction of the push is from your position to the target's, with a given force, and will affect you equally in opposite directions) It's important to note that the direction will be set, not simply influenced by the push.
- Entries do not have a physical radius, so they cannot bump on eachother.
- The rate at which the iceberg shrinks is unknown to you. It will depend on the participant's ability of staying clustered, and possibly other factors too. Don't try to calculate it.
- Your speed will be capped so it may never exceed 1 in any direction. (Think of a unit circle)
- The code will run on a Ubuntu 12.04 LTS virtual machine, with a measly 1GB of RAM.
##Execution
Input
TheEach round, your program will be executed once for each step ofinvoked from the gamecommand line, thus it may not share any variables with the previous instancea CSV document being passed to its STDIN. The first line of this document provides the current iceberg radius (floating point number) and the amount of remaining competitors (integer)
Your entry must be easily executable in the above mentioned configurationAfter this "header", any extra packages required mustthere will be listed in the answer. Your program must receive input from STDIN and return data to STDOUTone line for each remaining competitor in CSV format. The control program will output a list of numbers according to the following format (f_ = float,which is on its turn on the format i_type(variable) = integer):
f_icebergRadius, i_ent_count #The iceberg's current radius and the number ofstring(entity participants
i_ent_idid), f_ent_xfloat(x), f_ent_yfloat(y),float(velocity f_ent_speedxx), f_ent_speedy #REPEATS FOR EACH ENTITY float(total i_ent_countvelocity linesy)
Your entry iswill always be the first ofitem on the list.
Practical example of the
Example input passed:
112.0, 2 #Iceberg of radius 14, 2 participants
01af3b,10.022, 15.042, 0.0, 0.0 #Your data7
0.0d5e86, -12.018, 06.066, 0.6,-0 #Opponent data.2
\
(the \ is a trailing newline, represented like that for clarity)
Output
Your program will process the given input and output should either bea ASV (f_ = floatAnything Separated Values) document. A ASV is like a CSV, except everything that doesn't match the regex i_[.0-9a-z] = integer,is considered a separator s_ = string(even uppercase letters). If your program emits more than 1 line, only the last one is considered.
For movement:
move,float(velocity f_speedxx),float(velocity f_speedyy)
orFor pushing:
push,string(entity i_ent_idid), f_forcefloat(strength)
These names should be pretty self-explanatory, you can either modify your speed to a valueTo do nothing, or push a entity when near.simply don't output anyting
This format is flexible, you can use any character to separate each column, as long as it doesn't match the regexWhere [.0-9a-z]move and (Yes, uppercase letterspush are valid separators)string literals. It might even be a different separator
Example:
move,0.0,0.7
or
push,d5e86
The following lines are valid outputs for each field, as long as you avoid that regex.
The input passed to your STDIN will always be separated by a comma (,), with no surrounding whitespaceprogram:
moveA0.0A0.7
moveX0.0Y0.7
move!0.0:0.7
Detailed Rules and remarks
##ScoringA list of important points to consider:
- You can skip your turn by returning no output, but this will make you keep moving in the direction you ere headed to.
- If a competitor loses, it will not show up on the participants list (see below)
- A player is considered to fall from the iceberg if their distance from the center is greater than the iceberg's radius.
- Entries do not have a physical radius, so they cannot bump on eachother (except for the push command)
- You can't know the shrinking rate of the iceberg.
Scoring
Examples in pseudocode
What do you think? The controller code hasn't been written yet, asking for suggestions.
Is the input format ok? I find it a bit confusingAntisocial - pushes everyone away from him, but at least itdoesn't care about where he is easy to parse in languages with not so many text handling functions.
I'll create a controller/runner and upload it to a GitHub repository when it's finished.
#!/bin/env pseudocode
data = read_csv(stdin)
foreach line in data.range(1,data[0,1]):
if distance(me, line[1], line[2]) <= 1:
write_csv_line(stdout, ["push", line[0], 1.0])