Skip to content

Commit

Permalink
Merge branch 'develop' into improve-world-seeding
Browse files Browse the repository at this point in the history
  • Loading branch information
rk1a committed Aug 27, 2023
2 parents e5d4efc + 315cb46 commit 428caab
Show file tree
Hide file tree
Showing 43 changed files with 537 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
end_of_line = lf

[*.{cpp,h,lua,txt,glsl,md,c,cmake,java,gradle}]
charset = utf8
charset = utf-8
indent_size = 4
indent_style = tab
insert_final_newline = true
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/.venv
/tags
/tags.lock
/tags.temp
/*-*-*-*-*.conf
/*-*-*-*-*/

## Editors and development environments
*~
*.swp
Expand Down Expand Up @@ -54,6 +61,7 @@ newworld/
## Non-static Minetest directories or symlinks to these
/bin/
/games/*
!/games/minetest_game/
!/games/devtest/
/cache
/textures/*
Expand Down Expand Up @@ -103,7 +111,6 @@ doc/mkdocs/mkdocs.yml
build/
build_headless/
CMakeFiles
Makefile
cmake_install.cmake
CMakeCache.txt
CPackConfig.cmake
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@
[submodule "lib/zmqpp"]
path = lib/zmqpp
url = [email protected]:zeromq/zmqpp.git
[submodule "games/minetest_game"]
path = games/minetest_game
url = [email protected]:minetest/minetest_game.git
[submodule "lib/SDL"]
path = lib/SDL
url = [email protected]:libsdl-org/SDL.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()
project(minetest)
set(PROJECT_NAME_CAPITALIZED "Minetest")

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(GCC_MINIMUM_VERSION "5.1")
set(CLANG_MINIMUM_VERSION "3.5")
Expand Down
76 changes: 76 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
.PHONY: all deps repos sdl2 package zmqpp minetester minetest install demo proto clean

MINETESTER_VERSION := 0.0.1
SDL2_CMAKE_FILE := lib/SDL/build/lib/cmake/SDL2/sdl2-config.cmake
ZMQPP_LIB_FILE := lib/zmqpp/build/max-g++/libzmqpp.a
MINETEST_BINARY := bin/minetest
DEBUG_BINARY := bin/debug
MINETESTER_WHEEL := build/package/wheel/minetester-$(MINETESTER_VERSION)-py3-none-manylinux_2_35_x86_64.whl

default: minetest

linux_deps:
# Install debian dependencies
util/minetester/install_deps.sh

python_build_deps:
# Install python build dependencies
pip install --upgrade pip
pip install -r build_requirements.txt

repos:
# Init all submodules
git submodule update --init --recursive

$(SDL2_CMAKE_FILE):
# compile sdl2
util/minetester/build_sdl2.sh

sdl2: $(SDL2_CMAKE_FILE)

proto:
#create protobuf c++ and python files
util/minetester/compile_proto.sh

$(ZMQPP_LIB_FILE):
#compile zmqpp
util/minetester/build_zmqpp.sh

zmqpp: $(ZMQPP_LIB_FILE)


$(MINETEST_BINARY):
#build minetest binary
util/minetester/build_minetest.sh

minetest: $(MINETEST_BINARY)

$(DEBUG_BINARY):
util/minetester/build_debuggable_minetest.sh

debug: $(DEBUG_BINARY)

$(MINETESTER_WHEEL):
#build minetester python library
util/minetester/build_minetester.sh

minetester: $(MINETESTER_WHEEL)

install:
#install python library
pip install $(MINETESTER_WHEEL) --force-reinstall

demo:
#install run demo script
python -m minetester.scripts.test_loop

ctags:
ctags --extras=+f -R --links=no .

clean:
#clean up repo
util/minetester/clean.sh

clean_minetester:
#clean up minetester, but not minetest
util/minetester/clean_minetester.sh
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
EleutherAI Alignment Minetest
=============================
This is a fork of the Minetest Voxel Engine, designed to support an OAI gym like environment. The library supports
This is a fork of the Minetest Voxel Engine, designed to support an OAI gym like environment.

Modes of Operation
------------------
The model provides 4 modes of operation for players and agents
1. Asynchronous real time interaction for agents between client and server.
2. Single agent synchronous interaction between a client and server
3. Multi agent synchronous interaction between a client and server
4. Real time recording of player actions
The environment will eventually provide 4 modes of operation for players and agents
1. Asynchronous real time interaction for agents between client and server. (WIP)
2. Single agent synchronous interaction between a client and server (Done)
3. Multi agent synchronous interaction between a client and server(WIP)
4. Real time recording of player actions (WIP)


Minetester
==========
Minetester is the Python package that exposes Minetest environments via the `gym(nasium)` interface.
After building the minetest executable you can install it with:
After [building the minetest executable](https://github.com/EleutherAI/minetest/blob/develop/build_instructions.txt) you can install it with:
```
pip install -e .
```
Expand All @@ -23,6 +23,35 @@ To verify the installation run
python -m minetester.scripts.test_loop
```

Quick Build Instructions for Linux
==================================

Run these make commands in order to build and install minetester.
If anything goes wrong during install, inspect the relevant entry/script in the Makefile to see what it's trying to do.

```bash
make deb_deps #install debian dependencies, equivalent commands are nessesary for other distros
make python_build_deps #install build dependencies into the local python environment (we reccomend using a venv)
make repos #init submodules
make sdl2 #build sdl2
make zmqpp #build zmqpp
make proto #create c++ and python protobuf files
make minetest #build minetest binary
make minetester #build minetester python library
make install #install python library into local environment along with nessesary dependencies
make demo #run the demo script
make clean #clean up build artifacts
```

Additionally the makefile supports a utility to clean only the minetester install

```
make clean_minetester #remove existing minetester install
make minetester #build minetester python library
make install #install python library into local environment along with nessesary dependencies
make demo #run the demo script
```

Minetest
========

Expand Down
15 changes: 6 additions & 9 deletions build_instructions.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1. Install prereqs
1. Install prereqs
1. sudo apt-get install xvfb g++ make libzmq3-dev libtool pkg-config build-essential autoconf automake libc6-dev cmake libpng-dev libjpeg-dev libxi-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev libluajit-5.1-dev protobuf-compiler

2. Build SDL2
Expand Down Expand Up @@ -33,17 +33,14 @@
6. Build minetest
1. cd into minetest
2. either run
cmake . -DRUN_IN_PLACE=TRUE -DBUILD_HEADLESS=1 -DSDL2_DIR=<path to SDL repo>/SDL/build/lib/cmake/SDL2/
or
cmake . -DRUN_IN_PLACE=TRUE -DBUILD_HEADLESS=1 -DSDL2_DIR=<path to SDL repo>/SDL/build/lib/cmake/SDL2/
or
cmake . -DRUN_IN_PLACE=TRUE -DBUILD_HEADLESS=0 -DSDL2_DIR=
3. run make -j$(nproc)

7. setup python
1. create a new python conda env or venv (tested with python3.9)
2. pip install gym matplotlib protobuf==3.20.1 psutil zmq
7. setup python
1. create and activate a new python conda env or venv (tested with python3.9)
2. pip install gym matplotlib protobuf==3.20.1 psutil zmq -e ./minetest
3. cd into the scripts directory and run compile_proto.sh
4. run python -m minetester.scripts.test_loop




3 changes: 3 additions & 0 deletions build_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setuptools
build
auditwheel
6 changes: 3 additions & 3 deletions clientmods/mods.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load_mod_random_v0 = true
load_mod_rewards = true
load_mod_treechop_v1 = false
load_mod_treechop_shaped_v0 = false
load_mod_random_v1 = false
load_mod_treechop_v0 = false
load_mod_random_v0 = false
load_mod_preview = false
load_mod_treechop_shaped_v0 = false
load_mod_treechop_v0 = false
3 changes: 2 additions & 1 deletion clientmods/random_v0/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
minetest.register_globalstep(function(dtime)
REWARD = math.random()
TERMINAL = math.floor(math.random() + 0.5) == 1
end)
INFO = "hello world"
end)
3 changes: 2 additions & 1 deletion clientmods/rewards/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- define global reward and terminal variables
-- define global reward, terminal and info variables
REWARD = 0.0
TERMINAL = false
INFO = ""
1 change: 1 addition & 0 deletions games/minetest_game
Submodule minetest_game added at 960aff
1 change: 1 addition & 0 deletions lib/SDL
Submodule SDL added at f070c8
Loading

0 comments on commit 428caab

Please sign in to comment.