/NEAT-TidyV3mul

Primary LanguageC++MIT LicenseMIT

[C++] Topologies I Dunno Yet, eVolve &>EMUL

> TidyV3mul : My very own NEAT framework in C++ (it's v3 on the NES)


Examples


How to _

cd bin

1. Execute program : $ <cmd>
2. Connect Nintaco : Tools > Start Program Server... > Start Server
3. Disconnect      : Stop Server or Ctrl+C

Install

./make.sh or

OPT=$(dirname $(pwd))'/opt/'

sudo apt-get update
sudo apt-get install g++ cmake valgrind libgtest-dev wmctrl

cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make
sudo cp -v lib/*.a /usr/lib

cd "${OPT}"'java'
sudo rm -rv *
wget -O jre-8uLatest-linux-x64.tar.gz https://javadl.oracle.com/webapps/download/AutoDL?BundleId=247127_10e8cce67c7843478f41411b7003171c
tar zxvf jre-8uLatest-linux-x64.tar.gz
rm -v jre-8uLatest-linux-x64.tar.gz
mv -v jre1.8* jre1.8.0_latest

cd "${OPT}"'nintaco'
rm -rv *
mkdir -p Nintaco_bin_2020-05-01
cd Nintaco_bin_2020-05-01
wget https://nintaco.com/Nintaco_bin_2020-05-01.zip
unzip Nintaco_bin_2020-05-01.zip
rm -v Nintaco_bin_2020-05-01.zip

Run

./app.sh or

$ ./build.sh -R
$ ./compile.sh
$ ./run.sh -m train -k n -l 1 -g 0 -t 0 -n 0 -p plt1 -s sav1
$ ./run.sh -m eval -k n -l 1 -e 10 -t 0 -n 0 -s sav1

Connect Nintaco

Train

./train.sh [-D -R] <args> or

* Debug   : $ ./train.sh -D -k n -l 1 -g 0 -t 0 -n 0 -p plt1 -s sav1
* Release : $ ./train.sh -R -k n -l 1 -g 0 -t 0 -n 0 -p plt1 -s sav1

Connect Nintaco

Eval

./eval.sh [-D -R] <args> or

* Debug   : $ ./eval.sh -D -k n -l 1 -e 10 -t 0 -n 0 -s sav1
* Release : $ ./eval.sh -R -k n -l 1 -e 10 -t 0 -n 0 -s sav1

Connect Nintaco

Play

./play.sh [-D -R] <args> or

* Debug   : $ ./play.sh -D -k y -l 1 -e 10
* Release : $ ./play.sh -R -k y -l 1 -e 10

Connect Nintaco

Test

./test.sh [-D -R] <args> or

* Debug   : $ ./test.sh -D 
* Release : $ ./test.sh -R 

Connect Nintaco

Memcheck

./memcheck.sh <cmd>

* Example : $ ./memcheck.sh ./train.sh -g 10 
* Example : $ ./memcheck.sh ./eval.sh -s sav

Connect Nintaco

Log

./log.sh [-V] <cmd>

* Example : $ ./log.sh ./train.sh -s sav
* Example : $ ./log.sh -V ./play.sh -e 1

Connect Nintaco

Readme

./readme.sh

* Update : $ ./readme.sh

Help

./help.sh

usage: apps/exec [-h] [-m MOD] [-k KEY] [-l LVL] [-g GEN] [-e EPO] [-t STP] [-n NOP] [-p PLT] [-s SAV]

TidyV3mul

optional args:
  -h      Print help and exit
  -m MOD  Set mode < train | eval | play | test >
  -k KEY  Set keyboard sfml < y | n >
  -l LVL  Set load state file level lvl
  params:
  -g GEN  [train]       Set number generation (0=inf)
  -e EPO  [eval, play]  Set number epoch      (0=inf)
  -t STP  [train, eval] Set number max step   (0=inf)
  -n NOP  [train, eval] Set number max noop   (0=inf)
  utils:
  -p PLT  [train]       Set file name plot plt
  -s SAV  [train, eval] Set file name save sav
  keys:
  X       [play]        Button A      (? set)
  Z       [play]        Button B      (? set)
  Up      [play]        Button Up     (? set)
  Down    [play]        Button Down   (? set)
  Left    [play]        Button Left   (? set)
  Right   [play]        Button Right  (? set)
  Space   [play]        Button Start  (? set)
  Enter   [play]        Button Select (? set)

Emulation

./emul.sh

* Start : $ ./emul.sh

Config

include/env/conf.hpp

* HYPERPARAMETER VALUES :

INPUTS               = 8
OUTPUTS              = 6

LIM_HIDDEN           = 1000000

MUTATE_WEIGHT_RATE   = 0.1f
MUTATE_GENE_RATE     = 0.25f
MUTATE_LINK_RATE     = 1.f
MUTATE_BIAS_RATE     = 0.4f
MUTATE_NEURON_RATE   = 0.7f
MUTATE_ENABLE_RATE   = 0.2f
MUTATE_DISABLE_RATE  = 0.4f
MUTATE_OFFSET_SIZE   = 0.1f
MUTATE_RATE_DECAY    = 0.f

DELTA_DISJOINT       = 2.f
DELTA_WEIGHTS        = 0.4f
DELTA_THRESHOLD      = 1.f

CROSSOVER_PROB       = 0.75f
STALE_SPECIES        = 50
POPULATION_SIZE      = 300
END_POPULATION_SIZE  = 0
POPULATION_GENS_INC  = 300
POPULATION_INC_FREQ  = 10

ACT_REPEAT           = 5
MVG_AVG              = 300
PLT_FREQ             = 2
SAV_FREQ             = 1

GENERATIONS_TRAIN    = 0
EPOCHS_EVAL          = 10
MAX_STEP             = 0
MAX_NOOP             = 0

Demo

cd bin && ./app.sh

-------------------------------TRAIN-------------------------------

log/plots/

-------------------------------EVAL--------------------------------

Docs

1. Model

include/env/env/ src/env/env/

  • 1.1. implement model

res/rom/ res/sav/ res/

  • 1.2. add rom file
  • 1.3. add level state files
  • 1.4. add optional resources

resources

2. Control

include/env/env.hpp

  • 2.1. add include
  • 2.2. declare model struct

src/env/env.hpp

  • 2.3. define initialization function
  • 2.4. define observation function
  • 2.5. define action function
  • 2.6. define is done function
  • 2.7. define fitness function
  • 2.8. define information function
  • 2.9. define no operation function
  • 2.10. define reset function
  • 2.11. define step function
  • 2.12. define reset render function
  • 2.13. define step render function

3. View

include/env/view.hpp

  • 3.1. add include
  • 3.2. declare event state struct
  • 3.3. declare draw variables
  • 3.4. declare draw functions

src/env/view.cpp

  • 3.5. define event setup function
  • 3.6. define get action function
  • 3.7. define draw setup function
  • 3.8. define draw loop function

4. Tests

test/include/ test/src/

  • 4.1. implement tests

5. Parameters

include/env/conf.hpp

  • 5.1. add include
  • 5.2. define default arguments
  • 5.3. declare optional parameters
  • 5.4. define argv cmds commands
  • 5.5. define help error message
  • 5.6. define optional commands
  • 5.7. define params parameters
  • 5.8. define optional parameters

6. Readme & license

README.md

  • 6.1. update readme

LICENSE

  • 6.2. update license

@romainducrocq