Commit dfc7049e authored by Michaela Klauck's avatar Michaela Klauck

Jani generator and ASCII racetrack models

parent 32f7554e
usage: generator.py [-h] [--out OUT] [--horizon HORIZON] [--prob PROB] [--2d]
[--collision {dead,bonet,barto}]
[--noise {off,nochange,offbyone}] [--parking]
[--zero-velocity] [--storm-compatible]
[--start-point START_POINT]
[--individual-jani-for-each-start-point]
racetrack
Jani racetrack instance generator
positional arguments:
racetrack Racetrack instance file
optional arguments:
-h, --help show this help message and exit
--out OUT Output jani file
--horizon HORIZON If provided, a finite horizon model will be generated
--prob PROB Success probability of accelerating
--2d Represent map as 2D array.
--collision {dead,bonet,barto}
Which wall-hit variant to generate.
--noise {off,nochange,offbyone}
Which noise variant to generate.
--parking Requires the car to exactly hit the goal zone (i.e.,
not just passing through).
--zero-velocity Requires the car really park in goal zone (i.e.,
hitting goal zone + having there).
--storm-compatible Generate Storm compatible model.
--start-point START_POINT
Build model assuming single start point.
--individual-jani-for-each-start-point, --individual
Generate an individual Jani file for each start point.
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import re
if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("track")
p.add_argument("plan")
args = p.parse_args()
grid = []
pos_x = None
pos_y = None
with open(args.track) as f:
grid = [list(l.strip()) for l in f.readlines()[1:]]
for y in range(len(grid)):
for x in range(len(grid[y])):
if grid[y][x] == "s":
pos_x = x
pos_y = y
break
if pos_x != None:
break
accel_regex = re.compile("accel\d+_(-?\d+)_(-?\d+)")
accels = []
with open(args.plan) as f:
for l in f.readlines():
m = accel_regex.search(l)
if m != None:
accels.append((int(m.group(1)), int(m.group(2))))
velo_x = 0
velo_y = 0
grid[pos_y][pos_x] = "A" # str(0)
for step in range(len(accels)):
velo_x += accels[step][0]
velo_y += accels[step][1]
pos_x += velo_x
pos_y += velo_y
grid[pos_y][pos_x] = "A" # str(step + 1)
for y in range(len(grid)):
print("".join(grid[y]))
#print(", ".join(["(%d, %d)" % (
# sum([accels[j][0] for j in range(i)]),
# sum([accels[j][1] for j in range(i)]))
# for i in range(len(accels)+1)]))
dim: 33 30
xxxxxxxxxx.......xxxxxxxxxxxxx
xxxxxx..............xxxxxxxxxx
xx.....................xxxxxxx
xx........................xxxx
xx........................xxxx
xx........................xxxx
xx..........xx............xxxx
xx........xxxxx...........xxxx
xx.......xxxxxxx..........xxxx
xx......xxxxx............xxxxx
xx.....xxxx............xxxxxxx
xx.....xxxx..........xxxxxxxxx
x......xxxx........xxxxxxxxxxx
x......xxxx......xxxxxxxxxxxxx
x......xxxx.............xxxxxx
x......xxx...............xxxxx
x.....xxxx................xxxx
x.....xxxx.................xxx
x.....xxxx..................xx
x.....xxxxx..................x
x.....xxxxxx..................
x.....xxxxxxxxxxxxxxxx........
......xxxxxxxxxxxxxxxxx.......
......xxxxxxxxxxxxxxxxx.......
......xxxxxxxxxxxxxxxxx.......
......xxxxxxxxxxxxxxxxx.......
......xxxxxxxxxxxxxxxxx.......
......xxxxxxxxxxxxxxxxx.......
......xxxxxxxxxxxxxxxxx.......
......xxxxxxxxxxxxxxxxx.......
......xxxxxxxxxxxxxxxxx.......
......xxxxxxxxxxxxxxxxx.......
ssssssxxxxxxxxxxxxxxxxxggggggg
\ No newline at end of file
dim: 12 35
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxggg
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
s..................................
s..................................
s..................................
s..................................
xxxx...............................
xxxxxxxx...........................
xxxxxxxxxxxx.......................
\ No newline at end of file
dim: 45 50
xxxxxxxxxxxxxxxxxxxxx........xxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx..............xxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx..................xxxxxxxxxxxxxxxx
xxxxxxxxxxxxx........................xxxxxxxxxxxxx
xxxxxxxxxxx............................xxxxxxxxxxx
xxxxxxxxx............xxxxxxxx............xxxxxxxxx
xxxxxxxx..........xxxxxxxxxxxxxx..........xxxxxxxx
xxxxxxx.........xxxxxxxxxxxxxxxxxx.........xxxxxxx
xxxxxx........xxxxxxxxxxxxxxxxxxxxx.........xxxxxx
xxxxx........xxxxxxxxxxxxxxxxxxxxxxx.........xxxxx
xxxxx.......xxxxxxxxxxxxxxxxxxxxxxxxx........xxxxx
xxxx.......xxxxxxxxxxxxxxxxxxxxxxxxxxx........xxxx
xxxx......xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.......xxxx
xxx.......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.......xxx
xxx......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......xxx
xx......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......xx
xx......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......xx
x.......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.......x
x......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......x
x......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......x
......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......
s.....xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.....g
s.....xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.....g
s.....xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.....g
......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......
x......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......x
x......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......x
x.......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.......x
xx......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......xx
xx......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......xx
xxx......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx......xxx
xxx.......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.......xxx
xxxx......xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.......xxxx
xxxx.......xxxxxxxxxxxxxxxxxxxxxxxxxxx........xxxx
xxxxx.......xxxxxxxxxxxxxxxxxxxxxxxxx........xxxxx
xxxxx........xxxxxxxxxxxxxxxxxxxxxxx.........xxxxx
xxxxxx........xxxxxxxxxxxxxxxxxxxxx.........xxxxxx
xxxxxxx.........xxxxxxxxxxxxxxxxxx.........xxxxxxx
xxxxxxxx..........xxxxxxxxxxxxxx..........xxxxxxxx
xxxxxxxxx............xxxxxxxx............xxxxxxxxx
xxxxxxxxxxx............................xxxxxxxxxxx
xxxxxxxxxxxxx........................xxxxxxxxxxxxx
xxxxxxxxxxxxxxxx..................xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx..............xxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxx........xxxxxxxxxxxxxxxxxxxxx
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment