Api¶
Seeding¶
-
class
compLib.Api.
Seeding
¶ Class used for communicating with seeding api
-
static
get_park
() → int¶ Get a parkingsapce from the api. :return: An int between 0 and 3
-
static
pay_park
() → bool¶ Pay for parking. :return: True if successful, False if not successful
-
static
simon_says
() → int¶ Get next simon says zone from the api. :return: An int between 0 and 3 or -1 after making this request 5 times.
-
static
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 :return: A Position object with x and y coordinates of the goal, rotation is always -1
-
static
get_items
() → list¶ Get a list with all current items :return: A list will all items currently on the game field. Items are dictionaries that look like: {“id”: 0}
-
static
get_opponent
() → compLib.Api.Position¶ Get position of the opponents robot :return: A Position object with opponents robot position
-
static
get_position
() → compLib.Api.Position¶ Get position of the robot :return: A Position object with robot position
-
static
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}")