Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Eric/add converter #315

Merged
merged 11 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "third_party/pybind11"]
path = third_party/pybind11
url = https://github.com/pybind/pybind11.git
[submodule "third_party/libtmt"]
path = third_party/libtmt
url = https://github.com/deadpixi/libtmt.git
35 changes: 31 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ file(
"sys/unix/unixmain.c"
"sys/unix/unixres.c"
"win/tty/*.c"
"win/rl/winrl.cc"
"third_party/libtmt/tmt.c")
"win/rl/winrl.cc")

# terminal emulator library
add_library(tmt STATIC "third_party/libtmt/tmt.c")
set_target_properties(tmt PROPERTIES C_STANDARD 11)

# libnethack library
add_library(nethack SHARED ${NETHACK_SRC})
Expand All @@ -117,7 +120,7 @@ target_link_directories(nethack PUBLIC /usr/local/lib)
# Careful with -DMONITOR_HEAP: Ironically, it fails to fclose FILE* heaplog.
# target_compile_definitions(nethack PUBLIC "$<$<CONFIG:DEBUG>:MONITOR_HEAP>")

target_link_libraries(nethack PUBLIC m fcontext bz2)
target_link_libraries(nethack PUBLIC m fcontext bz2 tmt)

# dlopen wrapper library
add_library(nethackdl STATIC "sys/unix/nledl.c")
Expand All @@ -131,7 +134,7 @@ target_link_libraries(rlmain PUBLIC nethackdl)
target_include_directories(rlmain PUBLIC ${NLE_INC_GEN})
add_dependencies(rlmain util) # For pm.h.

# pybind11 python library.
# pybind11 core python library.
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/pybind11)
pybind11_add_module(
_pynethack
Expand All @@ -145,3 +148,27 @@ target_link_libraries(_pynethack PUBLIC nethackdl)
set_target_properties(_pynethack PROPERTIES CXX_STANDARD 14)
target_include_directories(_pynethack PUBLIC ${NLE_INC_GEN})
add_dependencies(_pynethack util) # For pm.h.

# ttyrec converter library
add_library(
converter STATIC ${CMAKE_CURRENT_SOURCE_DIR}/third_party/converter/converter.c
${CMAKE_CURRENT_SOURCE_DIR}/third_party/converter/stripgfx.c)
target_include_directories(
converter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/third_party/libtmt
${CMAKE_CURRENT_SOURCE_DIR}/third_party/converter)
target_link_libraries(converter PUBLIC bz2 tmt)
if(CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_options(converter PRIVATE -Wall -Wextra -pedantic -Werror)
endif()

# ttyrec reader executable
add_executable(ttyrec_reader EXCLUDE_FROM_ALL "third_party/converter/reader.c")
target_link_libraries(ttyrec_reader PUBLIC converter)
target_include_directories(
ttyrec_reader PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/third_party/converter)

pybind11_add_module(_pyconverter third_party/converter/pyconverter.cc)
target_link_libraries(_pyconverter PUBLIC converter)
set_target_properties(_pyconverter PROPERTIES CXX_STANDARD 14)
target_include_directories(
_pyconverter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/third_party/converter)
1 change: 1 addition & 0 deletions nle/dataset/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from nle._pyconverter import Converter
24 changes: 24 additions & 0 deletions nle/tests/2009-02-05.10_33_51.frame.10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@














----+---
|......|
|....$.|
|......|
|...@..+
|......|
--------

Qvazzler the Evoker St:9 Dx:15 Co:14 In:18 Wi:9 Ch:10 Neutral S:0
Dlvl:1 $:0 HP:12(12) Pw:6(6) AC:9 Xp:1/0 T:1
Binary file added nle/tests/2009-02-05.10_33_51.ttyrec.bz2
Binary file not shown.
Binary file added nle/tests/2018-09-27.00_20_39.ttyrec.bz2
Binary file not shown.
24 changes: 24 additions & 0 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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0,0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
7,23,23,23,23,23,23,23,23,16,23,23,23,16,23,23,23,23,23,23,23,23,23,23,23,23,23,16,16,16,16,7,0,7,7,7,7,7,7,7,7,0,7,7,7,7,7,0,7,7,7,7,7,0,7,7,7,7,0,7,7,7,7,7,0,7,7,7,7,0,7,7,7,7,7,7,0,0,0,0
7,7,7,7,7,7,7,0,7,7,7,7,7,0,7,7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,0,7,7,7,7,7,0,7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
24 changes: 24 additions & 0 deletions nle/tests/2020-10-03.17_27_10.finalframe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@


------+-- ---+-- --+--
|.......| ----- |....| -------- |...|
|.......+# #|..{| |....|#######.......| |...|
|.......|#####.^..| |....-##### |......| |...|
|.......-#####|...|# --.-.-# ## |....>..# |..||
|.......| |...-## ##### --------%# #&...|
-.----.- -----# # # ###|@=.|
###################%## ## ### # ---.-
# # ###############)##%#########0# # ##
# # # #--.--- # #
# # #|....|##### ##
# # #-....-# --+-------
-------.---- ## |...{|# ###.(.......|
|..........| # -----#### |..^%..{.|
|..........| # --------------.- ################# ...<.....|
|..........| # |..............| #### ----------
|.....m....| # |...%...........##
------------ ##...............|
----------------

[Anarchos the Woman-at-arms ] St:18/04 Dx:12 Co:18 In:8 Wi:13 Ch:8 Lawful
Dlvl:22 $:272 HP:91(91) Pw:19(19) AC:-10 Xp:11 T:16956 Burdened
Loading