Skip to content
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

Add Gymnasium client #18

Merged
merged 47 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
26f0d23
Rm Android & Docker & windows CI tests
siboehm Jan 17, 2024
be27afd
Add headless mode
siboehm Jan 17, 2024
3c9ac52
Add remote client
siboehm Jan 17, 2024
09b99aa
Add Python minetest client
siboehm Jan 17, 2024
1e8d03a
rm obsolete SDL_Target cmake settings
siboehm Jan 18, 2024
d9a9b44
Docs: Add instr for faster build using Ninja & mold
siboehm Jan 18, 2024
cfe0958
Rm commented out code in Cmake
siboehm Jan 18, 2024
13b3d01
Fix macos test failure by installing devtest game
siboehm Jan 18, 2024
9218ddb
re-add delete line in renderingengine
siboehm Jan 19, 2024
b18fb18
simplify pytest setup on macos
siboehm Jan 19, 2024
a0ac991
Minor changes to minetest gym env
siboehm Jan 19, 2024
ecd7e47
Clean up Python helper scripts
siboehm Jan 19, 2024
0d76a01
Linux CI: Pytest doesn't need gdb
siboehm Jan 19, 2024
bdfb2d3
ruff formatting
siboehm Jan 19, 2024
ec16498
minor comments
siboehm Jan 19, 2024
5686a52
Minor refactorings in remote input handling
siboehm Jan 19, 2024
441bc23
comment change in minetest.conf.example
garymm Jan 24, 2024
1cb167a
always enable capnproto
garymm Jan 24, 2024
8b7dfa7
Include local python code in conda environment
garymm Jan 30, 2024
eafe572
add devcontainer
garymm Jan 30, 2024
a5a49f5
specify gym environment version
garymm Jan 30, 2024
4020a3a
python VS Code settings
garymm Jan 30, 2024
95ef2c5
check if mintest process is alive after handshake
garymm Jan 30, 2024
1ac7db9
test world mod: heed minetest deprecation warning
garymm Jan 30, 2024
7614ef3
make pytest fail properly
garymm Jan 30, 2024
5526ad7
fix bug in reward parsing
garymm Jan 30, 2024
1f8bfae
Get rid of deserializeAction
garymm Jan 31, 2024
ee799ae
remoteinputhandler: includes
garymm Jan 31, 2024
48e7d2a
doc: improve some build instructions
garymm Jan 31, 2024
81fbf35
remoteinputhandler: RM unused members
garymm Feb 1, 2024
4624f71
eliminate warnings shown by pytest
garymm Jan 31, 2024
7c22a47
launch config to debug multiplayer client
garymm Feb 1, 2024
4fd2947
only init offscreen video driver if headless
garymm Feb 1, 2024
8b1ddce
RM XVFB
garymm Feb 1, 2024
524bc3e
gym: properly disable sound
garymm Feb 2, 2024
4fe0eb5
clean up handshaker and add launch config for it
garymm Feb 2, 2024
d18eec2
move python tools into python/tools
garymm Feb 2, 2024
ada76bb
devcontainer: add ruff, run container priveleged
garymm Feb 2, 2024
7f90675
vscode: format python and jsonc on save
garymm Feb 2, 2024
becd62b
improve setup instructions
garymm Feb 2, 2024
02071a6
gym: support connecting to running minetest
garymm Feb 3, 2024
21e9ea6
gym test: close env on test failure. dump images
garymm Feb 6, 2024
e4abb75
devcontainer: disable priveleged mode
garymm Feb 6, 2024
bfe6332
suppress pygame log spam
garymm Feb 8, 2024
c3b69f7
gym: hide observations while engine loading
garymm Feb 8, 2024
e5e7a31
headless: minor naming and RAII
garymm Feb 8, 2024
bbbe3f4
apt-get -> conda
garymm Feb 8, 2024
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
56 changes: 0 additions & 56 deletions .github/workflows/android.yml

This file was deleted.

46 changes: 36 additions & 10 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,42 @@ jobs:
run: |
./util/test_multiplayer.sh

pytest:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps clang-14 gdb

- name: Build
run: |
./util/ci/build.sh
env:
CC: clang-14
CXX: clang++-14

- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
mamba-version: "*"
channels: conda-forge,nodefaults
activate-environment: minetest
environment-file: environment.yml

- name: Setup Minetest env
shell: bash -x -l {0}
run: |
pushd python && pip install -e . && popd

- name: Run pytest
shell: bash -l {0}
run: |
set -euo pipefail
timeout 5m pytest -v || find artifacts/log -type f -name '*.log' -exec cat {} \;


# Build with prometheus-cpp (server-only)
clang_9_prometheus:
name: "clang_9 (PROMETHEUS=1)"
Expand All @@ -151,13 +187,3 @@ jobs:
- name: Test
run: |
./bin/minetestserver --run-unittests

