Exemple #1
0
def eq_gridworld_test():
    empty = gw.GridWorld()
    trivial_nonempty = gw.GridWorld(TRIVIAL_GWFILE)
    trivial_diff = gw.GridWorld(TRIVIAL_GWFILE)
    if trivial_diff.is_empty((0, 0)):
        trivial_diff.mark_occupied((0, 0))
    else:
        trivial_diff.mark_empty((0, 0))
    trivial_nonempty_2goals = gw.GridWorld(TRIVIAL_GWFILE)
    trivial_nonempty_2goals.goal_list = [(0, 0), (1, 1)]
    trivial_nonempty_2init = gw.GridWorld(TRIVIAL_GWFILE)
    trivial_nonempty_2init.init_list = [(0, 0), (1, 1)]
    for (G, H,
         is_equal) in [(gw.GridWorld(), gw.GridWorld(), True),
                       (empty, trivial_nonempty, False),
                       (trivial_nonempty_2goals, trivial_nonempty, False),
                       (trivial_nonempty_2init, trivial_nonempty, False),
                       (trivial_nonempty, trivial_diff, False),
                       (gw.unoccupied((3, 5)), gw.unoccupied((1, 1)), False)]:
        yield eq_gridworld_check, G, H, is_equal
Exemple #2
0
 def setUp(self):
     self.prefix = "testworld"
     self.X = gw.GridWorld(REFERENCE_GWFILE, prefix=self.prefix)
     self.Y_testpaths = gw.GridWorld(UNREACHABLE_GOAL_GWFILE,
                                     prefix=self.prefix)
Exemple #3
0
 def test_equality(self):
     assert self.X == gw.GridWorld(REFERENCE_GWFILE)
     Y = gw.GridWorld()
     assert self.X != Y
     Y = gw.GridWorld(TRIVIAL_GWFILE)
     assert self.X != Y
Exemple #4
0
 def test_dumploadloop(self):
     assert self.X == gw.GridWorld(self.X.dumps())
Exemple #5
0
from __future__ import print_function

import sys
import tulip.gridworld as gw
from tulip import synth

# import specified gridworld from textfile - singlelane.txt
with open("singlelane.txt", "r") as f:
    lane = gw.GridWorld(f.read(), prefix="Y")
print(lane)

# adding environment - traffic light is red or not red
env_vars = {'red'}
env_init = set()                # empty set
env_prog = '!red'
env_safe = set()                # empty set
#lane[0,0] = 'init'
#lane[0,5] = 'goal'
lane.atomic_propositions.add_from({'signal', 'goal'})
#lane.states.add(lane[0,0], ap={'init'})
lane.states.add(lane[0,2], ap={'signal'})
lane.states.add(lane[0,5], ap={'goal'})

# specs
sys_vars = set()#'X0reach'}          # infer the rest from TS
sys_init = set()#{'X0reach'}
sys_prog = {'goal'}             # []<>Goal
sys_safe = {'((signal && red)->X(signal)) && (goal -> X(goal))'}
#sys_prog |= {'X0reach'}
# @specs_setup_section_end@