microsoft / jericho

A learning environment for man-made Interactive Fiction games.
GNU General Public License v2.0
253 stars 42 forks source link

Few questions on using Jericho > 3.0.0 #57

Open ktr0921 opened 2 years ago

ktr0921 commented 2 years ago
  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 commented 2 years ago

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 https://github.com/microsoft/jericho/blob/8a31783edc1d4a0a484d1393d6d1cb4a71e6a8dd/jericho/jericho.py#L557 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 commented 2 years ago

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 commented 2 years ago

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.