-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper function to load the right Environment based on file exten…
…sion
- Loading branch information
Showing
2 changed files
with
17 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT license. | ||
import re | ||
|
||
from textworld.envs.glulx.git_glulx import GitGlulxEnv | ||
from textworld.envs.zmachine.jericho import JerichoEnv | ||
from textworld.envs.tw import TextWorldEnv | ||
from textworld.envs.wrappers.tw_inform7 import TWInform7 | ||
|
||
|
||
def _guess_backend(path): | ||
# Guess the backend from the extension. | ||
if path.endswith(".ulx"): | ||
return GitGlulxEnv | ||
elif re.search(r"\.z[1-8]", path): | ||
return JerichoEnv | ||
|
||
msg = "Unsupported game format: {}".format(path) | ||
raise ValueError(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters