diff --git a/_sources/lib/Api.rst.txt b/_sources/lib/Api.rst.txt index 18605ae..59ad2d6 100644 --- a/_sources/lib/Api.rst.txt +++ b/_sources/lib/Api.rst.txt @@ -32,31 +32,31 @@ Calling Seeding API from compLib.Api import Seeding - park, code = Seeding.get_park() + zones, code = Seeding.get_delivery() if code == 403: print(f"I am not in the correct zone to make that request!") else: - park = park["id"] - print(f"I should move to parking position: {park}") + print(f"First we need to go to zone {zone[0]}") + # put code here to follow line and drive to the zone + print(f"Now we need to go to zone {zone[1]}") + # put code here to follow line and drive to the next zone + print(f"Now we need to go to zone {zone[2]}") + # put code here to follow line and drive to the last zone + print(f"We delivered all packages, hopefully we scored some points!") - 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.. +.. code-block:: python - success = Seeding.pay_park() - # check which code the api returned - if success == 204: - print(f"We scored some points!") - else: - print(f"We failed :(") + from compLib.Api import Seeding + + package, code = Seeding.get_cargo("yellow") + if code == 403: + print(f"I am not in the correct zone to make that request!") + elif code == 404: + print(f"I am in the correct zone, but there is no yellow package here.") + elif code == 413: + print(f"I am in the correct zone, but I already have two packages loaded.") + else code == 200: + print(f"The {package['color']} has been picked up!") Calling Double Elimination API ---------------------------------- @@ -70,3 +70,38 @@ Calling Double Elimination API goal, status = DoubleElim.get_goal() print(f"Goal is at: x={goal.x}, y={goal.y}, the server responded with status code: {status}") + +.. code-block:: python + + from compLib.Api import DoubleElim + import time + + # function which waits for the game to be started (you should include this in your double elimination program) + def wait_for_start(): + _, status = DoubleElim.get_position() + while status == 503: + time.sleep(0.1) + _, status = DoubleElim.get_position() + + wait_for_start() + print(f"Game has started, lets score some points!!") + + position, status = DoubleElim.get_position() + print(f"Position of my robot is: x={position.x}, y={position.y} and rotation is: {position.degrees}, the server responded with status code: {status}") + + opponent_position, status = DoubleElim.get_opponent() + print(f"Position of the opponents robot is: x={opponent_position.x}, y={opponent_position.y} and rotation is: {opponent_position.degrees}, the server responded with status code: {status}") + + goal, status = DoubleElim.get_goal() + print(f"Goal is at: x={goal.x}, y={goal.y}, the server responded with status code: {status}") + + items, status = DoubleElim.get_items() + print(f"There are currently {len(items)} on the gameboard: {items}, the server responded with status code: {status}") + + score, status = DoubleElim.get_score() + print(f"The current score of the game is {score}, the server responded with status code: {status}") + + meteoroids, status = DoubleElim.get_meteoroid() + print(f"The current meteoroids in the game are {meteoroids}, the server responded with status code: {status}") + +In this second example we wait until the game is started by the judges and then make all possible requests once. You should use the wait_for_start function in your double elimination program. If your robot starts too soon your run will not count! diff --git a/_static/documentation_options.js b/_static/documentation_options.js index dbef29e..4c199ec 100644 --- a/_static/documentation_options.js +++ b/_static/documentation_options.js @@ -1,6 +1,6 @@ var DOCUMENTATION_OPTIONS = { URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), - VERSION: '0.0.2', + VERSION: '0.2.3', LANGUAGE: 'None', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/genindex.html b/genindex.html index 6762521..e5bf9ef 100644 --- a/genindex.html +++ b/genindex.html @@ -3,7 +3,7 @@ - Index — CompLib 0.0.2 documentation + Index — CompLib 0.2.3 documentation