So I understand that a player knows he’s won the game if he achieves the FINISHED state, but how do we know that our opponent has won? My initial thinking was checking if the opponent is on a block that has the FINISH_LINE attribute, but since our opponent could be far ahead we probably don’t have a state that contains that block.
You will not have a chance to check if the opponent won because everything will end in terms of rounds. The losing player does not get a chance to finish the match.
If you do need this data for some reason,
You can check the opponent’s x and add their current speed. If that exceeds 1500 they will probably cross the finish line in the next round. If that data is of any use to you.
Edit: Also, You can check if enemy x is bigger or equal to 1500 if you have some scenario where you continue your games. Dont think this gives away strategy in itself, and it technically answers the question.
What @WillieTheron has said is correct. The match will end if your opponent wins so you won’t have a chance to “check” if they won.
Thanks for this @KyleMc @WillieTheron , however I’m still kind of confused here. Engine cutting the game off completely means that a player could never be in the ‘FINISHED’ state (as the engine ends the program before that state is returned). It’s entirely possible for us to infer that the game is about to end by taking the player position + speed and seeing if that exceeds 1500, but there are some edge cases where that could be incorrect (a mud tile just before the end could potentially slow your opponent down enough that an extra round could be slipped in, or a boost could end the game before you expect). I would have liked to see the engine communicate the ending of the game to the bots. Is there any discussion around this or should I just make do?
Each round the game-runner does the following:
- Gives the bots the current round state files, and expect their commands in return
- The game-runner then processes those commands in the current round
- It checks if any player has won the match yet
- It generates new state files for the next round
So here step 4 will never happen when the opponent has already won. Thus the bots will never receive a state file confirming that the opponent has won/lost, since we do not call on the bots after a match winner has been determined.
This is simply because the game-runner does not expect any more commands from the bots (no command can make any difference when the match is already ended). It would seem like a useful feature, so that a bot could store in some memory about it’s win/loss ratio, but we do not allow bots to store memory between matches (bots are restarted for every match).
Thanks @pierre.roux , I guess my own strategy would have benefited from the game-runner just reporting the ‘FINISHED’ state to the bots before shutting down. Just as a comment I think maybe the documentation could be updated to report this subtle detail. I know I expected different behaviour as I expected a ‘FINISHED’ state to be communicated to my bot went it won.
You do not have a keep alive on your bot. Match starts, your bot starts, match ends, your bot gets killed.
All the match stats are logged.
If this is about “Training” your bot, You could update the test harness to behave differently (like write to a file if it finds a winner). I have done this before. Where I changed parts of the harness to better suit my own tests.
So locally you could still achieve what you want.
If you need to assess matches, we can download all our replay files during the tournament.
In the competition the bots do have certain restrictions, Like:
All written files gets reset for every match.
Cannot connect to the internet
Has a time limit on moves.
Basically any action that would be in bad spirit (like running your both through a cloud supercomputer) or writing diagnostics on opponent bots to see how they are trained. Or even training your bot against other bots in live tournament would probably be frowned upon.
This is how the harness works, Even if a Finished state is communicated, the bot would have no valid action after. If you write files, they will get wiped, if you trained your bot, it would likely get “reset” for the next round.
There’s just no scenario (I can think of) that would require the need to actually do anything once that loss has been set.
And again, if you need to do it locally you can patch the harness.
I mention all this because maybe it already answers against “Your Strategy”.