Yes. You may read the opponent’s source code via the get_opponent_source(self) function.
from extra import get_opponent_source
class SpyBot():
def __init__(self, round=1):
self.round = round
def move(self, previous=None):
opponent_source = get_opponent_source(self) # return value is of class `str`
if '3' in opponent_source:
return 2
return 3
Beware the halting problem. Infinite recursion constitutes overuse of compute resources and may be grounds for disqualification.
Infinite recursion constitutes overuse of compute resources and may be grounds for disqualification.
Is this disqualification in advance, or in run-time? That is, do you just look at the code and decide whether it’s good, or do you give each program some bounded time and memory to run and disqualify it if any copy overflows it? (Btw another option would be, punish only that copy.)
Does this open a security hole of future prediction like Spectre etc?
Some bots could have a thing where they remember if they have met certain another bot (SignalBot) in the game. If they haven’t, they decide that the game setup carries certain preset information.
If the bots find out later in the game that the preset condition would be true, then they coordinate so that SignalBot causes infinite loop and gets disqualified and the game restarted. Now the game will miss SignalBot, causing the others to use this information to deduce the signalled information.
Tl;dr:
Givens: In some cases Left is best strategy. Otherwise Right is best strategy.
ForetellerBot observes SignalBot in the game, decides to play Right.
Bots observe Left is better strategy.
SignalBot nonhalts and gets thrown out, game is reset.
ForetellerBot observes no SignalBot in the game, decides to play Left.
OP said elsewhere in the comments (emphasis mine):
Your code is allowed to peek at the game engine for the purposes of figuring out if it is being simulated by someone else’s code. Peeking at the game engine for other reasons, like figuring out how many of each opponents remain or attempting to modify the game engine itself or attempting to modify your opponents’ code from anywhere outside their own simulation of you is against the rules.
And in the original post:
You may save whatever information you want into the class instance’s fields but you may not save information between rounds or between class instantiations.
You are not peeking at the game engine, you can just message this the same as you can message cooperation (2, 0, 2 code etc).
You also do not need to save any information over instances—all of your bots on a round are running on the same instance. If any of your ForetellerBots observes SignalBot, then SignalBot has not dropped. SignalBot’s existence is in itself the flag.
Each pairing is independent of every other pairing. [You do know what round of the game it is and that you are facing an opponent. If you face a copy of yourself you are automatically awarded the maximum 5 points per round (2.5 points per bot). You otherwise do not know any history of the game to this point.
A separate instance of each bot is created for each pairing in each round. All that ForetellerBot knows in any pairing is whether it is itself facing a SignalBot, not whether any of its copies are.
Yes. You may read the opponent’s source code via the
get_opponent_source(self)
function.Beware the halting problem. Infinite recursion constitutes overuse of compute resources and may be grounds for disqualification.
Is this disqualification in advance, or in run-time? That is, do you just look at the code and decide whether it’s good, or do you give each program some bounded time and memory to run and disqualify it if any copy overflows it? (Btw another option would be, punish only that copy.)
Run-time. I disqualify the entire program—not just the one copy—and then restart the game with one (or fewer) competitors.
Does this open a security hole of future prediction like Spectre etc?
Some bots could have a thing where they remember if they have met certain another bot (SignalBot) in the game. If they haven’t, they decide that the game setup carries certain preset information.
If the bots find out later in the game that the preset condition would be true, then they coordinate so that SignalBot causes infinite loop and gets disqualified and the game restarted. Now the game will miss SignalBot, causing the others to use this information to deduce the signalled information.
Tl;dr:
Givens: In some cases Left is best strategy. Otherwise Right is best strategy.
ForetellerBot observes SignalBot in the game, decides to play Right.
Bots observe Left is better strategy.
SignalBot nonhalts and gets thrown out, game is reset.
ForetellerBot observes no SignalBot in the game, decides to play Left.
OP said elsewhere in the comments (emphasis mine):
And in the original post:
You are not peeking at the game engine, you can just message this the same as you can message cooperation (2, 0, 2 code etc).
You also do not need to save any information over instances—all of your bots on a round are running on the same instance. If any of your ForetellerBots observes SignalBot, then SignalBot has not dropped. SignalBot’s existence is in itself the flag.
A separate instance of each bot is created for each pairing in each round. All that ForetellerBot knows in any pairing is whether it is itself facing a SignalBot, not whether any of its copies are.
Thanks for the info. This conflicts with the specification of
which I interpreted to mean that there exists exactly 1 instance of the class per round.
The model you propose makes sense though, I guess my mental model of the thing was mistaken.
Why does get_opponent_source take self as an argument?
There are two active bots. The
self
argument tells the game client which bot’s code not to return.Thanks.