├── docs ├── .gitignore ├── images │ ├── 2d_physics.png │ ├── replicators.png │ ├── car_track_demo.gif │ ├── darwin_studio.png │ ├── pong_sandbox.png │ ├── splines_track.png │ ├── unicycle_demo.gif │ ├── ballistics_demo.gif │ ├── batch_run_dialog.png │ ├── conquest_sandbox.png │ ├── drone_track_demo.gif │ ├── unicycle_sandbox.png │ ├── ballistics_sandbox.png │ ├── car_track_sandbox.png │ ├── cart_pole_sandbox.png │ ├── drone_follow_demo.gif │ ├── drone_track_sandbox.png │ ├── drone_vision_demo.gif │ ├── harvester_sandbox.png │ ├── python_environment.png │ ├── tic_tac_toe_sandbox.png │ ├── drone_follow_sandbox.png │ ├── drone_vision_sandbox.png │ ├── property_set_variant.png │ ├── splines_corners_after.png │ ├── double_cart_pole_sandbox.png │ ├── qtcreator_select_project.png │ └── splines_corners_before.png └── main_page.md ├── .binder ├── runtime.txt └── requirements.txt ├── .gitattributes ├── tests ├── .temp │ └── .gitignore ├── bindings │ ├── python │ │ ├── .gitignore │ │ ├── __init__.py │ │ ├── darwin_test_utils.py │ │ ├── test_domain.py │ │ └── test_universe.py │ ├── bindings.pro │ └── main.cpp ├── .output │ ├── PropertiesTest_EmptyProperties.out │ ├── CgpTest_OutputGene_LoadSave.out │ ├── DatabaseTest_ManualTransactions.out │ ├── FormatTest_Stringify.out │ ├── TinySplineTest_Examples.out │ ├── DatabaseTest_ScopeTransactions.out │ ├── CgpTest_FunctionGene_LoadSave.out │ ├── DatabaseTest_Inserts.out │ ├── DatabaseTest_ResultSet.out │ ├── CgpTest_FunctionGene_LoadSave_Const.out │ ├── DatabaseTest_ParameterBinding.out │ ├── NeatTest_Gene_LoadSave.out │ ├── IoUtilsTest_Writing.out │ ├── CgpTest_Genotype_Save.out │ ├── PropertiesVariantTest_FromJson.out │ ├── TinySplineTest_ClosedCurve.out │ ├── CneGenesTest_FF_Gene_LoadSave.out │ ├── JsonTest_Parse.out │ ├── PropertiesTest_KnownValues.out │ ├── PropertiesVariantTest_ToJson.out │ ├── FormatTest_Basic.out │ ├── PropertiesTest_FromJson.out │ ├── PropertiesTest_SetValuesString.out │ ├── PropertiesTest_DefaultValues.out │ ├── CneGenesTest_RNN_Gene_LoadSave.out │ ├── CneGenesTest_Full_RNN_Gene_LoadSave.out │ ├── PropertiesTest_ToJson.out │ ├── SqliteTest_Select.out │ ├── CneGenesTest_LSTM_Lite_Gene_LoadSave.out │ ├── JsonTest_Examples.out │ ├── PropertiesVariantTest_EmbeddedToJson.out │ ├── CneGenesTest_LSTM_Gene_LoadSave.out │ ├── JsonTest_ForEach.out │ ├── PropertiesTest_SetValuesDirect.out │ ├── PropertiesTest_Const.out │ ├── PropertiesTest_Enumerate.out │ └── PugiXmlTest_Create.out ├── tests.pro ├── darwin │ ├── darwin.pro │ ├── test_environment.h │ └── main.cpp ├── third_party │ ├── third_party.pro │ └── main.cpp ├── domains │ ├── domains.pro │ └── main.cpp ├── populations │ ├── populations.pro │ └── dummy_domain.h ├── core │ ├── core.pro │ └── main.cpp └── tests_common.pri ├── third_party ├── box2d │ ├── box2d.h │ ├── box2d.pro │ └── LICENSE ├── gtest │ ├── gmock.h │ ├── gtest.h │ ├── gtest.pro │ └── LICENSE ├── tinyspline │ ├── tinyspline.h │ ├── tinyspline.pro │ └── LICENSE ├── sqlite │ ├── LICENSE │ └── sqlite.pro ├── pugixml │ ├── pugixml.h │ ├── pugixml.pro │ └── LICENSE ├── pybind11 │ ├── pybind11.pro │ └── pybind11.h ├── json │ ├── json.pro │ └── LICENSE └── third_party.pro ├── .gitignore ├── core_ui ├── resources │ ├── close.png │ ├── drone.png │ ├── gears.png │ ├── minus.png │ ├── pause.png │ ├── play.png │ ├── plus.png │ ├── reset.png │ ├── stop.png │ ├── undo.png │ ├── connect.png │ ├── darwin.png │ ├── mc_eject.png │ ├── mc_pause.png │ ├── mc_play.png │ ├── mc_stop.png │ ├── refresh.png │ ├── revert.png │ ├── zoom_in.png │ ├── zoom_out.png │ ├── blue_user.png │ ├── flip_sides.png │ ├── light_bulb.png │ ├── mc_forward.png │ ├── white_user.png │ ├── flip_vertical.png │ ├── mc_backward.png │ ├── view_refresh.png │ ├── zoom_fit_best.png │ ├── flip_horizontal.png │ ├── mc_skip_forward.png │ └── mc_skip_backward.png ├── core_ui.pro └── sim │ ├── box2d_sandbox_dialog.h │ ├── camera_widget.h │ ├── touch_widget.h │ ├── compass_widget.h │ └── box2d_sandbox_dialog.cpp ├── scripts └── docs │ ├── perf_chart.png │ ├── batch_fitness.png │ ├── fitness_chart.png │ ├── fitness_diff.png │ ├── fitness_dist.png │ ├── neat_genotype.png │ ├── universe_graph.png │ ├── cgp_genotype_full.png │ ├── cgp_genotype_pruned.png │ └── fitness_dist_sorted.png ├── experimental ├── experimental.pro ├── README.md ├── 2d_physics │ ├── main.cpp │ ├── tool_window.cpp │ ├── tool_window.h │ ├── camera_window.h │ ├── new_sandbox_dialog.h │ ├── touch_window.h │ ├── compass_window.h │ ├── new_scene_dialog.h │ ├── accelerometer_window.h │ ├── new_scene_dialog.cpp │ ├── compass_window.cpp │ ├── touch_window.cpp │ ├── camera_window.cpp │ ├── accelerometer_window.cpp │ ├── new_sandbox_dialog.cpp │ ├── sandbox_factory.h │ ├── main_window.h │ ├── scenes │ │ ├── bouncing.cpp │ │ ├── bouncing.h │ │ └── particles.h │ └── sandbox_window.h └── replicators │ ├── experiment_window.ui │ ├── main.cpp │ ├── new_experiment_dialog.h │ ├── tests.h │ ├── new_experiment_dialog.cpp │ ├── replicators.pro │ ├── replicators.cpp │ ├── tests.cpp │ └── main_window.h ├── populations ├── populations.pro ├── neat │ └── neat.pro ├── test_population │ ├── test_population.pro │ ├── test_population.h │ └── genotype.h ├── cgp │ └── cgp.pro └── cne │ └── cne.pro ├── .clang-format ├── domains ├── max │ └── max.pro ├── car_track │ └── car_track.pro ├── drone_track │ └── drone_track.pro ├── drone_follow │ └── drone_follow.pro ├── drone_vision │ └── drone_vision.pro ├── test_domain │ ├── test_domain.pro │ └── agent.h ├── unicycle │ ├── unicycle.pro │ └── agent.h ├── cart_pole │ ├── cart_pole.pro │ └── agent.h ├── ballistics │ ├── ballistics.pro │ ├── agent.cpp │ └── agent.h ├── double_cart_pole │ ├── double_cart_pole.pro │ └── agent.h ├── harvester │ ├── harvester.pro │ └── world.h ├── pong │ ├── pong.pro │ ├── test_players.h │ └── player.h ├── cart_pole_ui │ ├── cart_pole_ui.pro │ ├── cart_pole_ui.h │ └── cart_pole_ui.cpp ├── car_track_ui │ ├── car_track_ui.pro │ ├── domain_ui.h │ ├── domain_ui.cpp │ └── scene_ui.h ├── double_cart_pole_ui │ ├── double_cart_pole_ui.pro │ ├── double_cart_pole_ui.h │ └── double_cart_pole_ui.cpp ├── unicycle_ui │ ├── unicycle_ui.pro │ ├── unicycle_ui.h │ ├── scene_ui.h │ └── unicycle_ui.cpp ├── conquest │ ├── conquest.pro │ ├── ann_player.h │ ├── test_players.h │ └── player.h ├── drone_track_ui │ ├── drone_track_ui.pro │ ├── domain_ui.h │ └── domain_ui.cpp ├── ballistics_ui │ ├── ballistics_ui.pro │ ├── ballistics_ui.h │ ├── ballistics_ui.cpp │ └── scene_ui.h ├── drone_follow_ui │ ├── drone_follow_ui.pro │ ├── domain_ui.h │ ├── domain_ui.cpp │ └── scene_ui.h ├── drone_vision_ui │ ├── drone_vision_ui.pro │ ├── domain_ui.h │ ├── domain_ui.cpp │ └── scene_ui.h ├── tic_tac_toe │ ├── tic_tac_toe.pro │ ├── game_rules.h │ ├── test_players.h │ ├── player.h │ ├── board.cpp │ └── ann_player.h ├── pong_ui │ ├── pong_ui.pro │ ├── pong_ui.h │ ├── pong_ui.cpp │ └── human_player.h ├── harvester_ui │ ├── harvester_ui.pro │ ├── harvester_ui.h │ ├── new_sandbox_dialog.h │ └── harvester_ui.cpp ├── tic_tac_toe_ui │ ├── tic_tac_toe_ui.pro │ ├── tic_tac_toe_ui.h │ └── tic_tac_toe_ui.cpp ├── conquest_ui │ ├── conquest_ui.pro │ ├── conquest_ui.h │ └── conquest_ui.cpp └── domains.pro ├── bindings ├── bindings.pro └── python │ └── python.pro ├── AUTHORS ├── CONTRIBUTING.md ├── .gitmodules ├── darwin.pro ├── darwin_studio ├── player.cpp ├── output_window.h ├── evolution_window.h ├── start_evolution_dialog.h ├── experiment_window.h ├── open_experiment_dialog.h ├── output_window.cpp └── perf_window.h ├── registry ├── registry.h ├── registry_ui.h └── registry.pro └── core ├── ann_utils.cpp ├── parallel_for_each.cpp ├── sim ├── compass.cpp ├── compass.h ├── misc.h ├── car_controller.h ├── drone_controller.h └── scene.cpp ├── platform_abstraction_layer.h ├── pp_utils.h ├── runtime.h ├── exception.h ├── swiss_tournament.h └── chronometer.h /docs/.gitignore: -------------------------------------------------------------------------------- 1 | html 2 | -------------------------------------------------------------------------------- /.binder/runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.8 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /tests/.temp/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/bindings/python/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | -------------------------------------------------------------------------------- /tests/.output/PropertiesTest_EmptyProperties.out: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /tests/.output/CgpTest_OutputGene_LoadSave.out: -------------------------------------------------------------------------------- 1 | { 2 | "c": 5 3 | } -------------------------------------------------------------------------------- /tests/.output/DatabaseTest_ManualTransactions.out: -------------------------------------------------------------------------------- 1 | 1, 3.140000, 'PI' 2 | -------------------------------------------------------------------------------- /tests/.output/FormatTest_Stringify.out: -------------------------------------------------------------------------------- 1 | [Foo] 2 | [100] 3 | [{ 1, 2, 3 }] 4 | -------------------------------------------------------------------------------- /third_party/box2d/box2d.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "src/Box2D/Box2D.h" 3 | -------------------------------------------------------------------------------- /tests/.output/TinySplineTest_Examples.out: -------------------------------------------------------------------------------- 1 | x=-1.34, y=0.29 2 | x=0.70, y=2.30 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pro.user 2 | .DS_Store 3 | .vscode 4 | .build 5 | .ipynb_checkpoints 6 | -------------------------------------------------------------------------------- /third_party/gtest/gmock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "src/googlemock/include/gmock/gmock.h" -------------------------------------------------------------------------------- /third_party/tinyspline/tinyspline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "repo/src/tinysplinecxx.h" 3 | -------------------------------------------------------------------------------- /.binder/requirements.txt: -------------------------------------------------------------------------------- 1 | jupyterlab>=1.2.4 2 | darwin-framework 3 | matplotlib 4 | jupyterplot 5 | -------------------------------------------------------------------------------- /third_party/gtest/gtest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "src/googletest/include/gtest/gtest.h" 3 | -------------------------------------------------------------------------------- /core_ui/resources/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/close.png -------------------------------------------------------------------------------- /core_ui/resources/drone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/drone.png -------------------------------------------------------------------------------- /core_ui/resources/gears.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/gears.png -------------------------------------------------------------------------------- /core_ui/resources/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/minus.png -------------------------------------------------------------------------------- /core_ui/resources/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/pause.png -------------------------------------------------------------------------------- /core_ui/resources/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/play.png -------------------------------------------------------------------------------- /core_ui/resources/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/plus.png -------------------------------------------------------------------------------- /core_ui/resources/reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/reset.png -------------------------------------------------------------------------------- /core_ui/resources/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/stop.png -------------------------------------------------------------------------------- /core_ui/resources/undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/undo.png -------------------------------------------------------------------------------- /docs/images/2d_physics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/2d_physics.png -------------------------------------------------------------------------------- /docs/images/replicators.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/replicators.png -------------------------------------------------------------------------------- /scripts/docs/perf_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/perf_chart.png -------------------------------------------------------------------------------- /core_ui/resources/connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/connect.png -------------------------------------------------------------------------------- /core_ui/resources/darwin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/darwin.png -------------------------------------------------------------------------------- /core_ui/resources/mc_eject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/mc_eject.png -------------------------------------------------------------------------------- /core_ui/resources/mc_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/mc_pause.png -------------------------------------------------------------------------------- /core_ui/resources/mc_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/mc_play.png -------------------------------------------------------------------------------- /core_ui/resources/mc_stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/mc_stop.png -------------------------------------------------------------------------------- /core_ui/resources/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/refresh.png -------------------------------------------------------------------------------- /core_ui/resources/revert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/revert.png -------------------------------------------------------------------------------- /core_ui/resources/zoom_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/zoom_in.png -------------------------------------------------------------------------------- /core_ui/resources/zoom_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/zoom_out.png -------------------------------------------------------------------------------- /docs/images/car_track_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/car_track_demo.gif -------------------------------------------------------------------------------- /docs/images/darwin_studio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/darwin_studio.png -------------------------------------------------------------------------------- /docs/images/pong_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/pong_sandbox.png -------------------------------------------------------------------------------- /docs/images/splines_track.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/splines_track.png -------------------------------------------------------------------------------- /docs/images/unicycle_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/unicycle_demo.gif -------------------------------------------------------------------------------- /scripts/docs/batch_fitness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/batch_fitness.png -------------------------------------------------------------------------------- /scripts/docs/fitness_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/fitness_chart.png -------------------------------------------------------------------------------- /scripts/docs/fitness_diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/fitness_diff.png -------------------------------------------------------------------------------- /scripts/docs/fitness_dist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/fitness_dist.png -------------------------------------------------------------------------------- /scripts/docs/neat_genotype.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/neat_genotype.png -------------------------------------------------------------------------------- /third_party/sqlite/LICENSE: -------------------------------------------------------------------------------- 1 | SQLite is in the public domain. 2 | https://www.sqlite.org/copyright.html 3 | -------------------------------------------------------------------------------- /core_ui/resources/blue_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/blue_user.png -------------------------------------------------------------------------------- /core_ui/resources/flip_sides.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/flip_sides.png -------------------------------------------------------------------------------- /core_ui/resources/light_bulb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/light_bulb.png -------------------------------------------------------------------------------- /core_ui/resources/mc_forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/mc_forward.png -------------------------------------------------------------------------------- /core_ui/resources/white_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/white_user.png -------------------------------------------------------------------------------- /docs/images/ballistics_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/ballistics_demo.gif -------------------------------------------------------------------------------- /docs/images/batch_run_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/batch_run_dialog.png -------------------------------------------------------------------------------- /docs/images/conquest_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/conquest_sandbox.png -------------------------------------------------------------------------------- /docs/images/drone_track_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/drone_track_demo.gif -------------------------------------------------------------------------------- /docs/images/unicycle_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/unicycle_sandbox.png -------------------------------------------------------------------------------- /scripts/docs/universe_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/universe_graph.png -------------------------------------------------------------------------------- /core_ui/resources/flip_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/flip_vertical.png -------------------------------------------------------------------------------- /core_ui/resources/mc_backward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/mc_backward.png -------------------------------------------------------------------------------- /core_ui/resources/view_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/view_refresh.png -------------------------------------------------------------------------------- /core_ui/resources/zoom_fit_best.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/zoom_fit_best.png -------------------------------------------------------------------------------- /docs/images/ballistics_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/ballistics_sandbox.png -------------------------------------------------------------------------------- /docs/images/car_track_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/car_track_sandbox.png -------------------------------------------------------------------------------- /docs/images/cart_pole_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/cart_pole_sandbox.png -------------------------------------------------------------------------------- /docs/images/drone_follow_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/drone_follow_demo.gif -------------------------------------------------------------------------------- /docs/images/drone_track_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/drone_track_sandbox.png -------------------------------------------------------------------------------- /docs/images/drone_vision_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/drone_vision_demo.gif -------------------------------------------------------------------------------- /docs/images/harvester_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/harvester_sandbox.png -------------------------------------------------------------------------------- /docs/images/python_environment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/python_environment.png -------------------------------------------------------------------------------- /docs/images/tic_tac_toe_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/tic_tac_toe_sandbox.png -------------------------------------------------------------------------------- /scripts/docs/cgp_genotype_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/cgp_genotype_full.png -------------------------------------------------------------------------------- /tests/.output/DatabaseTest_ScopeTransactions.out: -------------------------------------------------------------------------------- 1 | caught exception: mid-transaction exception 2 | 1, 3.140000, 'PI' 3 | -------------------------------------------------------------------------------- /third_party/pugixml/pugixml.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PUGIXML_HEADER_ONLY 4 | #include "src/src/pugixml.hpp" 5 | -------------------------------------------------------------------------------- /core_ui/resources/flip_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/flip_horizontal.png -------------------------------------------------------------------------------- /core_ui/resources/mc_skip_forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/mc_skip_forward.png -------------------------------------------------------------------------------- /docs/images/drone_follow_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/drone_follow_sandbox.png -------------------------------------------------------------------------------- /docs/images/drone_vision_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/drone_vision_sandbox.png -------------------------------------------------------------------------------- /docs/images/property_set_variant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/property_set_variant.png -------------------------------------------------------------------------------- /docs/images/splines_corners_after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/splines_corners_after.png -------------------------------------------------------------------------------- /scripts/docs/cgp_genotype_pruned.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/cgp_genotype_pruned.png -------------------------------------------------------------------------------- /scripts/docs/fitness_dist_sorted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/scripts/docs/fitness_dist_sorted.png -------------------------------------------------------------------------------- /core_ui/resources/mc_skip_backward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/core_ui/resources/mc_skip_backward.png -------------------------------------------------------------------------------- /docs/images/double_cart_pole_sandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/double_cart_pole_sandbox.png -------------------------------------------------------------------------------- /docs/images/qtcreator_select_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/qtcreator_select_project.png -------------------------------------------------------------------------------- /docs/images/splines_corners_before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlemo/darwin/HEAD/docs/images/splines_corners_before.png -------------------------------------------------------------------------------- /experimental/experimental.pro: -------------------------------------------------------------------------------- 1 | 2 | TEMPLATE = subdirs 3 | 4 | SUBDIRS += \ 5 | 2d_physics \ 6 | replicators 7 | 8 | -------------------------------------------------------------------------------- /tests/.output/CgpTest_FunctionGene_LoadSave.out: -------------------------------------------------------------------------------- 1 | { 2 | "a": 2, 3 | "c": [ 4 | 0, 5 | 1 6 | ], 7 | "fn": "*" 8 | } -------------------------------------------------------------------------------- /experimental/README.md: -------------------------------------------------------------------------------- 1 | 2 | Sandbox location for experimental projects. These are not strictly 3 | required for using Darwin. 4 | -------------------------------------------------------------------------------- /tests/.output/DatabaseTest_Inserts.out: -------------------------------------------------------------------------------- 1 | before/rowid: 0 2 | rowid: 1 3 | rowid: 2 4 | rowid: 3 5 | rowid: 4 6 | after/rowid: 4 7 | -------------------------------------------------------------------------------- /tests/bindings/python/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | sys.path.append(os.path.dirname(os.path.abspath(__file__))) 5 | -------------------------------------------------------------------------------- /tests/.output/DatabaseTest_ResultSet.out: -------------------------------------------------------------------------------- 1 | 1, 3.140000, 'PI' 2 | 2, 0.000000, 'nothing' 3 | 3, 10.000000, 'null' 4 | 4, 0.000000, 'null' 5 | -------------------------------------------------------------------------------- /tests/.output/CgpTest_FunctionGene_LoadSave_Const.out: -------------------------------------------------------------------------------- 1 | { 2 | "a": 0, 3 | "c": [ 4 | 0, 5 | 1 6 | ], 7 | "fn": "const_1" 8 | } -------------------------------------------------------------------------------- /populations/populations.pro: -------------------------------------------------------------------------------- 1 | 2 | TEMPLATE = subdirs 3 | 4 | SUBDIRS += \ 5 | cgp \ 6 | cne \ 7 | neat \ 8 | test_population 9 | -------------------------------------------------------------------------------- /tests/.output/DatabaseTest_ParameterBinding.out: -------------------------------------------------------------------------------- 1 | 1, 3.140000, 'Pi' 2 | 2, 100.000000, 'Max' 3 | 3, 0.000000, 'null' 4 | 4, 0.100000, 'Haha let's see' 5 | -------------------------------------------------------------------------------- /third_party/pugixml/pugixml.pro: -------------------------------------------------------------------------------- 1 | 2 | # NOTE: header only library 3 | 4 | TARGET = pugixml 5 | TEMPLATE = aux 6 | 7 | HEADERS += \ 8 | pugixml.h 9 | -------------------------------------------------------------------------------- /third_party/pybind11/pybind11.pro: -------------------------------------------------------------------------------- 1 | 2 | # NOTE: header only library 3 | 4 | TARGET = pybind11 5 | TEMPLATE = aux 6 | 7 | HEADERS += \ 8 | pybind11.h 9 | -------------------------------------------------------------------------------- /third_party/json/json.pro: -------------------------------------------------------------------------------- 1 | 2 | # NOTE: header only library 3 | 4 | TARGET = json 5 | TEMPLATE = aux 6 | 7 | HEADERS += \ 8 | json.h 9 | 10 | -------------------------------------------------------------------------------- /tests/.output/NeatTest_Gene_LoadSave.out: -------------------------------------------------------------------------------- 1 | { 2 | "enabled": false, 3 | "in": 0, 4 | "innovation": 100, 5 | "out": 1, 6 | "recurrent": true, 7 | "weight": 0.5 8 | } -------------------------------------------------------------------------------- /tests/.output/IoUtilsTest_Writing.out: -------------------------------------------------------------------------------- 1 | [Testing...] 2 | { } 3 | { x } 4 | { -1, 0, 1, 100 } 5 | { -100.001, -1, -0.1, 0, 0.01, 1, 1.1 } 6 | { a, Bb, Cc cC, dDDd } 7 | [Done] 8 | -------------------------------------------------------------------------------- /tests/tests.pro: -------------------------------------------------------------------------------- 1 | 2 | TEMPLATE = subdirs 3 | 4 | SUBDIRS += \ 5 | bindings \ 6 | core \ 7 | darwin \ 8 | populations \ 9 | domains \ 10 | third_party 11 | -------------------------------------------------------------------------------- /tests/darwin/darwin.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../tests_common.pri) 3 | 4 | SOURCES += \ 5 | main.cpp \ 6 | smoke_tests.cpp 7 | 8 | HEADERS += \ 9 | test_environment.h 10 | 11 | -------------------------------------------------------------------------------- /tests/.output/CgpTest_Genotype_Save.out: -------------------------------------------------------------------------------- 1 | { 2 | "columns": 8, 3 | "constants_genes": [], 4 | "function_genes": [], 5 | "inputs": 5, 6 | "output_genes": [], 7 | "outputs": 4, 8 | "rows": 7 9 | } -------------------------------------------------------------------------------- /tests/bindings/bindings.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../tests_common.pri) 3 | 4 | SOURCES += \ 5 | main.cpp \ 6 | python_tests.cpp 7 | 8 | DISTFILES += \ 9 | $$files(python/*.py, true) 10 | 11 | -------------------------------------------------------------------------------- /third_party/third_party.pro: -------------------------------------------------------------------------------- 1 | 2 | TEMPLATE = subdirs 3 | 4 | SUBDIRS += \ 5 | gtest \ 6 | pugixml \ 7 | json \ 8 | sqlite \ 9 | box2d \ 10 | tinyspline \ 11 | pybind11 12 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Chromium 2 | BinPackArguments: 'false' 3 | BinPackParameters: 'false' 4 | Cpp11BracedListStyle: 'false' 5 | ColumnLimit: '90' 6 | UseTab: Never 7 | IncludeBlocks: Preserve 8 | SortIncludes: 'false' 9 | -------------------------------------------------------------------------------- /tests/.output/PropertiesVariantTest_FromJson.out: -------------------------------------------------------------------------------- 1 | active tag: extra 2 | values = '{ }' 3 | scale = '2.5' 4 | name = 'Lemo' 5 | --- 6 | active tag: empty 7 | --- 8 | active tag: basic 9 | bool_flag = 'false' 10 | max_value = '100' 11 | --- 12 | -------------------------------------------------------------------------------- /tests/.output/TinySplineTest_ClosedCurve.out: -------------------------------------------------------------------------------- 1 | 0: 6.67, -6.67 2 | 1: 9.42, 0.69 3 | 2: 7.72, 6.52 4 | 3: 3.27, 7.01 5 | 4: -2.20, 6.85 6 | 5: -6.99, 6.95 7 | 6: -9.38, 2.22 8 | 7: -7.66, -5.44 9 | 8: -0.83, -9.14 10 | 9: 6.67, -6.67 11 | -------------------------------------------------------------------------------- /tests/third_party/third_party.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../tests_common.pri) 3 | 4 | SOURCES += \ 5 | main.cpp \ 6 | sqlite_tests.cpp \ 7 | pugixml_tests.cpp \ 8 | json_tests.cpp \ 9 | box2d_tests.cpp \ 10 | tinyspline_tests.cpp 11 | 12 | -------------------------------------------------------------------------------- /third_party/sqlite/sqlite.pro: -------------------------------------------------------------------------------- 1 | 2 | QT -= core gui 3 | 4 | TARGET = sqlite 5 | TEMPLATE = lib 6 | CONFIG += staticlib warn_off 7 | 8 | DEFINES += SQLITE_ENABLE_JSON1 9 | 10 | SOURCES += \ 11 | sqlite3.c 12 | 13 | HEADERS += \ 14 | sqlite3.h 15 | -------------------------------------------------------------------------------- /tests/.output/CneGenesTest_FF_Gene_LoadSave.out: -------------------------------------------------------------------------------- 1 | { 2 | "w": { 3 | "cols": 2, 4 | "rows": 4, 5 | "values": [ 6 | 0.0, 7 | 1.0, 8 | 2.0, 9 | 3.0, 10 | 4.0, 11 | 5.0, 12 | 6.0, 13 | 7.0 14 | ] 15 | } 16 | } -------------------------------------------------------------------------------- /tests/.output/JsonTest_Parse.out: -------------------------------------------------------------------------------- 1 | { 2 | "happy": true, 3 | "pi": 3.141 4 | } 5 | Exception: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing object separator - invalid literal; last read: '"happy: true, "p'; expected ':' 6 | -------------------------------------------------------------------------------- /tests/.output/PropertiesTest_KnownValues.out: -------------------------------------------------------------------------------- 1 | max_value: 2 | resolution: 3 | name: 4 | flag: 'false' 'true' 5 | acc_operator: 'add' 'divide' 'multiply' 'subtract' 6 | layers: 7 | values: 8 | more_values: 9 | extra_values: 10 | values_init: 11 | custom: 12 | custom_init: 13 | -------------------------------------------------------------------------------- /tests/.output/PropertiesVariantTest_ToJson.out: -------------------------------------------------------------------------------- 1 | { 2 | "basic": { 3 | "bool_flag": "false", 4 | "max_value": "100" 5 | }, 6 | "empty": {}, 7 | "extra": { 8 | "name": "Darwin", 9 | "scale": "1", 10 | "values": "{ }" 11 | }, 12 | "tag": "basic" 13 | } -------------------------------------------------------------------------------- /tests/domains/domains.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../tests_common.pri) 3 | 4 | SOURCES += \ 5 | main.cpp \ 6 | cart_pole_tests.cpp \ 7 | double_cart_pole_tests.cpp \ 8 | unicycle_tests.cpp \ 9 | ballistics_tests.cpp 10 | 11 | HEADERS += \ 12 | test_brain.h 13 | -------------------------------------------------------------------------------- /third_party/pybind11/pybind11.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "repo/include/pybind11/pybind11.h" 5 | #include "repo/include/pybind11/attr.h" 6 | #include "repo/include/pybind11/stl.h" 7 | #include "repo/include/pybind11/functional.h" 8 | 9 | namespace py = pybind11; 10 | -------------------------------------------------------------------------------- /tests/.output/FormatTest_Basic.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %% 5 | % no arguments % 6 | 'Hello world!' 7 | '~~~~ Hello world! ~~~~' 8 | ' ... Hello world! ... ' 9 | prefix 'Foo' %=123 sufix 10 | ' #####' + '***** ' 11 | ' Hello world! ' 12 | [+00032.12345123] 13 | -------------------------------------------------------------------------------- /experimental/2d_physics/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "main_window.h" 3 | 4 | #include 5 | 6 | int main(int argc, char* argv[]) { 7 | QApplication app(argc, argv); 8 | Q_INIT_RESOURCE(resources); 9 | 10 | MainWindow main_window; 11 | main_window.show(); 12 | return app.exec(); 13 | } 14 | -------------------------------------------------------------------------------- /domains/max/max.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = max 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | robot.cpp \ 12 | world.cpp 13 | 14 | HEADERS += \ 15 | robot.h \ 16 | world.h \ 17 | max.h 18 | 19 | addLibrary(../../core) 20 | -------------------------------------------------------------------------------- /domains/car_track/car_track.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = car_track 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | domain.cpp \ 12 | scene.cpp 13 | 14 | HEADERS += \ 15 | domain.h \ 16 | scene.h 17 | 18 | addLibrary(../../core) 19 | -------------------------------------------------------------------------------- /domains/drone_track/drone_track.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = drone_track 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | domain.cpp \ 12 | scene.cpp 13 | 14 | HEADERS += \ 15 | domain.h \ 16 | scene.h 17 | 18 | addLibrary(../../core) 19 | -------------------------------------------------------------------------------- /experimental/2d_physics/tool_window.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "tool_window.h" 3 | 4 | ToolWindow::ToolWindow(QWidget* parent) : QFrame(parent) { 5 | setContentsMargins(5, 5, 5, 5); 6 | setStyleSheet(R"( 7 | ToolWindow 8 | { 9 | border: 1px solid lightgray; 10 | border-radius: 2px; 11 | })"); 12 | } 13 | -------------------------------------------------------------------------------- /experimental/2d_physics/tool_window.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | class SandboxWindow; 7 | 8 | class ToolWindow : public QFrame { 9 | Q_OBJECT 10 | 11 | public: 12 | explicit ToolWindow(QWidget* parent); 13 | 14 | virtual void onSandboxChange(SandboxWindow* sandbox_window) = 0; 15 | }; 16 | -------------------------------------------------------------------------------- /domains/drone_follow/drone_follow.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = drone_follow 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | domain.cpp \ 12 | scene.cpp 13 | 14 | HEADERS += \ 15 | domain.h \ 16 | scene.h 17 | 18 | addLibrary(../../core) 19 | -------------------------------------------------------------------------------- /domains/drone_vision/drone_vision.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = drone_vision 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | domain.cpp \ 12 | scene.cpp 13 | 14 | HEADERS += \ 15 | domain.h \ 16 | scene.h 17 | 18 | addLibrary(../../core) 19 | -------------------------------------------------------------------------------- /bindings/bindings.pro: -------------------------------------------------------------------------------- 1 | 2 | TEMPLATE = subdirs 3 | 4 | PYTHON_INCLUDE = $$(PYTHON_INCLUDE) 5 | isEmpty(PYTHON_INCLUDE) { 6 | message('PYTHON_INCLUDE not defined, Python bindings will not be built') 7 | } else { 8 | message('Including Python bindings (PYTHON_INCLUDE="$$PYTHON_INCLUDE")') 9 | SUBDIRS += python 10 | } 11 | 12 | -------------------------------------------------------------------------------- /domains/test_domain/test_domain.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = test_domain 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | test_domain.cpp \ 12 | agent.cpp 13 | 14 | HEADERS += \ 15 | test_domain.h \ 16 | agent.h 17 | 18 | addLibrary(../../core) 19 | -------------------------------------------------------------------------------- /docs/main_page.md: -------------------------------------------------------------------------------- 1 | 2 | This is the implementation reference for Darwin, a Neuroevolution Framework. 3 | 4 | - [GitHub Page](https://github.com/tlemo/darwin), which includes a quick introduction. 5 | - Main documentation indexes: [Namespaces](namespaces.html) and [Classes](annotated.html) 6 | 7 | ![Darwin Architecture Overview](images/darwin_architecture.svg) 8 | -------------------------------------------------------------------------------- /domains/unicycle/unicycle.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = unicycle 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | unicycle.cpp \ 12 | agent.cpp \ 13 | world.cpp 14 | 15 | HEADERS += \ 16 | unicycle.h \ 17 | agent.h \ 18 | world.h 19 | 20 | addLibrary(../../core) 21 | -------------------------------------------------------------------------------- /domains/cart_pole/cart_pole.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = cart_pole 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | cart_pole.cpp \ 12 | agent.cpp \ 13 | world.cpp 14 | 15 | HEADERS += \ 16 | cart_pole.h \ 17 | agent.h \ 18 | world.h 19 | 20 | addLibrary(../../core) 21 | -------------------------------------------------------------------------------- /domains/ballistics/ballistics.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = ballistics 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | ballistics.cpp \ 12 | agent.cpp \ 13 | world.cpp 14 | 15 | HEADERS += \ 16 | ballistics.h \ 17 | agent.h \ 18 | world.h 19 | 20 | addLibrary(../../core) 21 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the list of Darwin Neuroevolution Framework authors for copyright purposes. 2 | # 3 | # This does not necessarily list everyone who has contributed code, since in 4 | # some cases, their employer may be the copyright holder. To see the full list 5 | # of contributors, see the revision history in source control. 6 | 7 | Google LLC 8 | Leonard Mosescu 9 | 10 | -------------------------------------------------------------------------------- /tests/.output/PropertiesTest_FromJson.out: -------------------------------------------------------------------------------- 1 | max_value = '256' 2 | resolution = '0.05' 3 | name = ' <"El chupacabra"> ' 4 | flag = 'false' 5 | acc_operator = 'add' 6 | layers = '{ 10, 20, 30 }' 7 | values = '{ }' 8 | more_values = '{ 1, 2, 3 }' 9 | extra_values = '{ 0, 10, 20, 30 }' 10 | values_init = '{ -1, -2, -3 }' 11 | custom = '{ 0, 0 }' 12 | custom_init = '{ 1, -100 }' 13 | -------------------------------------------------------------------------------- /tests/.output/PropertiesTest_SetValuesString.out: -------------------------------------------------------------------------------- 1 | max_value = '5' 2 | resolution = '10.5' 3 | name = ' -- Lemo 123 -- ' 4 | flag = 'true' 5 | acc_operator = 'multiply' 6 | layers = '{ 16, 8, 4 }' 7 | values = '{ }' 8 | more_values = '{ -1.1, 0, 123.456 }' 9 | extra_values = '{ 0, 0.1, 0.2 }' 10 | values_init = '{ 3.14 }' 11 | custom = '{ 64, 16 }' 12 | custom_init = '{ 1, -100 }' 13 | -------------------------------------------------------------------------------- /tests/.output/PropertiesTest_DefaultValues.out: -------------------------------------------------------------------------------- 1 | max_value = '100' 2 | resolution = '0.3' 3 | name = ' <"El chupacabra"> ' 4 | flag = 'false' 5 | acc_operator = 'add' 6 | layers = '{ }' 7 | values = '{ -1, 0, 0.1, 0.2, 1.001 }' 8 | more_values = '{ 1, 2, 3 }' 9 | extra_values = '{ 0, 10, 20, 30 }' 10 | values_init = '{ -1, -2, -3 }' 11 | custom = '{ 0, 0 }' 12 | custom_init = '{ 1, -100 }' 13 | -------------------------------------------------------------------------------- /domains/double_cart_pole/double_cart_pole.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = double_cart_pole 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | double_cart_pole.cpp \ 12 | agent.cpp \ 13 | world.cpp 14 | 15 | HEADERS += \ 16 | double_cart_pole.h \ 17 | agent.h \ 18 | world.h 19 | 20 | addLibrary(../../core) 21 | -------------------------------------------------------------------------------- /tests/.output/CneGenesTest_RNN_Gene_LoadSave.out: -------------------------------------------------------------------------------- 1 | { 2 | "rw": { 3 | "cols": 2, 4 | "rows": 1, 5 | "values": [ 6 | 100.0, 7 | 101.0 8 | ] 9 | }, 10 | "w": { 11 | "cols": 2, 12 | "rows": 4, 13 | "values": [ 14 | 0.0, 15 | 1.0, 16 | 2.0, 17 | 3.0, 18 | 4.0, 19 | 5.0, 20 | 6.0, 21 | 7.0 22 | ] 23 | } 24 | } -------------------------------------------------------------------------------- /populations/neat/neat.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = neat 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | neat.cpp \ 12 | population.cpp \ 13 | genotype.cpp \ 14 | brain.cpp 15 | 16 | HEADERS += \ 17 | neat.h \ 18 | population.h \ 19 | genotype.h \ 20 | brain.h 21 | 22 | addLibrary(../../core) 23 | -------------------------------------------------------------------------------- /tests/populations/populations.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../tests_common.pri) 3 | 4 | SOURCES += \ 5 | main.cpp \ 6 | cne_genotypes_tests.cpp \ 7 | cne_genes_tests.cpp \ 8 | brains_tests.cpp \ 9 | cne_crossover_tests.cpp \ 10 | cne_mutation_tests.cpp \ 11 | neat_tests.cpp \ 12 | cgp_tests.cpp \ 13 | populations_smoke_tests.cpp 14 | 15 | HEADERS += \ 16 | dummy_domain.h 17 | -------------------------------------------------------------------------------- /domains/harvester/harvester.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = harvester 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | robot.cpp \ 12 | world.cpp \ 13 | world_map.cpp \ 14 | harvester.cpp 15 | 16 | HEADERS += \ 17 | robot.h \ 18 | world.h \ 19 | world_map.h \ 20 | harvester.h 21 | 22 | addLibrary(../../core) 23 | -------------------------------------------------------------------------------- /domains/pong/pong.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = pong 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | game.cpp \ 12 | pong.cpp \ 13 | ann_player.cpp \ 14 | test_players.cpp 15 | 16 | HEADERS += \ 17 | player.h \ 18 | game.h \ 19 | pong.h \ 20 | ann_player.h \ 21 | test_players.h 22 | 23 | addLibrary(../../core) 24 | -------------------------------------------------------------------------------- /experimental/2d_physics/camera_window.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "tool_window.h" 5 | 6 | #include 7 | 8 | class CameraWindow : public ToolWindow { 9 | public: 10 | explicit CameraWindow(QWidget* parent); 11 | 12 | private: 13 | void onSandboxChange(SandboxWindow* sandbox_window) override; 14 | 15 | private: 16 | physics_ui::CameraWidget* camera_widget_ = nullptr; 17 | }; 18 | -------------------------------------------------------------------------------- /experimental/2d_physics/new_sandbox_dialog.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class NewSandboxDialog; 8 | } 9 | 10 | class NewSandboxDialog : public QDialog { 11 | Q_OBJECT 12 | 13 | public: 14 | explicit NewSandboxDialog(QWidget* parent); 15 | ~NewSandboxDialog(); 16 | 17 | QString sceneName() const; 18 | 19 | private: 20 | Ui::NewSandboxDialog* ui = nullptr; 21 | }; 22 | -------------------------------------------------------------------------------- /experimental/2d_physics/touch_window.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "tool_window.h" 5 | 6 | #include 7 | 8 | class TouchWindow : public ToolWindow { 9 | public: 10 | explicit TouchWindow(QWidget* parent); 11 | 12 | private: 13 | void onSandboxChange(SandboxWindow* sandbox_window) override; 14 | 15 | private: 16 | physics_ui::TouchSensorWidget* sensor_widget_ = nullptr; 17 | }; 18 | -------------------------------------------------------------------------------- /third_party/gtest/gtest.pro: -------------------------------------------------------------------------------- 1 | 2 | QT -= core gui 3 | 4 | TARGET = gtest 5 | TEMPLATE = lib 6 | CONFIG += staticlib 7 | 8 | SOURCES += \ 9 | src/googletest/src/gtest-all.cc \ 10 | src/googlemock/src/gmock-all.cc 11 | 12 | HEADERS += \ 13 | gtest.h \ 14 | gmock.h 15 | 16 | INCLUDEPATH *= \ 17 | src/googletest \ 18 | src/googletest/include \ 19 | src/googlemock \ 20 | src/googlemock/include 21 | -------------------------------------------------------------------------------- /domains/cart_pole_ui/cart_pole_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = cart_pole_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | cart_pole_ui.cpp \ 12 | sandbox_window.cpp 13 | 14 | HEADERS += \ 15 | cart_pole_ui.h \ 16 | sandbox_window.h 17 | 18 | addLibrary(../cart_pole) 19 | addLibrary(../../core_ui) 20 | addLibrary(../../core) 21 | -------------------------------------------------------------------------------- /experimental/2d_physics/compass_window.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "tool_window.h" 5 | 6 | #include 7 | 8 | class CompassWindow : public ToolWindow { 9 | public: 10 | explicit CompassWindow(QWidget* parent); 11 | 12 | private: 13 | void onSandboxChange(SandboxWindow* sandbox_window) override; 14 | 15 | private: 16 | physics_ui::CompassWidget* sensor_widget_ = nullptr; 17 | }; 18 | -------------------------------------------------------------------------------- /tests/.output/CneGenesTest_Full_RNN_Gene_LoadSave.out: -------------------------------------------------------------------------------- 1 | { 2 | "rw": { 3 | "cols": 2, 4 | "rows": 2, 5 | "values": [ 6 | 100.0, 7 | 101.0, 8 | 102.0, 9 | 103.0 10 | ] 11 | }, 12 | "w": { 13 | "cols": 2, 14 | "rows": 4, 15 | "values": [ 16 | 0.0, 17 | 1.0, 18 | 2.0, 19 | 3.0, 20 | 4.0, 21 | 5.0, 22 | 6.0, 23 | 7.0 24 | ] 25 | } 26 | } -------------------------------------------------------------------------------- /third_party/box2d/box2d.pro: -------------------------------------------------------------------------------- 1 | 2 | QT -= core gui 3 | 4 | TARGET = box2d 5 | TEMPLATE = lib 6 | CONFIG += staticlib warn_off 7 | 8 | CONFIG += c++11 9 | 10 | CONFIG(debug, debug|release): DEFINES += DEBUG 11 | CONFIG(release, debug|release): DEFINES += NDEBUG 12 | 13 | HEADERS += \ 14 | $$files(src/Box2D/*.h, true) \ 15 | box2d.h 16 | 17 | SOURCES += \ 18 | $$files(src/Box2D/*.cpp, true) 19 | 20 | INCLUDEPATH *= src 21 | -------------------------------------------------------------------------------- /experimental/2d_physics/new_scene_dialog.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class NewSceneDialog; 10 | } 11 | 12 | class NewSceneDialog : public QDialog { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit NewSceneDialog(QWidget* parent, core::PropertySet* config); 17 | ~NewSceneDialog(); 18 | 19 | private: 20 | Ui::NewSceneDialog* ui = nullptr; 21 | }; 22 | -------------------------------------------------------------------------------- /tests/.output/PropertiesTest_ToJson.out: -------------------------------------------------------------------------------- 1 | { 2 | "acc_operator": "add", 3 | "custom": "{ 0, 0 }", 4 | "custom_init": "{ 1, -100 }", 5 | "extra_values": "{ 0, 10, 20, 30 }", 6 | "flag": "false", 7 | "layers": "{ }", 8 | "max_value": "100", 9 | "more_values": "{ 1, 2, 3 }", 10 | "name": " <\"El chupacabra\"> ", 11 | "resolution": "0.3", 12 | "values": "{ -1, 0, 0.1, 0.2, 1.001 }", 13 | "values_init": "{ -1, -2, -3 }" 14 | } -------------------------------------------------------------------------------- /populations/test_population/test_population.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = test_population 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | test_population.cpp \ 12 | population.cpp \ 13 | genotype.cpp \ 14 | brain.cpp 15 | 16 | HEADERS += \ 17 | test_population.h \ 18 | population.h \ 19 | genotype.h \ 20 | brain.h 21 | 22 | addLibrary(../../core) 23 | -------------------------------------------------------------------------------- /experimental/2d_physics/accelerometer_window.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "tool_window.h" 5 | 6 | #include 7 | 8 | class AccelerometerWindow : public ToolWindow { 9 | public: 10 | explicit AccelerometerWindow(QWidget* parent); 11 | 12 | private: 13 | void onSandboxChange(SandboxWindow* sandbox_window) override; 14 | 15 | private: 16 | physics_ui::AccelerometerWidget* sensor_widget_ = nullptr; 17 | }; 18 | -------------------------------------------------------------------------------- /third_party/tinyspline/tinyspline.pro: -------------------------------------------------------------------------------- 1 | 2 | QT -= core gui 3 | 4 | TARGET = tinyspline 5 | TEMPLATE = lib 6 | CONFIG += staticlib warn_off 7 | 8 | CONFIG += c++11 9 | 10 | CONFIG(debug, debug|release): DEFINES += DEBUG 11 | CONFIG(release, debug|release): DEFINES += NDEBUG 12 | 13 | HEADERS += \ 14 | $$files(repo/src/*.h, true) \ 15 | tinyspline.h 16 | 17 | SOURCES += \ 18 | $$files(repo/src/*.c, true) \ 19 | $$files(repo/src/*.cxx, true) 20 | -------------------------------------------------------------------------------- /domains/car_track_ui/car_track_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = car_track_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | domain_ui.cpp \ 12 | sandbox_window.cpp \ 13 | scene_ui.cpp 14 | 15 | HEADERS += \ 16 | domain_ui.h \ 17 | sandbox_window.h \ 18 | scene_ui.h 19 | 20 | addLibrary(../car_track) 21 | addLibrary(../../core_ui) 22 | addLibrary(../../core) 23 | -------------------------------------------------------------------------------- /domains/double_cart_pole_ui/double_cart_pole_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = double_cart_pole_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | double_cart_pole_ui.cpp \ 12 | sandbox_window.cpp 13 | 14 | HEADERS += \ 15 | double_cart_pole_ui.h \ 16 | sandbox_window.h 17 | 18 | addLibrary(../double_cart_pole) 19 | addLibrary(../../core_ui) 20 | addLibrary(../../core) 21 | -------------------------------------------------------------------------------- /domains/unicycle_ui/unicycle_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = unicycle_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | unicycle_ui.cpp \ 12 | sandbox_window.cpp \ 13 | scene_ui.cpp 14 | 15 | HEADERS += \ 16 | unicycle_ui.h \ 17 | sandbox_window.h \ 18 | scene_ui.h 19 | 20 | addLibrary(../unicycle) 21 | addLibrary(../../core_ui) 22 | addLibrary(../../core) 23 | -------------------------------------------------------------------------------- /populations/cgp/cgp.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = cgp 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | cgp.cpp \ 12 | population.cpp \ 13 | genotype.cpp \ 14 | brain.cpp 15 | 16 | HEADERS += \ 17 | cgp.h \ 18 | population.h \ 19 | genotype.h \ 20 | brain.h \ 21 | functions.h 22 | 23 | DISTFILES += \ 24 | functions_table.def 25 | 26 | addLibrary(../../core) 27 | -------------------------------------------------------------------------------- /domains/conquest/conquest.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = conquest 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | conquest.cpp \ 12 | board.cpp \ 13 | game.cpp \ 14 | ann_player.cpp \ 15 | test_players.cpp 16 | 17 | HEADERS += \ 18 | conquest.h \ 19 | board.h \ 20 | game.h \ 21 | player.h \ 22 | ann_player.h \ 23 | test_players.h 24 | 25 | addLibrary(../../core) 26 | -------------------------------------------------------------------------------- /domains/drone_track_ui/drone_track_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = drone_track_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | domain_ui.cpp \ 12 | sandbox_window.cpp \ 13 | scene_ui.cpp 14 | 15 | HEADERS += \ 16 | domain_ui.h \ 17 | sandbox_window.h \ 18 | scene_ui.h 19 | 20 | addLibrary(../drone_track) 21 | addLibrary(../../core_ui) 22 | addLibrary(../../core) 23 | -------------------------------------------------------------------------------- /domains/ballistics_ui/ballistics_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = ballistics_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | ballistics_ui.cpp \ 12 | sandbox_window.cpp \ 13 | scene_ui.cpp 14 | 15 | HEADERS += \ 16 | ballistics_ui.h \ 17 | sandbox_window.h \ 18 | scene_ui.h 19 | 20 | addLibrary(../ballistics) 21 | addLibrary(../../core_ui) 22 | addLibrary(../../core) 23 | -------------------------------------------------------------------------------- /domains/drone_follow_ui/drone_follow_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = drone_follow_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | domain_ui.cpp \ 12 | sandbox_window.cpp \ 13 | scene_ui.cpp 14 | 15 | HEADERS += \ 16 | domain_ui.h \ 17 | sandbox_window.h \ 18 | scene_ui.h 19 | 20 | addLibrary(../drone_follow) 21 | addLibrary(../../core_ui) 22 | addLibrary(../../core) 23 | -------------------------------------------------------------------------------- /domains/drone_vision_ui/drone_vision_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = drone_vision_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | domain_ui.cpp \ 12 | sandbox_window.cpp \ 13 | scene_ui.cpp 14 | 15 | HEADERS += \ 16 | domain_ui.h \ 17 | sandbox_window.h \ 18 | scene_ui.h 19 | 20 | addLibrary(../drone_vision) 21 | addLibrary(../../core_ui) 22 | addLibrary(../../core) 23 | -------------------------------------------------------------------------------- /tests/.output/SqliteTest_Select.out: -------------------------------------------------------------------------------- 1 | key = a 2 | flag = 1 3 | value = 1.0 4 | 5 | key = b 6 | flag = 2 7 | value = 2.2 8 | 9 | key = c 10 | flag = 3 11 | value = 3.3 12 | 13 | ---------------------------------- 14 | type = table 15 | name = foo 16 | tbl_name = foo 17 | rootpage = 2 18 | sql = CREATE TABLE foo(key text primary key, flag int default 0, value real) 19 | 20 | type = index 21 | name = sqlite_autoindex_foo_1 22 | tbl_name = foo 23 | rootpage = 3 24 | sql = NULL 25 | 26 | -------------------------------------------------------------------------------- /domains/tic_tac_toe/tic_tac_toe.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = tic_tac_toe 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | board.cpp \ 12 | tic_tac_toe.cpp \ 13 | ann_player.cpp \ 14 | test_players.cpp \ 15 | game_rules.cpp 16 | 17 | HEADERS += \ 18 | player.h \ 19 | board.h \ 20 | tic_tac_toe.h \ 21 | ann_player.h \ 22 | test_players.h \ 23 | game_rules.h 24 | 25 | addLibrary(../../core) 26 | -------------------------------------------------------------------------------- /tests/.output/CneGenesTest_LSTM_Lite_Gene_LoadSave.out: -------------------------------------------------------------------------------- 1 | { 2 | "lw": { 3 | "cols": 4, 4 | "rows": 2, 5 | "values": [ 6 | 100.0, 7 | 101.0, 8 | 102.0, 9 | 103.0, 10 | 104.0, 11 | 105.0, 12 | 106.0, 13 | 107.0 14 | ] 15 | }, 16 | "w": { 17 | "cols": 2, 18 | "rows": 4, 19 | "values": [ 20 | 0.0, 21 | 1.0, 22 | 2.0, 23 | 3.0, 24 | 4.0, 25 | 5.0, 26 | 6.0, 27 | 7.0 28 | ] 29 | } 30 | } -------------------------------------------------------------------------------- /experimental/replicators/experiment_window.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ExperimentWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 540 10 | 403 11 | 12 | 13 | 14 | Frame 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/core/core.pro: -------------------------------------------------------------------------------- 1 | 2 | SOURCES += \ 3 | intersection_tests.cpp \ 4 | main.cpp \ 5 | database_tests.cpp \ 6 | exception_tests.cpp \ 7 | io_utils_tests.cpp \ 8 | properties_tests.cpp \ 9 | format_tests.cpp \ 10 | compressed_fitness_tests.cpp \ 11 | parallel_for_tests.cpp \ 12 | properties_variant_tests.cpp \ 13 | misc_tests.cpp \ 14 | selection_algorithms_tests.cpp \ 15 | sim/track_tests.cpp \ 16 | tournament_tests.cpp 17 | 18 | include(../tests_common.pri) 19 | -------------------------------------------------------------------------------- /tests/bindings/python/darwin_test_utils.py: -------------------------------------------------------------------------------- 1 | 2 | import os 3 | 4 | def reserve_universe(filename): 5 | """deletes the file if it exists, then returns the full path""" 6 | darwin_home_path = os.getenv('DARWIN_HOME_PATH') 7 | if darwin_home_path is None: 8 | raise RuntimeError('DARWIN_HOME_PATH must be set before running the tests') 9 | full_path = os.path.abspath(os.path.join(darwin_home_path, filename)) 10 | if os.path.exists(full_path): 11 | os.remove(full_path) 12 | return full_path 13 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Code reviews 7 | 8 | All submissions, including submissions by project members, require review. We 9 | use GitHub pull requests for this purpose. Consult 10 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 11 | information on using pull requests. 12 | 13 | ## Coding Style 14 | 15 | See the [coding style](docs/coding_style.md) notes. 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gtest"] 2 | path = third_party/gtest/src 3 | url = https://github.com/tlemo/googletest.git 4 | [submodule "pugixml"] 5 | path = third_party/pugixml/src 6 | url = https://github.com/tlemo/pugixml.git 7 | [submodule "box2d"] 8 | path = third_party/box2d/src 9 | url = https://github.com/tlemo/Box2D.git 10 | [submodule "tinyspline"] 11 | path = third_party/tinyspline/repo 12 | url = https://github.com/tlemo/tinyspline.git 13 | [submodule "pybind11"] 14 | path = third_party/pybind11/repo 15 | url = https://github.com/tlemo/pybind11.git 16 | -------------------------------------------------------------------------------- /tests/.output/JsonTest_Examples.out: -------------------------------------------------------------------------------- 1 | {"everything":42} 2 | 42.99 3 | {"answer":{"everything":42},"happy":true,"list":[1,0,2],"name":"Niels","nothing":null,"object":{"currency":"USD","value":42.99},"pi":3.141} 4 | { 5 | "answer": { 6 | "everything": 42 7 | }, 8 | "happy": true, 9 | "list": [ 10 | 1, 11 | 0, 12 | 2 13 | ], 14 | "name": "Niels", 15 | "nothing": null, 16 | "object": { 17 | "currency": "USD", 18 | "value": "42.99" 19 | }, 20 | "pi": 3.141 21 | } 22 | [] 23 | null 24 | {} 25 | [["currency","USD"],["value",42.99]] 26 | -------------------------------------------------------------------------------- /populations/cne/cne.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = cne 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | cne.cpp \ 12 | genetic_operators.cpp \ 13 | feedforward.cpp \ 14 | lstm.cpp \ 15 | rnn.cpp \ 16 | full_rnn.cpp \ 17 | lstm_lite.cpp 18 | 19 | HEADERS += \ 20 | cne.h \ 21 | population.h \ 22 | feedforward.h \ 23 | lstm.h \ 24 | rnn.h \ 25 | full_rnn.h \ 26 | brain.h \ 27 | lstm_lite.h \ 28 | genotype.h 29 | 30 | addLibrary(../../core) 31 | -------------------------------------------------------------------------------- /experimental/2d_physics/new_scene_dialog.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "new_scene_dialog.h" 3 | #include "ui_new_scene_dialog.h" 4 | 5 | NewSceneDialog::NewSceneDialog(QWidget* parent, core::PropertySet* config) 6 | : QDialog(parent, 7 | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), 8 | ui(new Ui::NewSceneDialog) { 9 | ui->setupUi(this); 10 | ui->properties->addPropertiesSection("Scene Configuration", config); 11 | ui->properties->autoSizeColumns(); 12 | } 13 | 14 | NewSceneDialog::~NewSceneDialog() { 15 | delete ui; 16 | } 17 | -------------------------------------------------------------------------------- /experimental/replicators/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "main_window.h" 3 | #include "tests.h" 4 | 5 | #include 6 | 7 | #include 8 | 9 | int main(int argc, char* argv[]) { 10 | QApplication app(argc, argv); 11 | Q_INIT_RESOURCE(resources); 12 | 13 | #ifndef DARWIN_OS_WASM 14 | pp::ParallelForSupport::init(nullptr); 15 | #endif 16 | 17 | #ifndef NDEBUG 18 | experimental::replicators::tests::runTests(); 19 | #endif 20 | 21 | experimental::replicators::MainWindow main_window; 22 | main_window.show(); 23 | return app.exec(); 24 | } 25 | -------------------------------------------------------------------------------- /domains/pong_ui/pong_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui widgets 5 | 6 | TARGET = pong_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | pong_widget.cpp \ 12 | game_widget.cpp \ 13 | new_sandbox_dialog.cpp \ 14 | pong_ui.cpp 15 | 16 | HEADERS += \ 17 | pong_widget.h \ 18 | game_widget.h \ 19 | human_player.h \ 20 | pong_ui.h \ 21 | new_sandbox_dialog.h 22 | 23 | FORMS += \ 24 | game_widget.ui \ 25 | new_sandbox_dialog.ui 26 | 27 | addLibrary(../pong) 28 | addLibrary(../../core_ui) 29 | addLibrary(../../core) 30 | -------------------------------------------------------------------------------- /domains/harvester_ui/harvester_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = harvester_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | new_sandbox_dialog.cpp \ 12 | harvester_ui.cpp \ 13 | world_widget.cpp \ 14 | sandbox_window.cpp 15 | 16 | HEADERS += \ 17 | new_sandbox_dialog.h \ 18 | harvester_ui.h \ 19 | world_widget.h \ 20 | sandbox_window.h 21 | 22 | FORMS += \ 23 | new_sandbox_dialog.ui \ 24 | sandbox_window.ui 25 | 26 | addLibrary(../harvester) 27 | addLibrary(../../core_ui) 28 | addLibrary(../../core) 29 | -------------------------------------------------------------------------------- /darwin.pro: -------------------------------------------------------------------------------- 1 | 2 | TEMPLATE = subdirs 3 | 4 | SUBDIRS += \ 5 | bindings \ 6 | core \ 7 | core_ui \ 8 | populations \ 9 | domains \ 10 | registry \ 11 | darwin_studio \ 12 | tests \ 13 | experimental \ 14 | third_party 15 | 16 | core.depends = third_party 17 | core_ui.depends = core 18 | populations.depends = core core_ui 19 | domains.depends = core core_ui 20 | registry.depends = core populations domains 21 | darwin_studio.depends = core core_ui registry 22 | tests.depends = core registry third_party 23 | experimental.depends = core registry third_party 24 | bindings.depends = core registry 25 | -------------------------------------------------------------------------------- /experimental/replicators/new_experiment_dialog.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class NewExperimentDialog; 8 | } 9 | 10 | namespace experimental::replicators { 11 | 12 | class NewExperimentDialog : public QDialog { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit NewExperimentDialog(QWidget* parent, const char* title); 17 | ~NewExperimentDialog(); 18 | 19 | void done(int result) override; 20 | 21 | signals: 22 | void sigNewExperiment(QString species_name); 23 | 24 | private: 25 | Ui::NewExperimentDialog* ui = nullptr; 26 | }; 27 | 28 | } // namespace experimental::replicators 29 | -------------------------------------------------------------------------------- /tests/.output/PropertiesVariantTest_EmbeddedToJson.out: -------------------------------------------------------------------------------- 1 | { 2 | "another_variant": { 3 | "basic": { 4 | "bool_flag": "false", 5 | "max_value": "100" 6 | }, 7 | "empty": {}, 8 | "extra": { 9 | "name": "Darwin", 10 | "scale": "1", 11 | "values": "{ }" 12 | }, 13 | "tag": "empty" 14 | }, 15 | "start_value": "0", 16 | "test_variant": { 17 | "basic": { 18 | "bool_flag": "false", 19 | "max_value": "100" 20 | }, 21 | "empty": {}, 22 | "extra": { 23 | "name": "Darwin", 24 | "scale": "1", 25 | "values": "{ }" 26 | }, 27 | "tag": "basic" 28 | } 29 | } -------------------------------------------------------------------------------- /tests/tests_common.pri: -------------------------------------------------------------------------------- 1 | 2 | include(../common.pri) 3 | 4 | TEMPLATE = app 5 | CONFIG += console 6 | CONFIG += thread 7 | CONFIG -= app_bundle 8 | CONFIG -= qt 9 | CONFIG += link_prl 10 | 11 | DEFINES += TEST_OUTPUT_PATH=\\\"$$PWD/.output\\\" 12 | DEFINES += TEST_INPUT_PATH=\\\"$$PWD/.input\\\" 13 | DEFINES += TEST_TEMP_PATH=\\\"$$PWD/.temp\\\" 14 | DEFINES += TEST_PYTHON_SUITE=\\\"$$PWD/bindings/python\\\" 15 | 16 | INCLUDEPATH += $$PWD/../third_party/gtest/src/googletest/include 17 | INCLUDEPATH += $$PWD/../third_party/gtest/src/googlemock/include 18 | 19 | addLibrary(../../registry) 20 | addLibrary(../../core) 21 | addLibrary(../../third_party/gtest) 22 | -------------------------------------------------------------------------------- /domains/tic_tac_toe_ui/tic_tac_toe_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui widgets 5 | 6 | TARGET = tic_tac_toe_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | tic_tac_toe_ui.cpp \ 12 | new_sandbox_dialog.cpp \ 13 | sandbox_window.cpp \ 14 | board_widget.cpp \ 15 | game.cpp 16 | 17 | HEADERS += \ 18 | tic_tac_toe_ui.h \ 19 | new_sandbox_dialog.h \ 20 | sandbox_window.h \ 21 | board_widget.h \ 22 | human_player.h \ 23 | game.h 24 | 25 | FORMS += \ 26 | new_sandbox_dialog.ui \ 27 | sandbox_window.ui 28 | 29 | addLibrary(../tic_tac_toe) 30 | addLibrary(../../core_ui) 31 | addLibrary(../../core) 32 | -------------------------------------------------------------------------------- /domains/conquest_ui/conquest_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = conquest_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | SOURCES += \ 11 | new_sandbox_dialog.cpp \ 12 | conquest_ui.cpp \ 13 | board_widget.cpp \ 14 | game_stats_window.cpp \ 15 | game_window.cpp 16 | 17 | HEADERS += \ 18 | new_sandbox_dialog.h \ 19 | conquest_ui.h \ 20 | board_widget.h \ 21 | game_stats_window.h \ 22 | game_window.h 23 | 24 | FORMS += \ 25 | new_sandbox_dialog.ui \ 26 | game_stats_window.ui \ 27 | game_window.ui 28 | 29 | addLibrary(../conquest) 30 | addLibrary(../../core_ui) 31 | addLibrary(../../core) 32 | -------------------------------------------------------------------------------- /experimental/2d_physics/compass_window.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "compass_window.h" 3 | #include "sandbox_window.h" 4 | 5 | #include 6 | 7 | CompassWindow::CompassWindow(QWidget* parent) : ToolWindow(parent) { 8 | setWindowTitle("Compass"); 9 | setMinimumSize(64, 64); 10 | sensor_widget_ = new physics_ui::CompassWidget(this); 11 | auto layout = new QVBoxLayout(this); 12 | layout->setContentsMargins(0, 0, 0, 0); 13 | layout->addWidget(sensor_widget_); 14 | } 15 | 16 | void CompassWindow::onSandboxChange(SandboxWindow* sandbox_window) { 17 | auto scene = sandbox_window ? sandbox_window->scenePackage().scene.get() : nullptr; 18 | sensor_widget_->setSensor(scene ? scene->compass() : nullptr); 19 | } 20 | -------------------------------------------------------------------------------- /experimental/2d_physics/touch_window.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "touch_window.h" 3 | #include "sandbox_window.h" 4 | 5 | #include 6 | 7 | TouchWindow::TouchWindow(QWidget* parent) : ToolWindow(parent) { 8 | setWindowTitle("Touch"); 9 | setMinimumSize(64, 64); 10 | sensor_widget_ = new physics_ui::TouchSensorWidget(this); 11 | auto layout = new QVBoxLayout(this); 12 | layout->setContentsMargins(0, 0, 0, 0); 13 | layout->addWidget(sensor_widget_); 14 | } 15 | 16 | void TouchWindow::onSandboxChange(SandboxWindow* sandbox_window) { 17 | auto scene = sandbox_window ? sandbox_window->scenePackage().scene.get() : nullptr; 18 | sensor_widget_->setSensor(scene ? scene->touchSensor() : nullptr); 19 | } 20 | -------------------------------------------------------------------------------- /experimental/2d_physics/camera_window.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "camera_window.h" 3 | #include "sandbox_window.h" 4 | 5 | #include 6 | 7 | CameraWindow::CameraWindow(QWidget* parent) : ToolWindow(parent) { 8 | setWindowTitle("Camera"); 9 | setMinimumSize(64, 64); 10 | setMaximumSize(4096, 64); 11 | camera_widget_ = new physics_ui::CameraWidget(this); 12 | auto layout = new QVBoxLayout(this); 13 | layout->setContentsMargins(0, 0, 0, 0); 14 | layout->addWidget(camera_widget_); 15 | } 16 | 17 | void CameraWindow::onSandboxChange(SandboxWindow* sandbox_window) { 18 | auto scene = sandbox_window ? sandbox_window->scenePackage().scene.get() : nullptr; 19 | camera_widget_->setCamera(scene ? scene->camera() : nullptr); 20 | } 21 | -------------------------------------------------------------------------------- /experimental/2d_physics/accelerometer_window.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "accelerometer_window.h" 3 | #include "sandbox_window.h" 4 | 5 | #include 6 | 7 | AccelerometerWindow::AccelerometerWindow(QWidget* parent) : ToolWindow(parent) { 8 | setWindowTitle("Accelerometer"); 9 | setMinimumSize(64, 64); 10 | sensor_widget_ = new physics_ui::AccelerometerWidget(this); 11 | auto layout = new QVBoxLayout(this); 12 | layout->setContentsMargins(0, 0, 0, 0); 13 | layout->addWidget(sensor_widget_); 14 | } 15 | 16 | void AccelerometerWindow::onSandboxChange(SandboxWindow* sandbox_window) { 17 | auto scene = sandbox_window ? sandbox_window->scenePackage().scene.get() : nullptr; 18 | sensor_widget_->setSensor(scene ? scene->accelerometer() : nullptr); 19 | } 20 | -------------------------------------------------------------------------------- /experimental/2d_physics/new_sandbox_dialog.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "new_sandbox_dialog.h" 3 | #include "sandbox_factory.h" 4 | #include "ui_new_sandbox_dialog.h" 5 | 6 | NewSandboxDialog::NewSandboxDialog(QWidget* parent) 7 | : QDialog(parent, 8 | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), 9 | ui(new Ui::NewSandboxDialog) { 10 | ui->setupUi(this); 11 | 12 | for (const auto& [name, factory] : scenesRegistry()) { 13 | ui->scene_name->addItem(QString::fromStdString(name)); 14 | } 15 | 16 | ui->scene_name->setFocus(); 17 | } 18 | 19 | NewSandboxDialog::~NewSandboxDialog() { 20 | delete ui; 21 | } 22 | 23 | QString NewSandboxDialog::sceneName() const { 24 | return ui->scene_name->currentText(); 25 | } 26 | -------------------------------------------------------------------------------- /tests/.output/CneGenesTest_LSTM_Gene_LoadSave.out: -------------------------------------------------------------------------------- 1 | { 2 | "lw": { 3 | "cols": 12, 4 | "rows": 2, 5 | "values": [ 6 | 100.0, 7 | 101.0, 8 | 102.0, 9 | 103.0, 10 | 104.0, 11 | 105.0, 12 | 106.0, 13 | 107.0, 14 | 108.0, 15 | 109.0, 16 | 110.0, 17 | 111.0, 18 | 112.0, 19 | 113.0, 20 | 114.0, 21 | 115.0, 22 | 116.0, 23 | 117.0, 24 | 118.0, 25 | 119.0, 26 | 120.0, 27 | 121.0, 28 | 122.0, 29 | 123.0 30 | ] 31 | }, 32 | "w": { 33 | "cols": 2, 34 | "rows": 4, 35 | "values": [ 36 | 0.0, 37 | 1.0, 38 | 2.0, 39 | 3.0, 40 | 4.0, 41 | 5.0, 42 | 6.0, 43 | 7.0 44 | ] 45 | } 46 | } -------------------------------------------------------------------------------- /tests/.output/JsonTest_ForEach.out: -------------------------------------------------------------------------------- 1 | > {"everything":42} 2 | > true 3 | > [1,0,2] 4 | > "Niels" 5 | > null 6 | > {"currency":"USD","value":"42.99"} 7 | > 3.141 8 | ------------------------------------- 9 | > {"everything":42} 10 | > true 11 | > [1,0,2] 12 | > "Niels" 13 | > null 14 | > {"currency":"USD","value":"42.99"} 15 | > 3.141 16 | ------------------------------------- 17 | 'answer'='{"everything":42}' 18 | 'happy'='true' 19 | 'list'='[1,0,2]' 20 | 'name'='"Niels"' 21 | 'nothing'='null' 22 | 'object'='{"currency":"USD","value":"42.99"}' 23 | 'pi'='3.141' 24 | ------------------------------------- 25 | 'answer'='{"everything":42}' 26 | 'happy'='true' 27 | 'list'='[1,0,2]' 28 | 'name'='"Niels"' 29 | 'nothing'='null' 30 | 'object'='{"currency":"USD","value":"42.99"}' 31 | 'pi'='3.141' 32 | -------------------------------------------------------------------------------- /tests/.output/PropertiesTest_SetValuesDirect.out: -------------------------------------------------------------------------------- 1 | max_value = '5' 2 | resolution = '10.5' 3 | name = ' *** lemo 123 *** ' 4 | flag = 'true' 5 | acc_operator = 'multiply' 6 | layers = '{ 16, 8, 4 }' 7 | values = '{ -1, 0, 0.1, 0.2, 1.001 }' 8 | more_values = '{ }' 9 | extra_values = '{ 0, 10, 20, 30 }' 10 | values_init = '{ -1, -2, -3 }' 11 | custom = '{ 64, 16 }' 12 | custom_init = '{ 1, -100 }' 13 | 14 | ------------------------------- 15 | max_value = '100' 16 | resolution = '0.3' 17 | name = ' <"El chupacabra"> ' 18 | flag = 'false' 19 | acc_operator = 'add' 20 | layers = '{ }' 21 | values = '{ -1, 0, 0.1, 0.2, 1.001 }' 22 | more_values = '{ 1, 2, 3 }' 23 | extra_values = '{ 0, 10, 20, 30 }' 24 | values_init = '{ -1, -2, -3 }' 25 | custom = '{ 0, 0 }' 26 | custom_init = '{ 1, -100 }' 27 | -------------------------------------------------------------------------------- /darwin_studio/player.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "player.h" 16 | #include "game.h" 17 | 18 | namespace pong {} // namespace pong 19 | -------------------------------------------------------------------------------- /registry/registry.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | namespace registry { 18 | 19 | void init(); 20 | 21 | } // namespace registry 22 | -------------------------------------------------------------------------------- /core/ann_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "ann_utils.h" 16 | 17 | namespace ann { 18 | 19 | Config g_config; 20 | 21 | } // namespace ann 22 | -------------------------------------------------------------------------------- /core/parallel_for_each.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | namespace pp { 16 | 17 | thread_local bool g_inside_parallel_for = false; 18 | 19 | } // namespace pp 20 | -------------------------------------------------------------------------------- /registry/registry_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | namespace registry_ui { 18 | 19 | void init(); 20 | 21 | } // namespace registry_ui 22 | -------------------------------------------------------------------------------- /tests/.output/PropertiesTest_Const.out: -------------------------------------------------------------------------------- 1 | max_value = '100' ['100'] # Maximum value 2 | resolution = '0.3' ['0.3'] # Display resolution 3 | name = ' <"El chupacabra"> ' [' <"El chupacabra"> '] # Name 4 | flag = 'false' ['false'] # A boolean flag 5 | acc_operator = 'add' ['add'] # Enumeration 6 | layers = '{ }' ['{ }'] # Hidden layer sizes 7 | values = '{ -1, 0, 0.1, 0.2, 1.001 }' ['{ -1, 0, 0.1, 0.2, 1.001 }'] # Vector of real values 8 | more_values = '{ 1, 2, 3 }' ['{ 1, 2, 3 }'] # More real values ... 9 | extra_values = '{ 0, 10, 20, 30 }' ['{ 0, 10, 20, 30 }'] # Even more real values ... 10 | values_init = '{ -1, -2, -3 }' ['{ -1, -2, -3 }'] # Almost natural use of initializer lists 11 | custom = '{ 0, 0 }' ['{ 0, 0 }'] # A simple custom type 12 | custom_init = '{ 1, -100 }' ['{ 1, -100 }'] # Initialized custom type 13 | -------------------------------------------------------------------------------- /tests/.output/PropertiesTest_Enumerate.out: -------------------------------------------------------------------------------- 1 | name: 'max_value' 2 | description: 'Maximum value' 3 | 4 | name: 'resolution' 5 | description: 'Display resolution' 6 | 7 | name: 'name' 8 | description: 'Name' 9 | 10 | name: 'flag' 11 | description: 'A boolean flag' 12 | 13 | name: 'acc_operator' 14 | description: 'Enumeration' 15 | 16 | name: 'layers' 17 | description: 'Hidden layer sizes' 18 | 19 | name: 'values' 20 | description: 'Vector of real values' 21 | 22 | name: 'more_values' 23 | description: 'More real values ...' 24 | 25 | name: 'extra_values' 26 | description: 'Even more real values ...' 27 | 28 | name: 'values_init' 29 | description: 'Almost natural use of initializer lists' 30 | 31 | name: 'custom' 32 | description: 'A simple custom type' 33 | 34 | name: 'custom_init' 35 | description: 'Initialized custom type' 36 | 37 | -------------------------------------------------------------------------------- /experimental/replicators/tests.h: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | namespace experimental::replicators::tests { 18 | 19 | void runTests(); 20 | 21 | } // namespace experimental::replicators::tests 22 | -------------------------------------------------------------------------------- /tests/bindings/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | int main(int argc, char* argv[]) { 18 | ::testing::InitGoogleTest(&argc, argv); 19 | return RUN_ALL_TESTS(); 20 | } 21 | -------------------------------------------------------------------------------- /tests/third_party/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | int main(int argc, char* argv[]) { 18 | ::testing::InitGoogleTest(&argc, argv); 19 | return RUN_ALL_TESTS(); 20 | } 21 | -------------------------------------------------------------------------------- /experimental/2d_physics/sandbox_factory.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | using namespace std; 11 | 12 | struct SandboxScenePackage { 13 | unique_ptr scene; 14 | unique_ptr scene_ui; 15 | }; 16 | 17 | class SandboxFactory : public core::ModuleFactory { 18 | public: 19 | // config may be nullptr (for no configuration or default configuration) 20 | virtual SandboxScenePackage createScenePackage(const core::PropertySet* config) = 0; 21 | 22 | virtual unique_ptr defaultConfig() const { return nullptr; } 23 | }; 24 | 25 | inline auto& scenesRegistry() { 26 | static core::ImplementationsSet registry; 27 | return registry; 28 | } 29 | -------------------------------------------------------------------------------- /domains/pong_ui/pong_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace pong_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace pong_ui 28 | -------------------------------------------------------------------------------- /tests/core/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include 18 | 19 | int main(int argc, char* argv[]) { 20 | pp::ParallelForSupport::init(nullptr); 21 | 22 | testing::InitGoogleTest(&argc, argv); 23 | return RUN_ALL_TESTS(); 24 | } 25 | -------------------------------------------------------------------------------- /third_party/box2d/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2017 Erin Catto http://www.box2d.org 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /domains/car_track_ui/domain_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace car_track_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace car_track_ui 28 | -------------------------------------------------------------------------------- /domains/conquest_ui/conquest_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace conquest_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace conquest_ui 28 | -------------------------------------------------------------------------------- /domains/unicycle_ui/unicycle_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace unicycle_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace unicycle_ui 28 | -------------------------------------------------------------------------------- /domains/cart_pole_ui/cart_pole_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace cart_pole_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace cart_pole_ui 28 | -------------------------------------------------------------------------------- /domains/harvester_ui/harvester_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace harvester_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace harvester_ui 28 | -------------------------------------------------------------------------------- /bindings/python/python.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | TARGET=darwin 5 | TEMPLATE = lib 6 | CONFIG -= qt 7 | CONFIG += link_prl 8 | 9 | # disable the 'lib' shared library prefix and version symlinks 10 | CONFIG += plugin no_plugin_name_prefix 11 | 12 | # avoid the MSVC-style extra debug/release subdirectories in Windows builds 13 | CONFIG -= debug_and_release 14 | 15 | win32: QMAKE_EXTENSION_SHLIB = pyd 16 | 17 | SOURCES += \ 18 | python_bindings.cpp 19 | 20 | HEADERS += \ 21 | python_bindings.h 22 | 23 | # include path for Python headers 24 | INCLUDEPATH += $$(PYTHON_INCLUDE) 25 | 26 | # Python library path (should only be needed on Windows) 27 | PYTHON_LIBS = $$(PYTHON_LIBS) 28 | !isEmpty(PYTHON_LIBS) { 29 | LIBS += "-L$$PYTHON_LIBS" 30 | } 31 | 32 | addLibrary(../../registry) 33 | addLibrary(../../core) 34 | 35 | # default rules for deployment 36 | unix { 37 | target.path = /usr/lib 38 | } 39 | !isEmpty(target.path): INSTALLS += target 40 | -------------------------------------------------------------------------------- /domains/ballistics_ui/ballistics_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace ballistics_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace ballistics_ui 28 | -------------------------------------------------------------------------------- /domains/drone_follow_ui/domain_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace drone_follow_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace drone_follow_ui 28 | -------------------------------------------------------------------------------- /domains/drone_track_ui/domain_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace drone_track_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace drone_track_ui 28 | -------------------------------------------------------------------------------- /domains/drone_vision_ui/domain_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace drone_vision_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace drone_vision_ui 28 | -------------------------------------------------------------------------------- /domains/tic_tac_toe_ui/tic_tac_toe_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace tic_tac_toe_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace tic_tac_toe_ui 28 | -------------------------------------------------------------------------------- /domains/double_cart_pole_ui/double_cart_pole_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace double_cart_pole_ui { 20 | 21 | void init(); 22 | 23 | class Factory : public darwin::DomainUiFactory { 24 | QWidget* newSandboxWindow() override; 25 | }; 26 | 27 | } // namespace double_cart_pole_ui 28 | -------------------------------------------------------------------------------- /tests/.output/PugiXmlTest_Create.out: -------------------------------------------------------------------------------- 1 | default format options 2 | ---------------------------- 3 | 4 | 5 | 6 | 7 | 8 | ... this is the content... 9 | 1234567890 10 | 11 | 12 | 13 | custom format options 14 | ---------------------------- 15 | 16 | 18 | 28 | 29 | 30 | ... this is the content... 31 | 1234567890 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /tests/bindings/python/test_domain.py: -------------------------------------------------------------------------------- 1 | 2 | import unittest 3 | import darwin 4 | 5 | class DomainTestCase(unittest.TestCase): 6 | def test_config_assignment(self): 7 | d1 = darwin.Domain('pong') 8 | d2 = darwin.Domain('tic_tac_toe') 9 | 10 | # this is ok, we can bind to config instances 11 | c = d1.config 12 | c = d2.config 13 | 14 | # ... but we can't set the config 15 | with self.assertRaises(AttributeError): 16 | d1.config = d2.config 17 | 18 | # ... even self assignments 19 | with self.assertRaises(AttributeError): 20 | d1.config = d1.config 21 | 22 | # ... or setting to None 23 | with self.assertRaises(AttributeError): 24 | d1.config = None 25 | 26 | def test_config_lifetime(self): 27 | d = darwin.Domain('conquest') 28 | config = d.config 29 | d = None 30 | self.assertTrue(repr(config)) 31 | 32 | 33 | if __name__ == '__main__': 34 | unittest.main() 35 | -------------------------------------------------------------------------------- /experimental/replicators/new_experiment_dialog.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "new_experiment_dialog.h" 3 | #include "ui_new_experiment_dialog.h" 4 | #include "replicators.h" 5 | 6 | namespace experimental::replicators { 7 | 8 | NewExperimentDialog::NewExperimentDialog(QWidget* parent, const char* title) 9 | : QDialog(parent, 10 | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), 11 | ui(new Ui::NewExperimentDialog) { 12 | ui->setupUi(this); 13 | setWindowTitle(title); 14 | 15 | for (const auto& [name, factory] : *registry()) { 16 | ui->species_name->addItem(QString::fromStdString(name)); 17 | } 18 | 19 | ui->species_name->setFocus(); 20 | } 21 | 22 | NewExperimentDialog::~NewExperimentDialog() { 23 | delete ui; 24 | } 25 | 26 | void NewExperimentDialog::done(int result) { 27 | if (result == QDialog::Accepted) { 28 | emit sigNewExperiment(ui->species_name->currentText()); 29 | } 30 | QDialog::done(result); 31 | } 32 | 33 | } // namespace experimental::replicators 34 | -------------------------------------------------------------------------------- /domains/pong/test_players.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "player.h" 18 | 19 | namespace pong { 20 | 21 | // an "easy" handcrafted player: attempts to track the vertical ball position 22 | class HandcraftedPlayer : public Player { 23 | Action action() override; 24 | string name() const override { return "Handcrafted"; } 25 | }; 26 | 27 | } // namespace pong 28 | -------------------------------------------------------------------------------- /core/sim/compass.cpp: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "compass.h" 16 | 17 | #include 18 | 19 | namespace sim { 20 | 21 | Compass::Compass(b2Body* body) : body_(body) {} 22 | 23 | const b2Vec2 Compass::heading() const { 24 | const auto v = body_->GetLocalVector(b2Vec2(0, 1)); 25 | CHECK(!isnan(v.x)); 26 | CHECK(!isnan(v.y)); 27 | return v; 28 | } 29 | 30 | } // namespace sim 31 | -------------------------------------------------------------------------------- /experimental/2d_physics/main_window.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "sandbox_factory.h" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | using namespace std; 11 | 12 | namespace Ui { 13 | class MainWindow; 14 | } 15 | 16 | class ToolWindow; 17 | class SandboxWindow; 18 | 19 | class MainWindow : public QMainWindow { 20 | Q_OBJECT 21 | 22 | public: 23 | MainWindow(); 24 | ~MainWindow() override; 25 | 26 | void updateToolWindows(); 27 | void onSandboxChange(SandboxWindow* sandbox_window); 28 | 29 | private slots: 30 | void on_action_new_sandbox_triggered(); 31 | void on_tabs_tabCloseRequested(int index); 32 | void on_tabs_currentChanged(int index); 33 | 34 | private: 35 | void dockWindow(ToolWindow* tool_window, 36 | Qt::DockWidgetAreas allowed_areas, 37 | Qt::DockWidgetArea area); 38 | 39 | private: 40 | Ui::MainWindow* ui = nullptr; 41 | unique_ptr sandbox_factory_; 42 | vector tool_windows_; 43 | }; 44 | -------------------------------------------------------------------------------- /core_ui/core_ui.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../common.pri) 3 | 4 | QT += core gui charts widgets 5 | 6 | TARGET = core_ui 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | 10 | DEFINES += QT_DEPRECATED_WARNINGS 11 | 12 | SOURCES += \ 13 | canvas.cpp \ 14 | properties_widget.cpp \ 15 | sim/box2d_renderer.cpp \ 16 | sim/box2d_sandbox_dialog.cpp \ 17 | sim/box2d_sandbox_window.cpp \ 18 | sim/box2d_widget.cpp \ 19 | sim/accelerometer_widget.cpp \ 20 | sim/camera_widget.cpp \ 21 | sim/compass_widget.cpp \ 22 | sim/touch_widget.cpp 23 | 24 | HEADERS += \ 25 | canvas.h \ 26 | properties_widget.h \ 27 | sim/box2d_renderer.h \ 28 | sim/box2d_sandbox_dialog.h \ 29 | sim/box2d_sandbox_window.h \ 30 | sim/box2d_widget.h \ 31 | sim/accelerometer_widget.h \ 32 | sim/camera_widget.h \ 33 | sim/compass_widget.h \ 34 | sim/touch_widget.h 35 | 36 | FORMS += \ 37 | sim/box2d_sandbox_dialog.ui \ 38 | sim/box2d_sandbox_window.ui 39 | 40 | RESOURCES += \ 41 | resources.qrc 42 | 43 | addLibrary(../core) 44 | -------------------------------------------------------------------------------- /darwin_studio/output_window.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | namespace Ui { 21 | class OutputWindow; 22 | } 23 | 24 | class OutputWindow : public QFrame { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit OutputWindow(QWidget* parent = nullptr); 29 | ~OutputWindow(); 30 | 31 | void consoleOutput(const QString& output); 32 | 33 | private: 34 | Ui::OutputWindow* ui; 35 | }; 36 | -------------------------------------------------------------------------------- /core/sim/compass.h: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace sim { 20 | 21 | //! Tracks the local direction of the global "North" (x=0, y=1) vector 22 | class Compass { 23 | public: 24 | Compass(b2Body* body); 25 | 26 | b2Body* body() const { return body_; } 27 | 28 | const b2Vec2 heading() const; 29 | 30 | private: 31 | b2Body* body_ = nullptr; 32 | }; 33 | 34 | } // namespace sim 35 | -------------------------------------------------------------------------------- /domains/domains.pro: -------------------------------------------------------------------------------- 1 | 2 | TEMPLATE = subdirs 3 | 4 | SUBDIRS += \ 5 | pong \ 6 | pong_ui \ 7 | conquest \ 8 | conquest_ui \ 9 | harvester \ 10 | harvester_ui \ 11 | max \ 12 | tic_tac_toe \ 13 | tic_tac_toe_ui \ 14 | car_track \ 15 | car_track_ui \ 16 | cart_pole \ 17 | cart_pole_ui \ 18 | double_cart_pole \ 19 | double_cart_pole_ui \ 20 | unicycle \ 21 | unicycle_ui \ 22 | drone_follow \ 23 | drone_follow_ui \ 24 | drone_vision \ 25 | drone_vision_ui \ 26 | drone_track \ 27 | drone_track_ui \ 28 | ballistics \ 29 | ballistics_ui \ 30 | test_domain 31 | 32 | pong_ui.depends = pong 33 | tic_tac_toe_ui.depends = tic_tac_toe 34 | conquest_ui.depends = conquest 35 | harvester_ui.depends = harvester 36 | cart_pole_ui.depends = cart_pole 37 | double_cart_pole_ui.depends = double_cart_pole 38 | unicycle_ui.depends = unicycle 39 | ballistics_ui.depends = ballistics 40 | drone_vision_ui.depends = drone_vision 41 | drone_follow_ui.depends = drone_follow 42 | drone_track_ui.depends = drone_track 43 | car_track_ui.depends = car_track 44 | -------------------------------------------------------------------------------- /core/platform_abstraction_layer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // portable abstractions for platform specific code 16 | 17 | #pragma once 18 | 19 | #include 20 | using namespace std; 21 | 22 | namespace pal { 23 | 24 | //! Returns user home directory path 25 | string userHomePath(); 26 | 27 | //! Returns true if AVX2 is detected 28 | bool detectAvx2(); 29 | 30 | //! Sets an enviroment variable 31 | void setenv(const char* name, const char* value); 32 | 33 | } // namespace pal 34 | -------------------------------------------------------------------------------- /domains/ballistics/agent.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "agent.h" 16 | #include "world.h" 17 | 18 | namespace ballistics { 19 | 20 | Agent::Agent(const darwin::Genotype* genotype) : brain_(genotype->grow()) {} 21 | 22 | float Agent::aim(float target_x, float target_y) { 23 | brain_->setInput(kInputTargetX, target_x); 24 | brain_->setInput(kInputTargetY, target_y); 25 | 26 | brain_->think(); 27 | 28 | return brain_->output(kOutputAimAngle); 29 | } 30 | 31 | } // namespace ballistics 32 | -------------------------------------------------------------------------------- /experimental/2d_physics/scenes/bouncing.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "bouncing.h" 3 | 4 | #include 5 | 6 | namespace bouncing_scene { 7 | 8 | GLOBAL_INITIALIZER { 9 | scenesRegistry().add("Bouncing Objects"); 10 | } 11 | 12 | Scene::Scene() : sim::Scene(b2Vec2(0, -9.8f), sim::Rect(-100, -100, 200, 200)) { 13 | b2BodyDef ground_body_def; 14 | ground_body_def.position.Set(0.0f, -10.0f); 15 | ground_body_def.type = b2_staticBody; 16 | auto ground_body = world_.CreateBody(&ground_body_def); 17 | 18 | b2PolygonShape ground_box; 19 | ground_box.SetAsBox(100.0f, 10.0f); 20 | 21 | ground_body->CreateFixture(&ground_box, 0.0f); 22 | 23 | sim::addBall(-80, 90, 1, &world_); 24 | sim::addBall(-70, 80, 2, &world_); 25 | sim::addBall(-60, 70, 3, &world_); 26 | 27 | auto ball4 = sim::addBall(-50, 60, 5, &world_); 28 | ball4->ApplyAngularImpulse(500.0f, true); 29 | 30 | sim::addBox(0, 50.0f, 1, 1, &world_); 31 | sim::addBox(10, 50.0f, 1, 5, &world_); 32 | 33 | auto box3 = sim::addBox(20, 50.0f, 5, 1, &world_); 34 | box3->ApplyAngularImpulse(1.0f, true); 35 | } 36 | 37 | } // namespace bouncing_scene 38 | -------------------------------------------------------------------------------- /experimental/replicators/replicators.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../../common.pri) 3 | 4 | QT += core gui widgets 5 | 6 | TARGET = replicators 7 | TEMPLATE = app 8 | 9 | #CONFIG += console 10 | 11 | DEFINES += QT_DEPRECATED_WARNINGS 12 | DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 13 | 14 | SOURCES += \ 15 | experiment_window.cpp \ 16 | main.cpp \ 17 | main_window.cpp \ 18 | new_experiment_dialog.cpp \ 19 | phenotype_widget.cpp \ 20 | replicators.cpp \ 21 | species/segment_tree.cpp \ 22 | species/test.cpp \ 23 | species/ksims_virtual_creatures.cpp \ 24 | species/cell_lab.cpp \ 25 | tests.cpp 26 | 27 | HEADERS += \ 28 | experiment_window.h \ 29 | main_window.h \ 30 | new_experiment_dialog.h \ 31 | phenotype_widget.h \ 32 | replicators.h \ 33 | species/segment_tree.h \ 34 | species/test.h \ 35 | species/ksims_virtual_creatures.h \ 36 | species/cell_lab.h \ 37 | tests.h 38 | 39 | FORMS += \ 40 | experiment_window.ui \ 41 | main_window.ui \ 42 | new_experiment_dialog.ui 43 | 44 | addLibrary(../../registry) 45 | addLibrary(../../core_ui) 46 | addLibrary(../../core) 47 | -------------------------------------------------------------------------------- /core/pp_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace pp { 20 | 21 | template 22 | void atomicMax(std::atomic& max, T value) { 23 | T prev = max; 24 | while (value > prev && !max.compare_exchange_weak(prev, value)) 25 | ; 26 | } 27 | 28 | template 29 | void atomicMin(std::atomic& min, T value) { 30 | T prev = min; 31 | while (value < prev && !min.compare_exchange_weak(prev, value)) 32 | ; 33 | } 34 | 35 | } // namespace pp 36 | -------------------------------------------------------------------------------- /domains/test_domain/agent.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "test_domain.h" 18 | 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace test_domain { 25 | 26 | class Agent { 27 | public: 28 | Agent(const darwin::Genotype* genotype, const TestDomain* domain); 29 | 30 | float evaluate(); 31 | 32 | private: 33 | unique_ptr brain_; 34 | const TestDomain* domain_ = nullptr; 35 | }; 36 | 37 | } // namespace test_domain 38 | -------------------------------------------------------------------------------- /third_party/json/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013-2018 Niels Lohmann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /experimental/replicators/replicators.cpp: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "replicators.h" 16 | 17 | namespace experimental::replicators { 18 | 19 | Phenotype::Phenotype() : world_(b2Vec2(0, 0)) {} 20 | 21 | void Phenotype::animate() { 22 | constexpr float32 kTimeStep = 1.0f / 50.0f; 23 | constexpr int32 kVelocityIterations = 10; 24 | constexpr int32 kPositionIterations = 10; 25 | world_.Step(kTimeStep, kVelocityIterations, kPositionIterations); 26 | timestamp_ += kTimeStep; 27 | } 28 | 29 | } // namespace experimental::replicators 30 | -------------------------------------------------------------------------------- /third_party/pugixml/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2006-2018 Arseny Kapoulkine 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following 12 | conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /third_party/tinyspline/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Marcel Steinbeck 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /core/sim/misc.h: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace sim { 20 | 21 | // TODO: refactor these helpers 22 | b2Body* addBall(float x, float y, float r, b2World* world); 23 | b2Body* addBox(float x, float y, float w, float h, b2World* world); 24 | b2Body* addCross(float x, float y, float w, float h, b2World* world); 25 | b2Body* addBullet(float x, float y, float dx, float dy, b2World* world); 26 | b2Body* addBoxProjectile(float x, float y, float dx, float dy, b2World* world); 27 | 28 | } // namespace sim 29 | -------------------------------------------------------------------------------- /core_ui/sim/box2d_sandbox_dialog.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace physics_ui { 20 | 21 | namespace Ui { 22 | class Box2dSandboxDialog; 23 | } 24 | 25 | class Box2dSandboxDialog : public QDialog { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit Box2dSandboxDialog(int default_generation, int default_max_steps); 30 | ~Box2dSandboxDialog(); 31 | 32 | int generation() const; 33 | int maxSteps() const; 34 | 35 | private: 36 | Ui::Box2dSandboxDialog* ui = nullptr; 37 | }; 38 | 39 | } // namespace physics_ui 40 | -------------------------------------------------------------------------------- /core_ui/sim/camera_widget.h: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #include 20 | 21 | namespace physics_ui { 22 | 23 | //! Visualization for a sim::Camera object 24 | class CameraWidget : public QWidget { 25 | public: 26 | explicit CameraWidget(QWidget* parent) : QWidget(parent) {} 27 | 28 | void setCamera(const sim::Camera* camera); 29 | 30 | private: 31 | void paintEvent(QPaintEvent* event) override; 32 | 33 | private: 34 | const sim::Camera* camera_ = nullptr; 35 | }; 36 | 37 | } // namespace physics_ui 38 | -------------------------------------------------------------------------------- /core/sim/car_controller.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | using namespace std; 22 | 23 | namespace sim { 24 | 25 | class CarController { 26 | public: 27 | CarController(const darwin::Genotype* genotype, Car* car); 28 | void simStep(); 29 | 30 | static int inputs(const CarConfig& config); 31 | static int outputs(const CarConfig& config); 32 | 33 | private: 34 | Car* car_ = nullptr; 35 | unique_ptr brain_; 36 | }; 37 | 38 | } // namespace sim 39 | -------------------------------------------------------------------------------- /domains/unicycle_ui/scene_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | namespace unicycle_ui { 21 | 22 | class SceneUi : public physics_ui::Box2dSceneUi { 23 | public: 24 | SceneUi(unicycle::World* world) : world_(world) {} 25 | 26 | private: 27 | void render(QPainter& painter, const QRectF&, bool) override; 28 | void mousePressEvent(const QPointF& pos, QMouseEvent* event) override; 29 | 30 | private: 31 | unicycle::World* world_ = nullptr; 32 | }; 33 | 34 | } // namespace unicycle_ui 35 | -------------------------------------------------------------------------------- /core/sim/drone_controller.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | using namespace std; 22 | 23 | namespace sim { 24 | 25 | class DroneController { 26 | public: 27 | DroneController(const darwin::Genotype* genotype, Drone* drone); 28 | void simStep(); 29 | 30 | static int inputs(const DroneConfig& config); 31 | static int outputs(const DroneConfig& config); 32 | 33 | private: 34 | Drone* drone_ = nullptr; 35 | unique_ptr brain_; 36 | }; 37 | 38 | } // namespace sim 39 | -------------------------------------------------------------------------------- /domains/unicycle/agent.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "unicycle.h" 18 | 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace unicycle { 25 | 26 | class World; 27 | 28 | class Agent { 29 | public: 30 | Agent(const darwin::Genotype* genotype, World* world); 31 | void simStep(); 32 | 33 | static int inputs(const Config& config); 34 | static int outputs(const Config& config); 35 | 36 | private: 37 | World* world_ = nullptr; 38 | unique_ptr brain_; 39 | }; 40 | 41 | } // namespace unicycle 42 | -------------------------------------------------------------------------------- /tests/populations/dummy_domain.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | class DummyDomain : public darwin::Domain { 21 | public: 22 | DummyDomain(size_t inputs, size_t outputs) : inputs_(inputs), outputs_(outputs) {} 23 | 24 | virtual size_t inputs() const override { return inputs_; } 25 | virtual size_t outputs() const override { return outputs_; } 26 | 27 | bool evaluatePopulation(darwin::Population*) const override { return true; } 28 | 29 | private: 30 | size_t inputs_ = 0; 31 | size_t outputs_ = 0; 32 | }; 33 | -------------------------------------------------------------------------------- /darwin_studio/evolution_window.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | namespace Ui { 23 | class EvolutionWindow; 24 | } 25 | 26 | class EvolutionWindow : public QFrame { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit EvolutionWindow(QWidget* parent = nullptr); 31 | ~EvolutionWindow(); 32 | 33 | private: 34 | void updateUI(uint32_t hints); 35 | void setHistoryValue(int index, int column, float value); 36 | 37 | private: 38 | Ui::EvolutionWindow* ui; 39 | int last_trace_size_ = 0; 40 | }; 41 | -------------------------------------------------------------------------------- /domains/cart_pole/agent.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "cart_pole.h" 18 | 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace cart_pole { 25 | 26 | class World; 27 | 28 | class Agent { 29 | public: 30 | Agent(const darwin::Genotype* genotype, World* world); 31 | void simStep(); 32 | 33 | static int inputs(const Config& config); 34 | static int outputs(const Config& config); 35 | 36 | private: 37 | World* world_ = nullptr; 38 | unique_ptr brain_; 39 | }; 40 | 41 | } // namespace cart_pole 42 | -------------------------------------------------------------------------------- /domains/harvester_ui/new_sandbox_dialog.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace harvester_ui { 20 | 21 | namespace Ui { 22 | class NewSandboxDialog; 23 | } 24 | 25 | class NewSandboxDialog : public QDialog { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit NewSandboxDialog(QWidget* parent = nullptr); 30 | ~NewSandboxDialog(); 31 | 32 | int generation() const; 33 | int worldWidth() const; 34 | int worldHeight() const; 35 | int initialHealth() const; 36 | 37 | private: 38 | Ui::NewSandboxDialog* ui; 39 | }; 40 | 41 | } // namespace harvester_ui 42 | -------------------------------------------------------------------------------- /domains/tic_tac_toe/game_rules.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "player.h" 18 | 19 | #include 20 | 21 | namespace tic_tac_toe { 22 | 23 | class TicTacToeRules : public tournament::GameRules { 24 | public: 25 | tournament::Scores scores(tournament::GameOutcome outcome) const override; 26 | 27 | tournament::GameOutcome play(Player* x_player, Player* o_player) const; 28 | 29 | tournament::GameOutcome play(const darwin::Genotype* x_genotype, 30 | const darwin::Genotype* o_genotype) const override; 31 | }; 32 | 33 | } // namespace tic_tac_toe 34 | -------------------------------------------------------------------------------- /tests/domains/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | int main(int argc, char* argv[]) { 22 | // Darwin initialization 23 | // 24 | // NOTE: this must be done before InitGoogleTest() in order 25 | // to allow parameterized tests query the environment 26 | // 27 | core::Runtime::init(0, nullptr, TEST_TEMP_PATH); 28 | registry::init(); 29 | pp::ParallelForSupport::init(nullptr); 30 | 31 | ::testing::InitGoogleTest(&argc, argv); 32 | return RUN_ALL_TESTS(); 33 | } 34 | -------------------------------------------------------------------------------- /domains/double_cart_pole/agent.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "double_cart_pole.h" 18 | 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace double_cart_pole { 25 | 26 | class World; 27 | 28 | class Agent { 29 | public: 30 | Agent(const darwin::Genotype* genotype, World* world); 31 | void simStep(); 32 | 33 | static int inputs(const Config& config); 34 | static int outputs(const Config& config); 35 | 36 | private: 37 | World* world_ = nullptr; 38 | unique_ptr brain_; 39 | }; 40 | 41 | } // namespace double_cart_pole 42 | -------------------------------------------------------------------------------- /domains/pong_ui/pong_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "pong_ui.h" 16 | #include "game_widget.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace pong_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("pong"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace pong_ui 40 | -------------------------------------------------------------------------------- /core/runtime.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | namespace fs = std::filesystem; 19 | 20 | namespace core { 21 | 22 | //! Interface to the Darwin runtime environment 23 | class Runtime { 24 | public: 25 | //! Initialize the Darwin runtime 26 | static void init(int argc, char* argv[], const char* home_path = nullptr); 27 | 28 | //! The Darwin home path (containing configuration and log files) 29 | static const fs::path& darwinHomePath(); 30 | 31 | //! A signature string describing the current build 32 | static const char* buildString(); 33 | 34 | private: 35 | static fs::path darwin_home_path_; 36 | }; 37 | 38 | } // namespace core 39 | -------------------------------------------------------------------------------- /domains/tic_tac_toe/test_players.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "board.h" 18 | #include "player.h" 19 | 20 | #include 21 | using namespace std; 22 | 23 | namespace tic_tac_toe { 24 | 25 | class RandomPlayer : public Player { 26 | public: 27 | RandomPlayer(bool informed_choice) : informed_choice_(informed_choice) {} 28 | 29 | // Player interface 30 | int move() override; 31 | 32 | string name() const override; 33 | 34 | private: 35 | float evaluateMove(int square) const; 36 | 37 | private: 38 | mutable default_random_engine rnd_{ random_device{}() }; 39 | bool informed_choice_ = false; 40 | }; 41 | 42 | } // namespace tic_tac_toe 43 | -------------------------------------------------------------------------------- /domains/conquest_ui/conquest_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "conquest_ui.h" 16 | #include "game_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace conquest_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("conquest"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace conquest_ui 40 | -------------------------------------------------------------------------------- /domains/car_track_ui/domain_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "domain_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace car_track_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("car_track"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace car_track_ui 40 | -------------------------------------------------------------------------------- /domains/pong/player.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | using namespace std; 19 | 20 | namespace pong { 21 | 22 | class Game; 23 | 24 | class Player { 25 | public: 26 | enum class Action { None, MoveUp, MoveDown }; 27 | enum class Side { Left, Right }; 28 | 29 | public: 30 | Player() = default; 31 | virtual ~Player() = default; 32 | 33 | virtual void newGame(const Game* game, Side side) { 34 | game_ = game; 35 | side_ = side; 36 | } 37 | 38 | virtual Action action() = 0; 39 | virtual string name() const = 0; 40 | 41 | protected: 42 | const Game* game_ = nullptr; 43 | Side side_ = Side::Left; 44 | }; 45 | 46 | } // namespace pong 47 | -------------------------------------------------------------------------------- /domains/unicycle_ui/unicycle_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "unicycle_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace unicycle_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("unicycle"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace unicycle_ui 40 | -------------------------------------------------------------------------------- /domains/cart_pole_ui/cart_pole_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "cart_pole_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace cart_pole_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("cart_pole"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace cart_pole_ui 40 | -------------------------------------------------------------------------------- /domains/harvester_ui/harvester_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "harvester_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace harvester_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("harvester"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace harvester_ui 40 | -------------------------------------------------------------------------------- /domains/drone_track_ui/domain_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "domain_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace drone_track_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("drone_track"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace drone_track_ui 40 | -------------------------------------------------------------------------------- /domains/ballistics_ui/ballistics_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "ballistics_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace ballistics_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("ballistics"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace ballistics_ui 40 | -------------------------------------------------------------------------------- /domains/drone_follow_ui/domain_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "domain_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace drone_follow_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("drone_follow"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace drone_follow_ui 40 | -------------------------------------------------------------------------------- /domains/drone_vision_ui/domain_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "domain_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace drone_vision_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("drone_vision"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace drone_vision_ui 40 | -------------------------------------------------------------------------------- /tests/darwin/test_environment.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | namespace fs = std::filesystem; 23 | 24 | class DarwinTestEnvironment : public testing::Environment { 25 | public: 26 | static string universePath() { 27 | const auto universe_path = fs::path(TEST_TEMP_PATH) / "test_universe.darwin"; 28 | return universe_path.string(); 29 | } 30 | 31 | private: 32 | void SetUp() override { 33 | auto universe_path = universePath(); 34 | fs::remove(universe_path); 35 | darwin::Universe::create(universe_path); 36 | } 37 | 38 | void TearDown() override {} 39 | }; 40 | -------------------------------------------------------------------------------- /domains/conquest/ann_player.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "board.h" 18 | #include "player.h" 19 | 20 | #include 21 | 22 | namespace conquest { 23 | 24 | class AnnPlayer : public Player { 25 | public: 26 | unique_ptr brain; 27 | const darwin::Genotype* genotype = nullptr; 28 | int generation = -1; 29 | 30 | public: 31 | int order() override; 32 | string name() const override; 33 | void newGame(const Game* game, Side side) override; 34 | 35 | void grow(const darwin::Genotype* genotype); 36 | 37 | static size_t inputsCount(const Board* board); 38 | static size_t outputsCount(const Board* board); 39 | }; 40 | 41 | } // namespace conquest 42 | -------------------------------------------------------------------------------- /domains/tic_tac_toe_ui/tic_tac_toe_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "tic_tac_toe_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace tic_tac_toe_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("tic_tac_toe"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("\nFailed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace tic_tac_toe_ui 40 | -------------------------------------------------------------------------------- /domains/conquest/test_players.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "player.h" 18 | 19 | #include 20 | using namespace std; 21 | 22 | namespace conquest { 23 | 24 | class DummyPlayer : public Player { 25 | int order() override { return Player::kNoAction; } 26 | string name() const override { return "Human"; } 27 | }; 28 | 29 | class RandomPlayer : public Player { 30 | int order() override; 31 | string name() const override { return "Random"; } 32 | 33 | private: 34 | default_random_engine rnd_{ random_device{}() }; 35 | }; 36 | 37 | class HandcraftedPlayer : public Player { 38 | int order() override; 39 | string name() const override { return "Handcrafted"; } 40 | }; 41 | 42 | } // namespace conquest 43 | -------------------------------------------------------------------------------- /domains/double_cart_pole_ui/double_cart_pole_ui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "double_cart_pole_ui.h" 16 | #include "sandbox_window.h" 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace double_cart_pole_ui { 25 | 26 | void init() { 27 | darwin::registry()->domains_ui.add("double_cart_pole"); 28 | } 29 | 30 | QWidget* Factory::newSandboxWindow() { 31 | auto sandbox_window = make_unique(); 32 | if (!sandbox_window->setup()) { 33 | core::log("Failed to setup the new sandbox window\n\n"); 34 | sandbox_window.reset(); 35 | } 36 | return sandbox_window.release(); 37 | } 38 | 39 | } // namespace double_cart_pole_ui 40 | -------------------------------------------------------------------------------- /domains/ballistics/agent.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "ballistics.h" 18 | 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace ballistics { 25 | 26 | class World; 27 | 28 | class Agent { 29 | public: 30 | static constexpr int kInputs = 2; 31 | static constexpr int kOutputs = 1; 32 | 33 | private: 34 | static constexpr int kInputTargetX = 0; 35 | static constexpr int kInputTargetY = 1; 36 | static constexpr int kOutputAimAngle = 0; 37 | 38 | public: 39 | explicit Agent(const darwin::Genotype* genotype); 40 | float aim(float target_x, float target_y); 41 | 42 | private: 43 | unique_ptr brain_; 44 | }; 45 | 46 | } // namespace ballistics 47 | -------------------------------------------------------------------------------- /darwin_studio/start_evolution_dialog.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | namespace Ui { 25 | class StartEvolutionDialog; 26 | } 27 | 28 | class StartEvolutionDialog : public QDialog { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit StartEvolutionDialog(QWidget* parent); 33 | ~StartEvolutionDialog(); 34 | 35 | const auto& evolutionConfig() const { return evolution_config_; } 36 | 37 | int batchRuns() const; 38 | 39 | void done(int result) override; 40 | 41 | private: 42 | Ui::StartEvolutionDialog* ui; 43 | 44 | darwin::EvolutionConfig evolution_config_; 45 | }; 46 | -------------------------------------------------------------------------------- /darwin_studio/experiment_window.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | using namespace std; 24 | 25 | namespace Ui { 26 | class ExperimentWindow; 27 | } 28 | 29 | class ExperimentWindow : public QFrame { 30 | Q_OBJECT 31 | 32 | public: 33 | explicit ExperimentWindow(shared_ptr experiment); 34 | ~ExperimentWindow(); 35 | 36 | void onBeginRun(); 37 | void onAbortRun(); 38 | 39 | private: 40 | void newExperiment(); 41 | void addProperties(const string& name, core::PropertySet* config); 42 | 43 | private: 44 | Ui::ExperimentWindow* ui; 45 | 46 | shared_ptr experiment_; 47 | }; 48 | -------------------------------------------------------------------------------- /populations/test_population/test_population.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace test_population { 20 | 21 | void init(); 22 | 23 | struct Config : public core::PropertySet { 24 | PROPERTY(input_range, float, 10.0f, "The expected inputs range (checked at runtime)"); 25 | PROPERTY(output_range, float, 2.0f, "The range of (random) output values"); 26 | PROPERTY(random_outputs, bool, true, "Generate random outputs"); 27 | PROPERTY(const_output, float, 0.0f, "Used for all outputs if random_outputs is false"); 28 | 29 | PROPERTY(elite_percentage, float, 0.1f, "Elite percentage"); 30 | PROPERTY(elite_min_fitness, float, 0.0f, "Elite minimum fitness"); 31 | }; 32 | 33 | } // namespace test_population 34 | -------------------------------------------------------------------------------- /tests/darwin/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "test_environment.h" 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int main(int argc, char* argv[]) { 26 | // Darwin initialization 27 | // 28 | // NOTE: this must be done before InitGoogleTest() in order 29 | // to allow parameterized tests query the environment 30 | // 31 | core::Runtime::init(0, nullptr, TEST_TEMP_PATH); 32 | darwin::Evolution::init(); 33 | registry::init(); 34 | 35 | testing::InitGoogleTest(&argc, argv); 36 | testing::AddGlobalTestEnvironment(new DarwinTestEnvironment); 37 | return RUN_ALL_TESTS(); 38 | } 39 | -------------------------------------------------------------------------------- /domains/harvester/world.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "robot.h" 18 | #include "world_map.h" 19 | 20 | namespace harvester { 21 | 22 | class World { 23 | public: 24 | World(const WorldMap& world_map, Robot* robot); 25 | 26 | World(const World&) = delete; 27 | World& operator=(const World&) = delete; 28 | 29 | void simInit(); 30 | void simStep(); 31 | 32 | const WorldMap& worldMap() const { return map_; } 33 | const Robot* robot() const { return robot_; } 34 | int currentStep() const { return step_; } 35 | 36 | // returns the previous cell type 37 | WorldMap::Cell visit(int row, int col); 38 | 39 | private: 40 | WorldMap map_; 41 | Robot* robot_ = nullptr; 42 | int step_ = -1; 43 | }; 44 | 45 | } // namespace harvester 46 | -------------------------------------------------------------------------------- /domains/drone_vision_ui/scene_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace drone_vision_ui { 22 | 23 | class SceneUi : public physics_ui::Box2dSceneUi { 24 | public: 25 | SceneUi(drone_vision::Scene* scene) : scene_(scene) {} 26 | 27 | void render(QPainter& painter, const QRectF&, bool) override; 28 | 29 | private: 30 | void renderCamera(QPainter& painter, const sim::Camera* camera) const; 31 | void renderDrone(QPainter& painter, const sim::Drone* drone) const; 32 | 33 | private: 34 | drone_vision::Scene* scene_ = nullptr; 35 | 36 | const QPixmap drone_pixmap_{ ":/resources/drone.png" }; 37 | }; 38 | 39 | } // namespace drone_vision_ui 40 | -------------------------------------------------------------------------------- /domains/conquest/player.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | using namespace std; 19 | 20 | namespace conquest { 21 | 22 | class Game; 23 | 24 | class Player { 25 | public: 26 | enum class Side { Blue, Red }; 27 | 28 | static constexpr int kNoAction = -1; 29 | 30 | public: 31 | Player() = default; 32 | virtual ~Player() = default; 33 | 34 | virtual void newGame(const Game* game, Side side) { 35 | game_ = game; 36 | color_lens_ = (side == Side::Blue) ? 1.0f : -1.0f; 37 | } 38 | 39 | virtual string name() const = 0; 40 | 41 | // returns the index of an arc (attack) or kNoAction 42 | virtual int order() = 0; 43 | 44 | protected: 45 | const Game* game_ = nullptr; 46 | float color_lens_ = 0; 47 | }; 48 | 49 | } // namespace conquest 50 | -------------------------------------------------------------------------------- /domains/ballistics_ui/scene_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | namespace ballistics_ui { 23 | 24 | class SceneUi : public physics_ui::Box2dSceneUi { 25 | Q_OBJECT 26 | 27 | public: 28 | SceneUi(ballistics::World* world) : world_(world) { trajectory_path_.moveTo(0, 0); } 29 | 30 | signals: 31 | void sigNewTarget(double x, double y); 32 | 33 | private: 34 | void render(QPainter& painter, const QRectF& viewport, bool debug) override; 35 | void mousePressEvent(const QPointF& pos, QMouseEvent* event) override; 36 | 37 | private: 38 | ballistics::World* world_ = nullptr; 39 | QPainterPath trajectory_path_; 40 | }; 41 | 42 | } // namespace ballistics_ui 43 | -------------------------------------------------------------------------------- /experimental/2d_physics/sandbox_window.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "sandbox_factory.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | using namespace std; 14 | 15 | class MainWindow; 16 | 17 | class SandboxWindow : public physics_ui::Box2dSandboxWindow { 18 | struct Variables { 19 | // simulation state 20 | core_ui::PropertyItem* state = nullptr; 21 | core_ui::PropertyItem* step = nullptr; 22 | core_ui::PropertyItem* timestamp = nullptr; 23 | core_ui::PropertyItem* objects_count = nullptr; 24 | }; 25 | 26 | public: 27 | explicit SandboxWindow(MainWindow* main_window, SandboxFactory* factory); 28 | 29 | void newScene() override; 30 | void singleStep() override; 31 | void updateUI() override; 32 | 33 | const SandboxScenePackage& scenePackage() const { return scene_package_; } 34 | 35 | private: 36 | void setupVariables(); 37 | 38 | private: 39 | MainWindow* main_window_ = nullptr; 40 | 41 | SandboxFactory* factory_ = nullptr; 42 | SandboxScenePackage scene_package_; 43 | int step_ = -1; 44 | 45 | Variables variables_; 46 | unordered_map scene_variables_map_; 47 | unordered_map scene_config_map_; 48 | 49 | unique_ptr config_; 50 | }; 51 | 52 | -------------------------------------------------------------------------------- /darwin_studio/open_experiment_dialog.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | namespace Ui { 24 | class OpenExperimentDialog; 25 | } 26 | 27 | class OpenExperimentDialog : public QDialog { 28 | Q_OBJECT 29 | 30 | public: 31 | explicit OpenExperimentDialog(QWidget* parent, const darwin::Universe* universe); 32 | ~OpenExperimentDialog(); 33 | 34 | const darwin::DbExperiment* experiment() const; 35 | 36 | private: 37 | void populateExperimentsTable(); 38 | 39 | private slots: 40 | void on_experiments_itemActivated(QTreeWidgetItem* item, int column); 41 | 42 | private: 43 | Ui::OpenExperimentDialog* ui; 44 | 45 | const darwin::Universe* universe_ = nullptr; 46 | }; 47 | -------------------------------------------------------------------------------- /domains/pong_ui/human_player.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "pong_widget.h" 18 | 19 | #include 20 | 21 | namespace pong_ui { 22 | 23 | class HumanPlayer : public pong::Player { 24 | public: 25 | HumanPlayer(const PongWidget* pong_widget) : pong_widget_(pong_widget) {} 26 | 27 | Action action() override { 28 | if (pong_widget_->keyState(side_ == Side::Left ? Qt::Key_Q : Qt::Key_P)) 29 | return Action::MoveUp; 30 | else if (pong_widget_->keyState(side_ == Side::Left ? Qt::Key_A : Qt::Key_L)) 31 | return Action::MoveDown; 32 | else 33 | return Action::None; 34 | } 35 | 36 | string name() const override { return "Human"; } 37 | 38 | private: 39 | const PongWidget* pong_widget_ = nullptr; 40 | }; 41 | 42 | } // namespace pong_ui 43 | -------------------------------------------------------------------------------- /core/exception.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "format.h" 18 | 19 | #include 20 | #include 21 | #include 22 | using namespace std; 23 | 24 | namespace core { 25 | 26 | //! The base for exception types in the Darwin framework 27 | class Exception : public std::runtime_error { 28 | public: 29 | //! Constructs an exception object, optionally formatting the message 30 | //! \sa core::format() 31 | template 32 | explicit Exception(const char* message, ARGS&&... args) 33 | : std::runtime_error(core::format(message, std::forward(args)...)) {} 34 | 35 | //! Constructs an exception object with the specified message 36 | explicit Exception(string message) : std::runtime_error(std::move(message)) {} 37 | }; 38 | 39 | } // namespace core 40 | -------------------------------------------------------------------------------- /darwin_studio/output_window.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "output_window.h" 16 | #include "console_buffer.h" 17 | #include "pubsub_relay.h" 18 | #include "ui_output_window.h" 19 | 20 | OutputWindow::OutputWindow(QWidget* parent) : QFrame(parent), ui(new Ui::OutputWindow) { 21 | ui->setupUi(this); 22 | 23 | connect(PubSubRelay::instance(), 24 | &PubSubRelay::sigConsoleOutput, 25 | this, 26 | &OutputWindow::consoleOutput); 27 | 28 | // flush buffered messages 29 | ConsoleBuffer::instance()->flushAndResume(); 30 | } 31 | 32 | OutputWindow::~OutputWindow() { 33 | delete ui; 34 | } 35 | 36 | void OutputWindow::consoleOutput(const QString& output) { 37 | ui->output->moveCursor(QTextCursor::End); 38 | ui->output->insertPlainText(output); 39 | ui->output->ensureCursorVisible(); 40 | } 41 | -------------------------------------------------------------------------------- /domains/tic_tac_toe/player.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "board.h" 18 | 19 | #include 20 | 21 | namespace tic_tac_toe { 22 | 23 | class Player { 24 | public: 25 | Player() = default; 26 | virtual ~Player() = default; 27 | 28 | // start a new game 29 | virtual void newGame(const Board* board, Board::Piece side) { 30 | CHECK(side != Board::Piece::Empty); 31 | board_ = board; 32 | side_ = side; 33 | } 34 | 35 | // returns the index of the selected board square, or Board::kNoSquare if not ready 36 | virtual int move() = 0; 37 | 38 | virtual string name() const = 0; 39 | 40 | Board::Piece side() const { return side_; } 41 | 42 | protected: 43 | const Board* board_ = nullptr; 44 | Board::Piece side_ = Board::Piece::Empty; 45 | }; 46 | 47 | } // namespace tic_tac_toe 48 | -------------------------------------------------------------------------------- /experimental/replicators/tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "tests.h" 16 | #include "replicators.h" 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace experimental::replicators::tests { 25 | 26 | void runTests() { 27 | // the following try/catch will not handle other types of failure 28 | // (ex. segfault or abort) 29 | try { 30 | for (const auto& [name, factory] : *registry()) { 31 | factory->runTests(); 32 | } 33 | } catch (std::exception& e) { 34 | QMessageBox::warning(nullptr, "Test failure", e.what()); 35 | FATAL("Test case failure"); 36 | } catch (...) { 37 | QMessageBox::warning(nullptr, "Test failure", "Unknown exception"); 38 | FATAL("Test case failure"); 39 | } 40 | } 41 | 42 | } // namespace experimental::replicators::tests 43 | -------------------------------------------------------------------------------- /core_ui/sim/touch_widget.h: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | namespace physics_ui { 21 | 22 | //! Visualization for a sim::TouchSensor object 23 | class TouchSensorWidget : public core_ui::Canvas { 24 | static constexpr double kCanvasWidth = 20; 25 | static constexpr double kCanvasHeight = 20; 26 | 27 | static constexpr double kSensorWidth = 15; 28 | static constexpr double kSensorHeight = 15; 29 | 30 | static constexpr double kSkinSize = 1.5; 31 | 32 | public: 33 | explicit TouchSensorWidget(QWidget* parent); 34 | 35 | void setSensor(const sim::TouchSensor* sensor); 36 | 37 | private: 38 | void paintEvent(QPaintEvent* event) override; 39 | 40 | private: 41 | const sim::TouchSensor* sensor_ = nullptr; 42 | }; 43 | 44 | } // namespace physics_ui 45 | -------------------------------------------------------------------------------- /experimental/replicators/main_window.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Ui { 11 | class MainWindow; 12 | } 13 | 14 | namespace experimental::replicators { 15 | 16 | class ExperimentWindow; 17 | 18 | class MainWindow : public QMainWindow { 19 | Q_OBJECT 20 | 21 | public: 22 | MainWindow(); 23 | ~MainWindow() override; 24 | 25 | private slots: 26 | void on_action_new_experiment_triggered(); 27 | void on_action_close_tab_triggered(); 28 | void on_action_new_sample_set_triggered(); 29 | void on_tabs_tabCloseRequested(int index); 30 | void on_tabs_currentChanged(int index); 31 | void on_action_refresh_candidates_triggered(); 32 | void on_action_animate_phenotypes_toggled(bool checked); 33 | void on_action_debug_render_toggled(bool checked); 34 | 35 | private: 36 | void newExperimentWindow(bool sample_set); 37 | void openTab(const QString& species_name, bool sample_set); 38 | void closeTab(int index); 39 | void enableExperimentActions(bool enabled); 40 | void deactivateCurrentExperiment(); 41 | 42 | void dockWindow(const char* name, 43 | QFrame* window, 44 | Qt::DockWidgetAreas allowed_areas, 45 | Qt::DockWidgetArea area); 46 | 47 | private: 48 | Ui::MainWindow* ui = nullptr; 49 | ExperimentWindow* current_experiment_window_ = nullptr; 50 | }; 51 | 52 | } // namespace experimental::replicators 53 | -------------------------------------------------------------------------------- /registry/registry.pro: -------------------------------------------------------------------------------- 1 | 2 | include(../common.pri) 3 | 4 | QT -= core gui 5 | 6 | TARGET = registry 7 | TEMPLATE = lib 8 | CONFIG += staticlib 9 | CONFIG += create_prl 10 | 11 | SOURCES += \ 12 | registry.cpp \ 13 | registry_ui.cpp 14 | 15 | HEADERS += \ 16 | registry.h \ 17 | registry_ui.h 18 | 19 | addLibrary(../domains/test_domain) 20 | addLibrary(../domains/cart_pole_ui) 21 | addLibrary(../domains/cart_pole) 22 | addLibrary(../domains/conquest_ui) 23 | addLibrary(../domains/conquest) 24 | addLibrary(../domains/double_cart_pole_ui) 25 | addLibrary(../domains/double_cart_pole) 26 | addLibrary(../domains/harvester_ui) 27 | addLibrary(../domains/harvester) 28 | addLibrary(../domains/max) 29 | addLibrary(../domains/pong_ui) 30 | addLibrary(../domains/pong) 31 | addLibrary(../domains/tic_tac_toe_ui) 32 | addLibrary(../domains/tic_tac_toe) 33 | addLibrary(../domains/unicycle_ui) 34 | addLibrary(../domains/unicycle) 35 | addLibrary(../domains/ballistics_ui) 36 | addLibrary(../domains/ballistics) 37 | addLibrary(../domains/drone_vision_ui) 38 | addLibrary(../domains/drone_vision) 39 | addLibrary(../domains/drone_follow_ui) 40 | addLibrary(../domains/drone_follow) 41 | addLibrary(../domains/drone_track_ui) 42 | addLibrary(../domains/drone_track) 43 | addLibrary(../domains/car_track_ui) 44 | addLibrary(../domains/car_track) 45 | 46 | addLibrary(../populations/cgp) 47 | addLibrary(../populations/cne) 48 | addLibrary(../populations/test_population) 49 | addLibrary(../populations/neat) 50 | 51 | addLibrary(../core) 52 | -------------------------------------------------------------------------------- /core_ui/sim/compass_widget.h: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | namespace physics_ui { 21 | 22 | //! Visualization for a sim::Compass object 23 | class CompassWidget : public core_ui::Canvas { 24 | static constexpr double kCanvasWidth = 20; 25 | static constexpr double kCanvasHeight = 20; 26 | 27 | static constexpr double kSensorWidth = 15; 28 | static constexpr double kSensorHeight = 15; 29 | 30 | static constexpr double kCompassLength = 7; 31 | static constexpr double kCompassWidth = 0.4; 32 | 33 | public: 34 | explicit CompassWidget(QWidget* parent); 35 | 36 | void setSensor(const sim::Compass* sensor); 37 | 38 | private: 39 | void paintEvent(QPaintEvent* event) override; 40 | 41 | private: 42 | const sim::Compass* sensor_ = nullptr; 43 | }; 44 | 45 | } // namespace physics_ui 46 | -------------------------------------------------------------------------------- /core/swiss_tournament.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace tournament { 22 | 23 | //! SwissTournament configuration 24 | struct SwissTournamentConfig : public core::PropertySet { 25 | PROPERTY(rounds, int, 20, "Number of tournament rounds"); 26 | PROPERTY(rematches, bool, true, "Play both-side rematches?"); 27 | }; 28 | 29 | //! [Swiss-style tournament](https://en.wikipedia.org/wiki/Swiss-system_tournament) 30 | class SwissTournament : public Tournament { 31 | class PairingLog; 32 | 33 | public: 34 | explicit SwissTournament(const core::PropertySet& config); 35 | 36 | void evaluatePopulation(darwin::Population* population, GameRules* game_rules) override; 37 | 38 | private: 39 | SwissTournamentConfig config_; 40 | }; 41 | 42 | } // namespace tournament 43 | -------------------------------------------------------------------------------- /populations/test_population/genotype.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "test_population.h" 18 | 19 | #include 20 | 21 | #include 22 | using namespace std; 23 | 24 | namespace test_population { 25 | 26 | class Population; 27 | 28 | class Genotype : public darwin::Genotype { 29 | public: 30 | explicit Genotype(const Population* population); 31 | 32 | unique_ptr grow() const override; 33 | unique_ptr clone() const override; 34 | 35 | json save() const override; 36 | void load(const json& json_obj) override; 37 | void reset() override; 38 | 39 | auto population() const { return population_; } 40 | auto seed() const { return seed_; } 41 | 42 | private: 43 | const Population* population_ = nullptr; 44 | random_device::result_type seed_ = 0; 45 | }; 46 | 47 | } // namespace test_population 48 | -------------------------------------------------------------------------------- /core/chronometer.h: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace core { 20 | 21 | //! Automatic (scope based) wall-clock time measurements (in milliseconds) 22 | class Chronometer { 23 | public: 24 | using Clock = std::chrono::steady_clock; 25 | 26 | public: 27 | explicit Chronometer(double* elapsed_ms, bool cumulative = false) 28 | : elapsed_ms_(elapsed_ms), cumulative_(cumulative) { 29 | start_timestamp_ = Clock::now(); 30 | } 31 | 32 | ~Chronometer() { 33 | const auto finish_timestamp = Clock::now(); 34 | const std::chrono::duration d = finish_timestamp - start_timestamp_; 35 | *elapsed_ms_ = (cumulative_ ? *elapsed_ms_ : 0) + d.count() * 1000.0; 36 | } 37 | 38 | private: 39 | Clock::time_point start_timestamp_; 40 | double* elapsed_ms_ = nullptr; 41 | bool cumulative_ = false; 42 | }; 43 | 44 | } // namespace core 45 | -------------------------------------------------------------------------------- /domains/car_track_ui/scene_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace car_track_ui { 25 | 26 | class SceneUi : public physics_ui::Box2dSceneUi { 27 | public: 28 | SceneUi(car_track::Scene* scene); 29 | 30 | void render(QPainter& painter, const QRectF& viewport, bool debug) override; 31 | void step() override; 32 | 33 | private: 34 | void renderCamera(QPainter& painter, const sim::Camera* camera) const; 35 | void renderPath(QPainter& painter) const; 36 | void renderTrack(QPainter& painter) const; 37 | void renderCurrentSegment(QPainter& painter) const; 38 | 39 | private: 40 | car_track::Scene* scene_ = nullptr; 41 | QPainterPath car_path_; 42 | }; 43 | 44 | } // namespace car_track_ui 45 | -------------------------------------------------------------------------------- /core/sim/scene.cpp: -------------------------------------------------------------------------------- 1 | // Copyright The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "scene.h" 16 | 17 | namespace sim { 18 | 19 | void Scene::clear() { 20 | auto body = world_.GetBodyList(); 21 | while (body != nullptr) { 22 | auto next = body->GetNext(); 23 | world_.DestroyBody(body); 24 | body = next; 25 | } 26 | } 27 | 28 | bool Scene::simStep() { 29 | if (timestamp_ == 0) { 30 | script_.start(); 31 | } 32 | 33 | preStep(); 34 | 35 | constexpr float32 kTimeStep = 1.0f / 50.0f; 36 | constexpr int32 kVelocityIterations = 10; 37 | constexpr int32 kPositionIterations = 10; 38 | 39 | script_.play(timestamp_); 40 | 41 | // Box2D simulation step 42 | world_.Step(kTimeStep, kVelocityIterations, kPositionIterations); 43 | timestamp_ += kTimeStep; 44 | 45 | // TODO: process the contacts 46 | // TODO: pause/resume/done/reset? 47 | 48 | postStep(kTimeStep); 49 | return true; 50 | } 51 | 52 | } // namespace sim 53 | -------------------------------------------------------------------------------- /core_ui/sim/box2d_sandbox_dialog.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "box2d_sandbox_dialog.h" 16 | #include "ui_box2d_sandbox_dialog.h" 17 | 18 | namespace physics_ui { 19 | 20 | Box2dSandboxDialog::Box2dSandboxDialog(int default_generation, int default_max_steps) 21 | : QDialog(nullptr, 22 | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), 23 | ui(new Ui::Box2dSandboxDialog) { 24 | ui->setupUi(this); 25 | 26 | ui->generation->setValue(default_generation); 27 | ui->max_steps->setValue(default_max_steps); 28 | 29 | ui->generation->setFocus(); 30 | } 31 | 32 | Box2dSandboxDialog::~Box2dSandboxDialog() { 33 | delete ui; 34 | } 35 | 36 | int Box2dSandboxDialog::generation() const { 37 | return ui->generation->value(); 38 | } 39 | 40 | int Box2dSandboxDialog::maxSteps() const { 41 | return ui->max_steps->value(); 42 | } 43 | 44 | } // namespace physics_ui 45 | -------------------------------------------------------------------------------- /domains/drone_follow_ui/scene_ui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | namespace drone_follow_ui { 24 | 25 | class SceneUi : public physics_ui::Box2dSceneUi { 26 | public: 27 | SceneUi(drone_follow::Scene* scene); 28 | 29 | void render(QPainter& painter, const QRectF&, bool) override; 30 | void step() override; 31 | 32 | private: 33 | void renderCamera(QPainter& painter, const sim::Camera* camera) const; 34 | void renderDrone(QPainter& painter, const sim::Drone* drone) const; 35 | 36 | private: 37 | drone_follow::Scene* scene_ = nullptr; 38 | 39 | QPainterPath drone_path_; 40 | QPainterPath target_drone_path_; 41 | 42 | const QPixmap drone_pixmap_{ ":/resources/drone.png" }; 43 | }; 44 | 45 | } // namespace drone_follow_ui 46 | -------------------------------------------------------------------------------- /tests/bindings/python/test_universe.py: -------------------------------------------------------------------------------- 1 | 2 | import unittest 3 | import darwin 4 | 5 | import darwin_test_utils 6 | 7 | 8 | class UniverseTestCase(unittest.TestCase): 9 | def test_create(self): 10 | path = darwin_test_utils.reserve_universe('python_bindings.darwin') 11 | universe = darwin.create_universe(path) 12 | self.assertFalse(universe.closed) 13 | self.assertEqual(universe.path, path) 14 | universe.close() 15 | self.assertTrue(universe.closed) 16 | 17 | def test_open_or_create(self): 18 | path = darwin_test_utils.reserve_universe('python_bindings.darwin') 19 | universe = darwin.open_universe(path) 20 | self.assertFalse(universe.closed) 21 | self.assertEqual(universe.path, path) 22 | universe.close() 23 | self.assertTrue(universe.closed) 24 | 25 | def test_context_manager(self): 26 | path = darwin_test_utils.reserve_universe('python_bindings.darwin') 27 | 28 | # create the universe 29 | with darwin.create_universe(path): 30 | # nothing to do, we just created a new universe 31 | pass 32 | 33 | # open the universe, using the context manager interface 34 | with darwin.open_universe(path) as universe: 35 | self.assertFalse(universe.closed) 36 | self.assertEqual(universe.path, path) 37 | self.assertTrue(str(universe).startswith(' 21 | 22 | #include 23 | using namespace std; 24 | 25 | namespace tic_tac_toe { 26 | 27 | class AnnPlayer : public Player { 28 | public: 29 | static int inputs() { return 9; } 30 | static int outputs(); 31 | 32 | void grow(const darwin::Genotype* genotype, int generation = -1); 33 | 34 | auto genotype() const { return genotype_; } 35 | 36 | // Player interface 37 | void newGame(const Board* board, Board::Piece side) override; 38 | int move() override; 39 | 40 | string name() const override; 41 | 42 | private: 43 | int policyBrainMove(); 44 | int valueBrainMove(); 45 | 46 | private: 47 | unique_ptr brain_; 48 | const darwin::Genotype* genotype_ = nullptr; 49 | int generation_ = -1; 50 | }; 51 | 52 | } // namespace tic_tac_toe 53 | -------------------------------------------------------------------------------- /third_party/gtest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /experimental/2d_physics/scenes/bouncing.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "sandbox_factory.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | using namespace std; 15 | 16 | namespace bouncing_scene { 17 | 18 | class Scene : public sim::Scene { 19 | public: 20 | Scene(); 21 | }; 22 | 23 | class SceneUi : public physics_ui::Box2dSceneUi { 24 | public: 25 | explicit SceneUi(Scene* scene) : scene_(scene) {} 26 | 27 | void mousePressEvent(const QPointF& pos, QMouseEvent* event) override { 28 | const auto x = float(pos.x()); 29 | const auto y = float(pos.y()); 30 | 31 | if ((event->buttons() & Qt::LeftButton) != 0) { 32 | sim::addBall(x, y, 3, scene_->box2dWorld()); 33 | } 34 | 35 | if ((event->buttons() & Qt::RightButton) != 0) { 36 | sim::addBox(x, y, 10, 2, scene_->box2dWorld()); 37 | } 38 | } 39 | 40 | void keyPressEvent(QKeyEvent* event) override { 41 | if (event->key() == Qt::Key_Space) { 42 | sim::addBullet(-95, 5, 100 * 100, 0, scene_->box2dWorld()); 43 | } 44 | } 45 | 46 | private: 47 | Scene* scene_ = nullptr; 48 | }; 49 | 50 | class Factory : public SandboxFactory { 51 | SandboxScenePackage createScenePackage(const core::PropertySet*) override { 52 | auto scene = make_unique(); 53 | auto scene_ui = make_unique(scene.get()); 54 | return { std::move(scene), std::move(scene_ui) }; 55 | } 56 | }; 57 | 58 | } // namespace bouncing_scene 59 | -------------------------------------------------------------------------------- /experimental/2d_physics/scenes/particles.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "sandbox_factory.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | using namespace std; 15 | 16 | namespace particles_scene { 17 | 18 | class Scene : public sim::Scene { 19 | public: 20 | Scene(); 21 | }; 22 | 23 | class SceneUi : public physics_ui::Box2dSceneUi { 24 | public: 25 | explicit SceneUi(Scene* scene) : scene_(scene) {} 26 | 27 | void mousePressEvent(const QPointF& pos, QMouseEvent* event) override { 28 | const auto x = float(pos.x()); 29 | const auto y = float(pos.y()); 30 | 31 | if ((event->buttons() & Qt::LeftButton) != 0) { 32 | sim::addBall(x, y, 3, scene_->box2dWorld()); 33 | } 34 | 35 | if ((event->buttons() & Qt::RightButton) != 0) { 36 | sim::addBox(x, y, 10, 2, scene_->box2dWorld()); 37 | } 38 | } 39 | 40 | void keyPressEvent(QKeyEvent* event) override { 41 | if (event->key() == Qt::Key_Space) { 42 | sim::addBullet(-95, 5, 100 * 100, 0, scene_->box2dWorld()); 43 | } 44 | } 45 | 46 | private: 47 | Scene* scene_ = nullptr; 48 | }; 49 | 50 | class Factory : public SandboxFactory { 51 | SandboxScenePackage createScenePackage(const core::PropertySet*) override { 52 | auto scene = make_unique(); 53 | auto scene_ui = make_unique(scene.get()); 54 | return { std::move(scene), std::move(scene_ui) }; 55 | } 56 | }; 57 | 58 | } // namespace particles_scene 59 | -------------------------------------------------------------------------------- /darwin_studio/perf_window.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Darwin Neuroevolution Framework Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | using namespace QtCharts; 24 | 25 | namespace Ui { 26 | class PerfWindow; 27 | } 28 | 29 | class PerfWindow : public QFrame { 30 | Q_OBJECT 31 | 32 | static constexpr int kInitialGenerations = 20; 33 | static constexpr int kXTicks = 10; 34 | static constexpr int kYTicks = 2; 35 | static constexpr float kAutoRangeScale = 1.1f; 36 | 37 | const QColor kTopSeriesColor{ 0, 0, 255 }; 38 | const QColor kAreaSeriesColor{ 100, 200, 255 }; 39 | 40 | public: 41 | explicit PerfWindow(QWidget* parent = nullptr); 42 | ~PerfWindow(); 43 | 44 | private: 45 | void updateChart(const darwin::EvolutionStage& stage); 46 | 47 | private: 48 | Ui::PerfWindow* ui; 49 | 50 | int stage_index_ = 0; 51 | QLineSeries* top_stage_series_ = new QLineSeries; 52 | }; 53 | --------------------------------------------------------------------------------