helpers.py 561 B

12345678910111213141516171819
  1. # Some helper functions
  2. def get_num_ships(od, place):
  3. place_state = design_to_state(od, place)
  4. return od.get_slot_value(place_state, "numShips")
  5. def design_to_state(od, design):
  6. incoming = od.get_incoming(design, "of")
  7. if len(incoming) == 1:
  8. # not all design-objects have a state
  9. return od.get_source(incoming[0])
  10. def state_to_design(od, state):
  11. return od.get_target(od.get_outgoing(state, "of")[0])
  12. def get_time(od):
  13. _, clock = od.get_all_instances("Clock")[0]
  14. return clock, od.get_slot_value(clock, "time")