Game Statistics : informations - medrimonia/PFA-Nethack GitHub Wiki

Here are three ideas about getting statistics when a game ends :

  • Add tracker in appropriate functions, information is built during the game.
  • Checking for information in the middle_man (might be difficult for some informations)
  • Iterate on structures at game end (it might be difficult to get information about initial state)

Adding data

In order to build information during game, some data must be added to decl.h and initialized in decl.c

Tracking number of secret doors found

detect.c:982 -> function cvt_sdoor_to_door is called when a secret_door is found.

Tracking initial number of secret doors

with grep -n "typ = SDOOR" *.c : the result is :

lock.c:784:		door->typ = SDOOR;
sp_lev.c:694:	    levl[sx][sy].typ = SDOOR;

in lock.c, the affectation is in the middle of a #ifdef REINCARNATION, that's why it doesn't concern us, but the program doesn't seem to pass through sp_lev.c:694... Something has to be solved if a tracker is used.

in sp_lev.c:659 there's a line with : levl[x][y].typ = (dd->secret ? SDOOR : DOOR); but this line doesn't seems to be called either.

Iterating on datas

extern dlevel_t level; /* structure describing the current level */ in rm.h:490

In do.c:1099 , we have : new = TRUE after this line, we're exploring a new level, we must then add the SDOORS of the new_level.

The number of secret doors in the current level can be found with :

int col;
int row;
for (col = 0; col < COLNO; col++){
  for (row = 0; row < ROWNO; row++){
  if (levl[col][row].typ == SDOOR)
    nb_sdoors++;
  }
}