-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dc0dc31
Showing
164 changed files
with
35,311 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Learning Sturctured Commnunication | ||
|
||
A Tensorflow implementation of `LSC`. | ||
|
||
|
||
## Code structure | ||
|
||
- `./graph_nets`: contains code for establishing communication sturcture. | ||
|
||
- `./examples/`: contains scenarios for Ising Model and Battle Game (also models). | ||
|
||
- `train_battle.py`: contains code for training Battle Game models | ||
|
||
## Requirements Installation | ||
```shell | ||
pip install ./ | ||
``` | ||
## Compile MAgent platform and run | ||
|
||
Before running Battle Game environment, you need to compile it. You can get more helps from: [MAgent](https://github.com/geek-ai/MAgent) | ||
|
||
**Steps for compiling** | ||
|
||
```shell | ||
cd examples/battle_model | ||
./build.sh | ||
``` | ||
|
||
**Steps for training models under Battle Game settings** | ||
|
||
1. Add python path in your `~/.bashrc` or `~/.zshrc`: | ||
|
||
```shell | ||
vim ~/.zshrc | ||
export PYTHONPATH=./examples/battle_model/python:${PYTHONPATH} | ||
source ~/.zshrc | ||
``` | ||
|
||
2. Run training script for training: | ||
|
||
```shell | ||
./runtiny.sh | ||
``` |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+71 Bytes
data/tmp/gilfixtiny3b6h3000-6/gil/events.out.tfevents.1569301523.AIDA2GPU
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build/ | ||
**__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
project(magent) | ||
|
||
IF (APPLE) | ||
set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang++") | ||
link_directories("/usr/local/opt/llvm/lib") | ||
include_directories( "/usr/local/include" ) | ||
link_directories("/usr/local/lib/") | ||
ENDIF() | ||
|
||
file(GLOB autopilot_sources src/*.cc src/gridworld/*.cc src/discrete_snake/*.cc src/utility/*.cc) | ||
set(LIB_SRC_FILES ${autopilot_sources}) | ||
|
||
file(GLOB autopilot_sources src/render/*.cc src/render/*/*.cc src/render/*/*/*.cc) | ||
set(RENDER_SRC_FILES ${autopilot_sources}) | ||
|
||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -std=c++11 -O3") | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-reorder -Wno-sign-compare -Wno-missing-braces") | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -pthread -DDEBUG") | ||
|
||
# runtime library | ||
add_library(magent SHARED ${LIB_SRC_FILES}) | ||
add_executable(testlib ${LIB_SRC_FILES}) | ||
|
||
# render | ||
add_executable(render ${RENDER_SRC_FILES}) | ||
|
||
IF (APPLE) | ||
target_link_libraries(render boost_system jsoncpp argp omp) | ||
ELSE() | ||
target_link_libraries(render boost_system jsoncpp) | ||
ENDIF() | ||
|
||
set_target_properties( render | ||
PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/render/") | ||
|
||
# copy frontend and demo | ||
add_custom_command( | ||
TARGET render POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/src/render/frontend/" "${CMAKE_BINARY_DIR}/render" | ||
) | ||
|
||
add_custom_command( | ||
TARGET render POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/src/render/backend/demo/" "${CMAKE_BINARY_DIR}/render/" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Battle Game | ||
|
||
A cooperative and competitive senario implemented based on MAgent platform | ||
|
||
## Code structure | ||
|
||
- `./algo`: contains algorithms (MFAC, AC, MFQ, IL) | ||
|
||
- `./python` and `./src`: contains engine files | ||
|
||
- `./senario_battle.py`: contains code for the logic of play Battle Game | ||
|
||
- `./build.sh`: you can run it to compile the MAgent platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from . import q_learning | ||
|
||
IL = q_learning.DQN | ||
MSGDQN = q_learning.MsgDQN | ||
GIL=q_learning.GDQN | ||
|
||
def spawn_ai(algo_name, sess, env, handle, human_name, max_steps,len_nei=6): | ||
if algo_name == 'il': | ||
model = IL(sess, human_name, handle, env, max_steps, len_nei,memory_size=80) | ||
elif algo_name == 'gil': | ||
model = GIL(sess, human_name, handle, env, max_steps,len_nei, memory_size=8,isHie=False) | ||
elif algo_name == 'msgdqn': | ||
model=MSGDQN(sess,human_name,handle,env,max_steps,len_nei,msg_bits=3,memory_size=80000) | ||
|
||
return model |
Oops, something went wrong.