Created
February 20, 2015 08:48
-
-
Save avian2/0635215fb6a664690444 to your computer and use it in GitHub Desktop.
Spectrum Wars proposed interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player: | |
"""Base class for the algorithm controlling a receiver and/or transmitter. | |
Users should derive their own classes from this one and override | |
methods as necessary. | |
class MyPlayer(Player): | |
... | |
The system creates two instances: one controlling the receiver and one | |
controlling the transmitter. It should also be able to have two | |
different classes for the two roles. | |
""" | |
def start(self): | |
"""Called by the system at the start of the game. | |
Users should override this method to perform any initialization | |
tasks required. | |
""" | |
pass | |
def status_update(self, spectrum, ack_num): | |
"""Called by the system periodically with updated information | |
about the state of the game. | |
spectrum - power vs. frequency data | |
ack_num - number of successfully transmitted packets between | |
the user's transmitter and receiver. | |
Users should override this method. | |
""" | |
pass | |
def reconfigure(self, frequency, power, bandwidth): | |
"""Called by the user to reconfigure the receiver or transmitter. | |
This is called, for example from the status_update() or | |
receive() methods. | |
""" | |
pass | |
def send(self, data): | |
"""Called by the user on the transmitter side to insert | |
arbitrary data into the packet stream. | |
(not used by the receiver) | |
""" | |
def receive(self, data): | |
"""Called by the system upon receipt of a packet that was sent | |
using send() method. | |
Packets that do not contain any data supplied by send() do not | |
invoke the receive() function. | |
(not used by the transmitter) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment