-
Notifications
You must be signed in to change notification settings - Fork 113
Conversation
When using ANSI_DEFAULT, hilites[CLR_BLACK] was set as a NULL string. This caused black items to show up as gray. I sent a fix to upstream NetHack at NetHack/NetHack#556. Fixing that alone doesn't unbreak test_nethack.py::TestNethackTerminalObservation::test_crop (which broke whenever black items were in sight) since CLR_BLACK is 0, not 8 aka bright black (and also NO_COLOR, somewhat confusingly). We fix this by changing the output of mapglyph for glyphs that aren't the null glyph. Fixes #198.
if (glyph != nul_glyph && color == CLR_BLACK) { | ||
/* This will be 'bright black' (or blue) on tty so we change it to | ||
* make NLE's colors and tty_colors stay compatible. */ | ||
color = iflags.wc2_darkgray ? 8 : CLR_BLUE; |
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.
or CLR_BLUE
?!?
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 will read the termcap fix
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.
NetHack has a configuration option on whether it uses "bright black" (\033[1;30m
) or (dark) blue to display black entries: https://github.com/facebookresearch/nle/blob/master/win/tty/termcap.c#L887
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.
For clarity, here's a Python version of what this code here did before this change:
CLR_BLACK = 0
CLR_RED = 1
CLR_GREEN = 2
CLR_BROWN = 3 # /* on IBM, low-intensity yellow is brown */
CLR_BLUE = 4
CLR_MAGENTA = 5
CLR_CYAN = 6
CLR_GRAY = 7 # /* low-intensity white */
NO_COLOR = 8
CLR_ORANGE = 9
CLR_BRIGHT_GREEN = 10
CLR_YELLOW = 11
CLR_BRIGHT_BLUE = 12
CLR_BRIGHT_MAGENTA = 13
CLR_BRIGHT_CYAN = 14
CLR_WHITE = 15
CLR_MAX = 16
BRIGHT = 8
hilites = [None] * 16
hilites[CLR_GRAY] = ""
hilites[NO_COLOR] = hilites[CLR_GRAY]
for c in range(CLR_MAX // 2):
if c == CLR_BLACK:
continue
hilites[c | BRIGHT] = "\033[1;3%dm" % c
if c == CLR_GRAY:
continue
hilites[c] = "\033[0;3%dm" % c
print(hilites)
Handle black items correctly.
When using
ANSI_DEFAULT
,hilites[CLR_BLACK]
was set as aNULL
string. This caused black items to show up as gray. I sent a fix to upstream NetHack at NetHack/NetHack#556.Fixing that alone doesn't unbreak
test_nethack.py::TestNethackTerminalObservation::test_crop
(which broke whenever black items were in sight) sinceCLR_BLACK
is 0, not 8 aka bright black (and alsoNO_COLOR
, somewhat confusingly).We fix this by changing the output of
mapglyph
for glyphs that aren't the null glyph.Fixes #198.
Also fix
read_tty.py
(broken after #217) and simplify test_crop.