- return tuple(ltravel)
-
-def get_motions(motions):
- template = """ {{
- .words = {},
- }},
-"""
- mot_str = ""
- for motion in motions:
- contents = motion[1]
- if contents["words"] == None:
- mot_str += template.format("NULL")
- continue
- c_words = [make_c_string(s) for s in contents["words"]]
- words_str = "(const char* []) {" + ", ".join(c_words) + "}"
- mot_str += template.format(words_str)
- return mot_str
-
-def get_actions(actions):
- template = """ {{
- .words = {},
- .message = {},
- }},
-"""
- act_str = ""
- for action in actions:
- contents = action[1]
-
- if contents["words"] == None:
- words_str = "NULL"
- else:
- c_words = [make_c_string(s) for s in contents["words"]]
- words_str = "(const char* []) {" + ", ".join(c_words) + "}"
-
- if contents["message"] == None:
- message = "NO_MESSAGE"
- else:
- message = contents["message"]
-
- act_str += template.format(words_str, message)
- act_str = act_str[:-1] # trim trailing newline
- return act_str
-
-if __name__ == "__main__":
- with open(yaml_name, "r") as f:
- db = yaml.load(f)
-
- locnames = [x[0] for x in db["locations"]]
- msgnames = [el[0] for el in db["arbitrary_messages"]]
- objnames = [el[0] for el in db["objects"]]
-
- travel = buildtravel(db["locations"], db["objects"], db["vocabulary"])