Skip to content

Commit

Permalink
bugfix: generation random track, no skip counting when generation fail
Browse files Browse the repository at this point in the history
  • Loading branch information
luigiberducci committed Mar 15, 2024
1 parent 77518a1 commit ac119ad
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions examples/random_trackgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ def main(args):
outdir.mkdir(parents=True, exist_ok=True)

for i in range(n_maps):
try:
print(f"[info] creating track {i}")
track, track_int, track_ext = create_track()
convert_track(track, track_int, track_ext, i, outdir)
print(f"[info] saved track {i} in {outdir}/")
except Exception as _: # noqa: F841
print("[error] failed to create track. Retrying...")
continue
print()
while True:
try:
print(f"[info] creating track {i}")
track, track_int, track_ext = create_track()
convert_track(track, track_int, track_ext, i, outdir)
print(f"[info] saved track {i} in {outdir}/")
break
except Exception as _: # noqa: F841
print("[error] failed to create track. Retrying...")
continue
print()


def create_track():
Expand Down Expand Up @@ -250,7 +252,7 @@ def convert_track(track, track_int, track_ext, track_id, outdir):
"--seed", type=int, default=123, help="The seed for the numpy rng"
)
parser.add_argument(
"--n_maps", type=int, default=3, help="Number of maps to create"
"--n-maps", type=int, default=3, help="Number of maps to create"
)
parser.add_argument(
"--outdir", type=pathlib.Path, default="./maps", help="Out directory"
Expand Down

0 comments on commit ac119ad

Please sign in to comment.