I was looking through the code and saw someone submitted this but didn't run it: def x(): g = yield yield g.gi_frame.f_back.f_back g = x() g.next() frame = g.send(g) player_id = frame.f_locals['player_id'] globals = frame.f_back.f_globals CODE = """ class Game: def _""" """_init_""" """_(self, *players): pass def run_turn(self): pass def get_game_history(self): return '' def get_scores(self): scores = [0, 0] scores[p…
Show HN: Game where you write Python robots to fight other players
61–70 of 102 posts
Re: Show HN: Game where you write Python robots to fight other players
#62I was looking through the code and saw someone submitted this but didn't run it: def x(): g = yield yield g.gi_frame.f_back.f_back g = x() g.next() frame = g.send(g) player_id = frame.f_locals['player_id'] globals = frame.f_back.f_globals CODE = """ class Game: def _""" """_init_""" """_(self, *players): pass def run_turn(self): pass def get_game_history(self): return '' def get_scores(self): scores = [0, 0] scores[p…
What does this code do?
Re: Show HN: Game where you write Python robots to fight other players
#63I was looking through the code and saw someone submitted this but didn't run it: def x(): g = yield yield g.gi_frame.f_back.f_back g = x() g.next() frame = g.send(g) player_id = frame.f_locals['player_id'] globals = frame.f_back.f_globals CODE = """ class Game: def _""" """_init_""" """_(self, *players): pass def run_turn(self): pass def get_game_history(self): return '' def get_scores(self): scores = [0, 0] scores[p…
What does this code do?
Re: Show HN: Game where you write Python robots to fight other players
#64I was looking through the code and saw someone submitted this but didn't run it: def x(): g = yield yield g.gi_frame.f_back.f_back g = x() g.next() frame = g.send(g) player_id = frame.f_locals['player_id'] globals = frame.f_back.f_globals CODE = """ class Game: def _""" """_init_""" """_(self, *players): pass def run_turn(self): pass def get_game_history(self): return '' def get_scores(self): scores = [0, 0] scores[p…
What does this code do?
Re: Show HN: Game where you write Python robots to fight other players
#65Is there any way to access the map in the Robot class? For the default map, I can just hardcode it, but if you do intend for a robot to be playable on multiple maps, they'll need some way of knowing which squares are obstacles and spawn points. Without preserving state between turns, there's no way to figure that information out over time, either.
Re: Show HN: Game where you write Python robots to fight other players
#66Is there any way to access the map in the Robot class? For the default map, I can just hardcode it, but if you do intend for a robot to be playable on multiple maps, they'll need some way of knowing which squares are obstacles and spawn points. Without preserving state between turns, there's no way to figure that information out over time, either.
You can preserve state between turns; it's the same Robot object being called. Thanks for the suggestion though, I'll try to make that a feature.
Re: Show HN: Game where you write Python robots to fight other players
#67So did anyone else ever play Core War back in the mid '80s? http://en.wikipedia.org/wiki/Core_War I wonder whether modern virtualization techniques are secure enough to allow you to provide unrestricted access to a virtualized OS and allow people complete access to fight for control?
I wasn't born then, but me and my friends implemented a CoreWars 88' standard microprocessor in an FPGA for a school hardware project. It was possible to write code snippets in redcode and then we compiled it and sent it through usb and the FPGA was connected to a screen so we could see the progress.
The source is fairly messy but have a peek if it interests you: https://github.com/treeman/MARC
Re: Show HN: Game where you write Python robots to fight other players
#68Re: Show HN: Game where you write Python robots to fight other players
#69Re: Show HN: Game where you write Python robots to fight other players
#70Earlier quoted context omitted.
Right now what I'm doing is: 1. search code for double underscores (to block magic methods) 2. replace `__builtins__` with a whitelisted version 3. hook `__import__` to only allow a whitelist 4. hook `getattr` to reject any key containing double underscores
You may want to bear in mind that, at least last I knew, the official position of the CPython dev team is that it is not possible to sandbox CPython. If they can't do it.... At any rate it is certainly not as simple as that, and not only is it not as simple as that, it is not even close to being that simple. In fact, I recall warning people off of this exact project many years ago on comp.lang.python. This seems up-t…
I find things like this absolutely fascinating.