sequenceDiagram
Client1->>Server: Submit Code
Client2->>Server: Submit Code
Note over Server: Run Match Simulation
Client1->>Server:Request DB
Server->>Client1:DB Request Response
Note over Client1: User selects Match To View
Client1->>Server:Request Match Record
Server->>Client1:Response to Record Request
Note over Client1: Match Visualization Displayed
Submit Code
- User ID
- Secret/Password
- Raw text code
{
"UserID":"John",
"Secret":"passw0rd",
"Code":""class SpaceShipController:\r def __init__(self, position, velocity, max_speed):\r self.position = position # Tuple (x, y) for current position\r self.velocity = velocity # Tuple (vx, vy) for current velocity\r self.max_speed = max_speed # Maximum speed of the spaceship\r\r def move(self, acceleration):\r \"\"\"Updates the spaceship's velocity and position based on acceleration.\"\"\"\r ax, ay = acceleration\r vx, vy = self.velocity\r new_vx = vx + ax\r new_vy = vy + ay\r\r # Ensure the velocity does not exceed max speed\r speed = (new_vx**2 + new_vy**2)**0.5\r if speed > self.max_speed:\r scale = self.max_speed / speed\r new_vx *= scale\r new_vy *= scale\r\r self.velocity = (new_vx, new_vy)\r self.position = (self.position[0] + new_vx, self.position[1] + new_vy)\r\r def shoot(self, target_position):\r \"\"\"Returns a trajectory vector to shoot at the target.\"\"\"\r tx, ty = target_position\r px, py = self.position\r trajectory = (tx - px, ty - py)\r return trajectory\r\r def status(self):\r \"\"\"Returns the current status of the spaceship.\"\"\"\r return {\r \"position\": self.position,\r \"velocity\": self.velocity\r }"
}
Response to DB Request
DB request is sent when the client wants a listing of matches which have been played
list of:
- Match Hash or something unique generated by backend
- Player1ID
- Player2ID
- Player1 Epoch of code upload
- Player1 Code hash
- Player2 Epock of code upload
- Player2 Code hash
- Winner (Bool)
- Length
{
"Matches": [
{
"User1ID": "John",
"User2ID": "Luca",
"User1Epoch": "1736318186",
"User1Hash": "744644e5311d752d0efd534316e5a84d",
"User2Epoch": "1736318199",
"User2Hash": "d8941cc78bf42a72da7c43de8bcbc186",
"Winner": "1", \\0 for tie
"MatchLength": "603" \\in simulation ticks
},
{
"User1ID": "Alice",
"User2ID": "Bob",
"User1Epoch": "1736318286",
"User1Hash": "3a71d5f33c85a9e93f5d9cf6a4b9142d",
"User2Epoch": "1736318299",
"User2Hash": "aa62f2f8d1e07f03e9b3c8de3aeb5cfa",
"Winner": "2",
"MatchLength": "755"
}
]
}
Response to request for match record
Match record request is sent from client to server when the client wants the full detail of a match in order to provide a visualization or more analysis to the user
In response to this request, the server should return some serialized object (maybe python pickle?) With the positions of all the things at each point in time. (yeah this is storage overhead but I calced each file will be around 40kb so whatever)