docker:
name: "Docker image"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Build docker image
run: |
docker build . -t minetest:latest
docker run --rm minetest:latest /usr/local/bin/minetestserver --version
21 changes: 11 additions & 10 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@ jobs:

- name: Build
run: |
git clone https://github.com/minetest/irrlicht lib/irrlichtmt --depth 1 -b $(cat misc/irrlichtmt_tag.txt)
mkdir build
cd build
cmake .. \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \
cmake -B build -S . \
-DCMAKE_FIND_FRAMEWORK=LAST \
-DCMAKE_INSTALL_PREFIX=../build/macos/ \
-DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE \
-DINSTALL_DEVTEST=TRUE
cmake --build . -j$(sysctl -n hw.logicalcpu)
make install
-DCMAKE_INSTALL_PREFIX=build/macos/ \
-DRUN_IN_PLACE=FALSE \
-DENABLE_GETTEXT=TRUE \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_HEADLESS=FALSE \
-GNinja \
-DSDL2_DIR= \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
cmake --build build
cmake --install build

- name: Test
run: |
Expand Down
147 changes: 0 additions & 147 deletions .github/workflows/windows.yml

This file was deleted.

7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ gtags.files
.idea
# Codelite
*.project
# Visual Studio Code & plugins
.vscode/
build/.cmake/
# Fleet
.fleet
Expand Down Expand Up @@ -66,6 +64,7 @@ AppDir
/client/mod_storage/

## Configuration/log files
artifacts/
minetest.conf
debug.txt
debug.txt.1
Expand Down Expand Up @@ -126,3 +125,7 @@ lib/irrlichtmt

# Generated mod storage database
client/mod_storage.sqlite

# Python
*.egg-info
*.pyc
13 changes: 13 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[submodule "lib/zmqpp"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one also seems better to use CMake since we don't expect to modify it

path = lib/zmqpp
url = https://github.com/zeromq/zmqpp.git
[submodule "games/minetest_game"]
path = games/minetest_game
url = https://github.com/minetest/minetest_game.git
[submodule "lib/SDL"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use CMake to fetch these instead?
An example from a CMakeLists.txt file I wrote for something else:

include(FetchContent)
FetchContent_Declare(
  ut
  GIT_REPOSITORY https://github.com/boost-ext/ut
  GIT_TAG        20f2c3f811e25b8c398c6e98545dbf07d72eb4e8
)
FetchContent_MakeAvailable(ut)

I don't have a lot experience with it but it seems maybe better if we don't expect users to edit the source of these at all. I guess at least for SDL we don't expect to edit it at all. irrlictmt maybe we will need to edit it?
Thoughts?

path = lib/SDL
url = https://github.com/libsdl-org/SDL.git
[submodule "lib/irrlichtmt"]
path = lib/irrlichtmt
url = https://github.com/Astera-org/irrlicht
branch = headless
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types: [python]
exclude: '^util/'
- id: ruff-format
types: [python]
exclude: '^util/'
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"greenxenith.minetest-tools"
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": false
}
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ endif()

# Configuration options
set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
set(BUILD_HEADLESS TRUE CACHE BOOL "Build in headless mode")
set(BUILD_SERVER FALSE CACHE BOOL "Build server")
set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")
set(BUILD_BENCHMARKS FALSE CACHE BOOL "Build benchmarks")
Expand Down Expand Up @@ -303,6 +304,8 @@ endif()
find_package(GMP REQUIRED)
find_package(Json REQUIRED)
find_package(Lua REQUIRED)
find_package(Zmq REQUIRED)
find_package(Zmqpp REQUIRED)
if(NOT USE_LUAJIT)
add_subdirectory(lib/bitop)
endif()
Expand Down
3 changes: 3 additions & 0 deletions builtin/settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,9 @@ deprecated_lua_api_handling (Deprecated Lua API handling) enum log none,log,erro
# Enable random user input (only used for testing).
random_input (Random input) bool false

# Enable input via remote message queue (for AI agent training).
remote_input (Remote input) string

# Enable mod channels support.
enable_mod_channels (Mod channels) bool false

Expand Down
10 changes: 10 additions & 0 deletions cmake/Modules/FindZmq.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mark_as_advanced(ZMQ_LIBRARY ZMQ_INCLUDE_DIR)

find_path(ZMQ_INCLUDE_DIR NAMES zmq.h)
message(STATUS ${ZMQ_INCLUDE_DIR})

find_library(ZMQ_LIBRARY NAMES zmq)
message(STATUS ${ZMQ_LIBRARY})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Zmq DEFAULT_MSG ZMQ_LIBRARY ZMQ_INCLUDE_DIR)
Loading
Loading