-
Notifications
You must be signed in to change notification settings - Fork 42
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
[WIP] FIX: Incomplete objects tree for some games #54
base: master
Are you sure you want to change the base?
Conversation
@mhauskn this PR is really messed at the moment. I'm going to clean it up, but I wanted you to have an update on the fix. I now believe after this PR, we might want to do a major release (Jericho 4.0.0). Things to look at, changes in the Also, I would like you to try out the script that you used to validate world changed when playing the walkthroughs. |
d77f6b9
to
7032ea4
Compare
I'm getting the following error trying to install:
I think we used to use the md5.c file to provide standalone md5 hashing, without the need for other dependencies. Is the PR intending to include a md5.h file? |
My bad. I pushed the missing file. That will enable computing the md5 hash for a game state directly in C instead of having to get the state from Python, then call the hashing function from |
Hey Marc - I've done some small fixes around the get_cleaned_world_diff() - see them here: d59a6c3. The motivation for these changes is to have a consistent world_diff returned by jericho._get_world_diff() and jericho._filter_candidate_actions(). This change makes both return a 256-length tuple that is comparable. However, I'm detecting some issues with Zork1's walkthrough:
Both of these seem to be issues with world_state not changing when we expect it should. Here is the script I'm running to detect these issues: https://gist.github.com/mhauskn/861e4983f54a435013f66e9ab44ea308#file-test_walkthrough-py |
Oh, I should have mentioned I have yet to test the valid_action code. I was focusing on making sure the commands from the walkthroughs appropriately trigger Also, I was thinking of removing the whole world_diff, since now I keep a copy of the previous objects tree that is used to compare against the current objects tree. The valid_action code still needs to be changed to use that. For Zork1, I have yet to validate it. I'm currently doing
|
*n = 1; | ||
return seastalker_ram_addrs; | ||
*n = 5; | ||
return seastalker_special_ram_addrs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong variable was returned.
@@ -43,7 +49,7 @@ char* partyfoul_clean_observation(char* obs) { | |||
if (pch != NULL) { | |||
*(pch-2) = '\0'; | |||
} | |||
return obs+1; | |||
return obs + strspn(obs, "\n "); // Skip leading newlines and whitespaces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes a character was missing.
*n = 0; | ||
return NULL; | ||
*n = 1; | ||
return plundered_intro; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to press "Enter" to start the game.
// Winning messages change depending on the score. | ||
// *** Grunk bring pig back to farm *** // 6 out of 7 points. | ||
// *** Grunk bring pig back to farm and make new friend *** // 7 out of 7 points. | ||
char *victory_text = "*** Grunk bring pig back to farm "; // Works for both 6 and 7 points. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different winning messages depending on how many points we got.
@@ -50,7 +51,7 @@ char* deephome_clean_observation(char* obs) { | |||
} | |||
|
|||
int deephome_victory() { | |||
char *death_text = "**** You have won ****"; | |||
char *death_text = "*** You have won ***"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Death message had too many *
int i; | ||
char mask; | ||
mask = ~(1 << 7); | ||
// Clear attr 24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says attr 24, but above the attr_idx == 25 was used.
// return 550; | ||
// Due to a bug, the max score is 554 points instead of 550. | ||
// ref: https://raw.githubusercontent.com/heasm66/walkthroughs/main/curses_walkthrough.txt | ||
return 554; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the max score for curses
.
//char *death_text = "**** You have won ****"; | ||
char *death_text = "*** You have won... for now ***"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect winning message?
@@ -522,6 +522,7 @@ void dumb_init_output(void) | |||
{ | |||
if (h_version == V3) { | |||
h_config |= CONFIG_SPLITSCREEN; | |||
h_config |= CONFIG_NOSTATUSLINE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the option to disable status line for V3 games. This simplifies the clean_observation_...
functions.
@@ -1554,7 +1554,7 @@ void z_show_status (void) | |||
/* One V5 game (Wishbringer Solid Gold) contains this opcode by | |||
accident, so just return if the version number does not fit */ | |||
|
|||
if (h_version >= V4) | |||
if (h_version >= V4 || h_config & CONFIG_NOSTATUSLINE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip printing the status line when the corresponding option is set. This simplifies the clean_observation_...
functions.
@mhauskn I'm back working on it. I've done the initial validation for a few more games. Also, I've left a couple of comments (see above) to show some bug fixes I found. Those should probably go in a separate PR to be merged in the current version of Jericho (i.e., v3). |
edbb67d
to
ec936df
Compare
// Extract time from status line. E.g. | ||
// " Vestibule [...] Saturday 5:01:00 a.m. Score: 0" | ||
// ^ ^ | ||
// 88 117 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the time to the observation. I think it is crucial for Sherlock.z5
49cde86
to
0bd314d
Compare
Now detected correctly (see ab86cb5). |
@@ -1756,21 +2030,7 @@ int filter_candidate_actions(char *candidate_actions, char *valid_actions, zword | |||
act_newline = malloc(strlen(act) + 2); | |||
strcpy(act_newline, act); | |||
strcat(act_newline, "\n"); | |||
|
|||
// Step: Code is copied due to inexplicable segfault when calling step() directly; Ugh! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhauskn I figured out the segfault. There's a step
function in regexp.c
(see https://code.woboq.org/userspace/glibc/misc/regexp.c.html#50). It was clashing with the one in Jericho, so I renamed it.
Hey Marc wanted to touch base on this PR. Is it still in-progress or in a finished state? If the latter - I will be happy to run some checks on it. |
I finally have some time now to tidy it up. One thing that is still missing is to check whether no-op action (e.g., inventory, examine obj, look) doesn't change the state of the environment (e.g., thief is moving around). |
3119bc2
to
e44f7a7
Compare
I tested for false-positive world changes by attempting a combination of valid and invalid actions. Invalid actions included things like "z/wait/inventory/x me/navigating-into-a-dead-end" etc. Below are my findings: curses, ballyhoo, gold, hhgg, inhumane, lostpig, omniquest, pentari, planetfall, tryst205, zork3, ztuu - all actions are triggering world changed. huntdark - after going "left", all actions started triggering world changes (maybe there is a timer for bleeding out). Doesn't seem to happen if going "right". Also a handful of games are giving false-positive world changes the first time "inventory" command is issued, but not on subsequent invokations. |
This PR improves support for the games in Jericho.
Here are the main modifications/improvements of this PR.
Updating the objects count that was off from some games. Having the wrong number of objects leads to an incomplete object tree which is used to represent the game state, hence to track
world_changed
. Furthermore, this affects valid actions detection which uses the game state to know whether an action had any effect in the world.Instead of relying on
world_diff
,world_changed
now relies onRetPC
)victory() > 0
game_over() > 0
.Re-validating all the games to make sure that relevant commands from the walkthrough lead to a
world_changed
.(in progress) Re-validating all the games to make sure that "noop" commands (e.g.,
look
,inventory
,examine OBJ
) do not triggerworld_changed
.Bonus additions:
curses.z5
max score is actually 554 instead of 550 (due to a bug in the game, see commentcurses.c
)murdac.z5
will report 250/250 upon victory (even though the RAM says 249).Here's the current progress of re-validating the games: