Api

Seeding

class compLib.Api.Seeding

Class used for communicating with seeding api

static get_park() → int

Get a parkingsapce from the api.

Returns

An int between 0 and 3

Return type

int

static pay_park() → bool

Pay for parking.

Returns

True if successful, False if not successful

Return type

bool

static simon_says() → int

Get next simon says zone from the api.

Returns

An int between 0 and 3 or -1 after making this request 5 times.

Return type

int

Double Elimination

class compLib.Api.DoubleElim

Class used for communicating with double elimination api

static get_goal()compLib.Api.Position

Get position of the goal

Returns

A Position object with x and y coordinates of the goal, rotation is always -1

Return type

Position

static get_items() → list

Get a list with all current items

Returns

A list will all items currently on the game field. Items are dictionaries that look like: {“id”: 0}

Return type

list

static get_opponent()compLib.Api.Position

Get position of the opponents robot

Returns

A Position object with opponents robot position

Return type

Position

static get_position()compLib.Api.Position

Get position of the robot

Returns

A Position object with robot position

Return type

Position

Position

class compLib.Api.Position(x, y, degrees)

Datastructure for holding a position

Examples

Calling Seeding API

from compLib.Api import Seeding

park = Seeding.get_park()
print(f"I should move to parking position: {park}")

if park == 0:
    print(f"I can't move to this position yet :(")
elif park == 1:
    print(f"Moving to position 1!")
    # drive to parking position using Motors module...
    print(f"Now hopefully at position 1")
    # drive back using Motors module...
elif park == 2:
    # do something similar to park == 1..
elif park == 3:
    # do something similar to park == 1..

success = Seeding.pay_park()
if success:
    print(f"We scored some points!")
else:
    print(f"We failed :(")

Calling Double Elimination API

from compLib.Api import DoubleElim

position = DoubleElim.get_position()
print(f"Position of my robot is: x={position.x}, y={position.y} and rotation is: {position.degrees}")

goal = DoubleElim.get_goal()
print(f"Goal is at: x={goal.x}, y={goal.y}")