Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few questions on using Jericho > 3.0.0 #57

Open
ktr0921 opened this issue Dec 16, 2021 · 3 comments
Open

Few questions on using Jericho > 3.0.0 #57

ktr0921 opened this issue Dec 16, 2021 · 3 comments

Comments

@ktr0921
Copy link

ktr0921 commented Dec 16, 2021

  1. Is any word outside of get_world_objects() not interactable? For instance, from what i understood so far, get_dictionary() is to extract any ‘word’ recognizable in the game and get_world_objects() is to extract any ‘object’ interactable in the game. This means any ‘word’ in get_dictionary() that is not in get_world_objects() will not be interactable, so I can discard them when selecting objects?

  2. Is there any way to get template/object index for valid actions? get_valid_actions() is probably the closest thing, but it does not provide template or object index. Is there any way to extract this?

  3. If there is a way to extract template/object index for valid actions (2), what is the object index? Is it get_world_objects() or get_dictionary()?

  4. Finally, how should I interpret fields in jericho.ZObject? The example of it in the official document is ‘Obj4: cretin Parent180 Sibling181 Child0 Attributes [7, 9, 14, 30] Properties [18, 17, 7]’. Does Parent180 refer to Obj180? Does this apply to Sibling181 and Child0? How about Attributes and Properties? Where do I get the chart or dataset for this?

Thank you in advance

@mhauskn
Copy link
Contributor

mhauskn commented Dec 16, 2021

Is any word outside of get_world_objects() not interactable? For instance, from what i understood so far, get_dictionary() is to extract any ‘word’ recognizable in the game and get_world_objects() is to extract any ‘object’ interactable in the game. This means any ‘word’ in get_dictionary() that is not in get_world_objects() will not be interactable, so I can discard them when selecting objects?

get_dictionary() returns the list of words recognized by the game's parser, whereas get_world_objects() returns the list of world objects. Generally object's names correspond to the dictionary word used to refer to them, but not always. For example there may be an object with name "zmid" that must be referred to using the word "zorkmid". Also, there are some interactive things that are not present in the object tree and instead are only represented in the game's RAM (such as the turnstyle/ticket counter in Ballyhoo). Finally, the parser will typically contain multiple synonyms for each interactive object. Other than these exceptions, the rule you propose above should be sound.

Is there any way to get template/object index for valid actions? get_valid_actions() is probably the closest thing, but it does not provide template or object index. Is there any way to extract this?

Try replacing

candidate_actions = self.act_gen.generate_actions(best_obj_names)

with self.act_gen.generate_template_actions(best_obj_names). This should retain the template and object indexes for all of the valid actions.

If there is a way to extract template/object index for valid actions (2), what is the object index? Is it get_world_objects() or get_dictionary()?

It will index into the world object tree.

Finally, how should I interpret fields in jericho.ZObject? The example of it in the official document is ‘Obj4: cretin Parent180 Sibling181 Child0 Attributes [7, 9, 14, 30] Properties [18, 17, 7]’. Does Parent180 refer to Obj180? Does this apply to Sibling181 and Child0? How about Attributes and Properties? Where do I get the chart or dataset for this?

Yes parent180 refers to a parent object with object number 180. The attributes and properties keep track of the state of an object (e.g. a chest being open/closed) and are harder to interpret. @rajammanabrolu may be able to provide more insight into the meaning of different attributes/properties.

@MarcCote
Copy link
Collaborator

Let me chip in regarding the last point.

The meaning of attributes can differ from one game to another (esp. games made by Infocom vs. those made with Inform5/6/7). Also, currently in Jericho 3.0, the Properties returned by the Jericho framework only report the properties IDs currently used for an object but not its contents (e.g. alternative name(s) for an object, some counters/state_ids, or some description of the object).

The last thing to mention, for some of the games, some objects are missing in the ObjectTree. We are working on a fix here: #54

@davidjhall
Copy link

Just to add a bit to the last point too -- I've been diving deep into the z-machine specification recently.

When a high-level programming language compiles down to machine code, the variables are replaced and lost. You might have variables called counter, loop_duration, capture_flag in the code, but they are reduced down to something like r0, r1, and r2 in the machine code.

Attributes and properties in zil are likewise reduced to numbers. The best way to find them out is to go to the source code, if you have it, and derive it from there. In your example, it looks like it's zork1 which can be found here --- specifically in gglobals.zil where the attributes NDESCBIT INVISIBLE SACREDBIT ACTORBIT are set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants