Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bam4d committed Mar 9, 2021
2 parents a7c2edc + 7d96fcf commit 2934c86
Show file tree
Hide file tree
Showing 504 changed files with 6,496 additions and 1,145 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. mac/linux/windows]
- Version [e.g. 0.3.3]
- Version [e.g. 1.0.0]

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10.0)
project(Griddly VERSION 0.3.3)
project(Griddly VERSION 1.0.0)

set(BINARY ${CMAKE_PROJECT_NAME})

Expand Down
17 changes: 11 additions & 6 deletions bindings/python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace griddly {

PYBIND11_MODULE(python_griddly, m) {
m.doc() = "Griddly python bindings";
m.attr("version") = "0.3.3";
m.attr("version") = "1.0.0";

#ifndef NDEBUG
spdlog::set_level(spdlog::level::debug);
Expand All @@ -34,9 +34,7 @@ PYBIND11_MODULE(python_griddly, m) {
gdy.def("get_action_input_mappings", &Py_GDYWrapper::getActionInputMappings);
gdy.def("get_avatar_object", &Py_GDYWrapper::getAvatarObject);
gdy.def("create_game", &Py_GDYWrapper::createGame);

// Get list of objects in the order of their assigned ID
gdy.def("get_object_names", &Py_GDYWrapper::getObjectNames);
gdy.def("get_level_count", &Py_GDYWrapper::getLevelCount);


py::class_<Py_GameWrapper, std::shared_ptr<Py_GameWrapper>> game_process(m, "GameProcess");
Expand All @@ -59,8 +57,6 @@ PYBIND11_MODULE(python_griddly, m) {
game_process.def("get_available_actions", &Py_GameWrapper::getAvailableActionNames);
game_process.def("get_available_action_ids", &Py_GameWrapper::getAvailableActionIds);



// Width and height of the game grid
game_process.def("get_width", &Py_GameWrapper::getWidth);
game_process.def("get_height", &Py_GameWrapper::getHeight);
Expand All @@ -78,6 +74,15 @@ PYBIND11_MODULE(python_griddly, m) {
// Get a dictionary containing the objects in the environment and their variable values
game_process.def("get_state", &Py_GameWrapper::getState);

// Get a specific variable value
game_process.def("get_global_variable", &Py_GameWrapper::getGlobalVariables);

// Get list of possible object names, ordered by ID
game_process.def("get_object_names", &Py_GameWrapper::getObjectNames);

// Get list of possible variable names, ordered by ID
game_process.def("get_object_variable_names", &Py_GameWrapper::getObjectVariableNames);

// Get a list of the events that have happened in the game up to this point
game_process.def("get_history", &Py_GameWrapper::getHistory, py::arg("purge")=true);

Expand Down
4 changes: 2 additions & 2 deletions bindings/wrapper/GDYWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class Py_GDYWrapper {
return gdyFactory_->getExternalActionNames();
}

std::vector<std::string> getObjectNames() const {
return gdyFactory_->getObjectGenerator()->getObjectNames();
uint32_t getLevelCount() const {
return gdyFactory_->getLevelCount();
}

py::dict getActionInputMappings() const {
Expand Down
36 changes: 34 additions & 2 deletions bindings/wrapper/GameWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,42 @@ class Py_GameWrapper {
return py_state;
}

py::dict getGlobalVariables(std::vector<std::string> variables) const {

py::dict py_globalVariables;
auto globalVariables = gameProcess_->getGrid()->getGlobalVariables();

for (auto variableNameIt : variables) {
std::unordered_map<int32_t, int32_t> resolvedGlobalVariableMap;

auto globalVariableMap = globalVariables[variableNameIt];

for(auto playerVariableIt : globalVariableMap) {
resolvedGlobalVariableMap.insert({playerVariableIt.first, *playerVariableIt.second});
}

py_globalVariables[variableNameIt.c_str()] = resolvedGlobalVariableMap;
}
return py_globalVariables;
}

std::vector<py::dict> getHistory(bool purge) const {
auto history = gameProcess_->getGrid()->getHistory();

std::vector<py::dict> py_events;
if (history.size() > 0) {
for (auto historyEvent : history) {
for (const auto& historyEvent : history) {
py::dict py_event;

py::dict rewards;
for (auto& reward: historyEvent.rewards) {
rewards[py::cast(reward.first)] = reward.second;
}

py_event["PlayerId"] = historyEvent.playerId;
py_event["ActionName"] = historyEvent.actionName;
py_event["Tick"] = historyEvent.tick;
py_event["Reward"] = historyEvent.reward;
py_event["Rewards"] = rewards;
py_event["Delay"] = historyEvent.delay;

py_event["SourceObjectName"] = historyEvent.sourceObjectName;
Expand All @@ -286,6 +310,14 @@ class Py_GameWrapper {
return py_events;
}

std::vector<std::string> getObjectNames() {
return gameProcess_->getGrid()->getObjectNames();
}

std::vector<std::string> getObjectVariableNames() {
return gameProcess_->getGrid()->getObjectVariableNames();
}

private:
const std::shared_ptr<TurnBasedGameProcess> gameProcess_;
const std::shared_ptr<GDYFactory> gdyFactory_;
Expand Down
18 changes: 5 additions & 13 deletions bindings/wrapper/StepPlayerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,9 @@ class Py_StepPlayerWrapper {
const std::shared_ptr<GameProcess> gameProcess_;

py::tuple performActions(std::vector<std::shared_ptr<Action>> actions, bool updateTicks) {
ActionResult actionResult;

actionResult = player_->performActions(actions, updateTicks);

int totalRewards = 0;
for (auto &r : actionResult.rewards) {
totalRewards += r;
}

auto actionResult = player_->performActions(actions, updateTicks);
auto info = buildInfo(actionResult);

return py::make_tuple(totalRewards, actionResult.terminated, info);
return py::make_tuple(actionResult.reward, actionResult.terminated, info);
}

py::dict buildInfo(ActionResult actionResult) {
Expand Down Expand Up @@ -172,6 +163,7 @@ class Py_StepPlayerWrapper {
std::shared_ptr<Action> buildAction(std::string actionName, std::vector<int32_t> actionArray) {
auto actionInputsDefinition = gdyFactory_->findActionInputsDefinition(actionName);
auto playerAvatar = player_->getAvatar();
auto playerId = player_->getId();

auto inputMappings = actionInputsDefinition.inputMappings;

Expand All @@ -185,7 +177,7 @@ class Py_StepPlayerWrapper {
auto mapping = inputMappings[actionId];
auto vectorToDest = mapping.vectorToDest;
auto orientationVector = mapping.orientationVector;
auto action = std::shared_ptr<Action>(new Action(gameProcess_->getGrid(), actionName, 0));
auto action = std::shared_ptr<Action>(new Action(gameProcess_->getGrid(), actionName, playerId, 0));
action->init(playerAvatar, vectorToDest, orientationVector, actionInputsDefinition.relative);

return action;
Expand All @@ -204,7 +196,7 @@ class Py_StepPlayerWrapper {

glm::ivec2 destinationLocation = sourceLocation + vector;

auto action = std::shared_ptr<Action>(new Action(gameProcess_->getGrid(), actionName, 0));
auto action = std::shared_ptr<Action>(new Action(gameProcess_->getGrid(), actionName, playerId, 0));
action->init(sourceLocation, destinationLocation);

return action;
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Chris Bamford'

# The full version, including alpha/beta/rc tags
release = '0.3.3'
release = '1.0.0'


# -- General configuration ---------------------------------------------------
Expand All @@ -35,6 +35,7 @@
'sphinx_rtd_theme',
'sphinxcontrib.images',
'sphinx.ext.autosectionlabel',
'sphinx_copybutton',
]

autosectionlabel_prefix_document=True
Expand Down
Binary file modified docs/games/Bait/img/Bait-level-Vector-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-level-Vector-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-level-Vector-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-level-Vector-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-level-Vector-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-tile-avatar-Vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-tile-box-Vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-tile-goal-Vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-tile-hole-Vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-tile-key-Vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-tile-mushroom-Vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait/img/Bait-tile-wall-Vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions docs/games/Bait/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. _doc_bait:

Bait
====

.. code-block::
Single-Player/GVGAI/bait.yaml
Description
-------------

Expand Down Expand Up @@ -84,6 +90,9 @@ The most basic way to create a Griddly Gym Environment. Defaults to level 0 and
env.render() # Renders the environment from the perspective of a single player
env.render(observer='global') # Renders the entire environment
if done:
emv.reset()
Objects
Expand Down
Binary file modified docs/games/Bait_With_Keys/img/Bait_With_Keys-level-Vector-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait_With_Keys/img/Bait_With_Keys-level-Vector-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait_With_Keys/img/Bait_With_Keys-level-Vector-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait_With_Keys/img/Bait_With_Keys-level-Vector-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait_With_Keys/img/Bait_With_Keys-level-Vector-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait_With_Keys/img/Bait_With_Keys-tile-box-Vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/games/Bait_With_Keys/img/Bait_With_Keys-tile-key-Vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions docs/games/Bait_With_Keys/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. _doc_bait_with_keys:

Bait With Keys
==============

.. code-block::
Single-Player/GVGAI/bait_keys.yaml
Description
-------------

Expand Down Expand Up @@ -84,6 +90,9 @@ The most basic way to create a Griddly Gym Environment. Defaults to level 0 and
env.render() # Renders the environment from the perspective of a single player
env.render(observer='global') # Renders the entire environment
if done:
emv.reset()
Objects
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions docs/games/Butterflies_and_Spiders/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. _doc_butterflies_and_spiders:

Butterflies and Spiders
=======================

.. code-block::
Single-Player/GVGAI/butterflies.yaml
Description
-------------

Expand Down Expand Up @@ -132,6 +138,9 @@ The most basic way to create a Griddly Gym Environment. Defaults to level 0 and
env.render() # Renders the environment from the perspective of a single player
env.render(observer='global') # Renders the entire environment
if done:
emv.reset()
Objects
Expand Down
Binary file modified docs/games/Clusters/img/Clusters-level-Vector-0.png
Binary file modified docs/games/Clusters/img/Clusters-level-Vector-1.png
Binary file modified docs/games/Clusters/img/Clusters-level-Vector-2.png
Binary file modified docs/games/Clusters/img/Clusters-level-Vector-3.png
Binary file modified docs/games/Clusters/img/Clusters-level-Vector-4.png
Binary file modified docs/games/Clusters/img/Clusters-tile-avatar-Vector.png
Binary file modified docs/games/Clusters/img/Clusters-tile-blue_box-Vector.png
Binary file modified docs/games/Clusters/img/Clusters-tile-green_block-Vector.png
Binary file modified docs/games/Clusters/img/Clusters-tile-green_box-Vector.png
Binary file modified docs/games/Clusters/img/Clusters-tile-red_block-Vector.png
Binary file modified docs/games/Clusters/img/Clusters-tile-red_box-Vector.png
Binary file modified docs/games/Clusters/img/Clusters-tile-spike-Vector.png
Binary file modified docs/games/Clusters/img/Clusters-tile-wall-Vector.png
9 changes: 9 additions & 0 deletions docs/games/Clusters/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. _doc_clusters:

Clusters
========

.. code-block::
Single-Player/GVGAI/clusters.yaml
Description
-------------

Expand Down Expand Up @@ -84,6 +90,9 @@ The most basic way to create a Griddly Gym Environment. Defaults to level 0 and
env.render() # Renders the environment from the perspective of a single player
env.render(observer='global') # Renders the entire environment
if done:
emv.reset()
Objects
Expand Down
Binary file modified docs/games/Cook_Me_Pasta/img/Cook_Me_Pasta-level-Vector-0.png
Binary file modified docs/games/Cook_Me_Pasta/img/Cook_Me_Pasta-level-Vector-1.png
Binary file modified docs/games/Cook_Me_Pasta/img/Cook_Me_Pasta-level-Vector-2.png
Binary file modified docs/games/Cook_Me_Pasta/img/Cook_Me_Pasta-level-Vector-3.png
Binary file modified docs/games/Cook_Me_Pasta/img/Cook_Me_Pasta-level-Vector-4.png
Binary file modified docs/games/Cook_Me_Pasta/img/Cook_Me_Pasta-level-Vector-5.png
Binary file modified docs/games/Cook_Me_Pasta/img/Cook_Me_Pasta-tile-lock-Vector.png
Binary file modified docs/games/Cook_Me_Pasta/img/Cook_Me_Pasta-tile-wall-Vector.png
9 changes: 9 additions & 0 deletions docs/games/Cook_Me_Pasta/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. _doc_cook_me_pasta:

Cook Me Pasta
=============

.. code-block::
Single-Player/GVGAI/cookmepasta.yaml
Description
-------------

Expand Down Expand Up @@ -93,6 +99,9 @@ The most basic way to create a Griddly Gym Environment. Defaults to level 0 and
env.render() # Renders the environment from the perspective of a single player
env.render(observer='global') # Renders the entire environment
if done:
emv.reset()
Objects
Expand Down
Binary file modified docs/games/Doggo/img/Doggo-level-Vector-0.png
Binary file modified docs/games/Doggo/img/Doggo-level-Vector-1.png
Binary file modified docs/games/Doggo/img/Doggo-level-Vector-2.png
Binary file modified docs/games/Doggo/img/Doggo-level-Vector-3.png
Binary file modified docs/games/Doggo/img/Doggo-level-Vector-4.png
Binary file modified docs/games/Doggo/img/Doggo-tile-doggo-Vector.png
Binary file modified docs/games/Doggo/img/Doggo-tile-stick-Vector.png
Binary file modified docs/games/Doggo/img/Doggo-tile-wall-Vector.png
9 changes: 9 additions & 0 deletions docs/games/Doggo/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. _doc_doggo:

Doggo
=====

.. code-block::
Single-Player/Mini-Grid/minigrid-doggo.yaml
Description
-------------

Expand Down Expand Up @@ -84,6 +90,9 @@ The most basic way to create a Griddly Gym Environment. Defaults to level 0 and
env.render() # Renders the environment from the perspective of a single player
env.render(observer='global') # Renders the entire environment
if done:
emv.reset()
Objects
Expand Down
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-level-Vector-0.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-level-Vector-1.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-level-Vector-2.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-level-Vector-3.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-level-Vector-4.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-tile-bookshelf-Vector.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-tile-chair-Vector.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-tile-doggo-Vector.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-tile-door-Vector.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-tile-key-Vector.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-tile-table-Vector.png
Binary file modified docs/games/Drunk_Dwarf/img/Drunk_Dwarf-tile-wall-Vector.png
9 changes: 9 additions & 0 deletions docs/games/Drunk_Dwarf/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. _doc_drunk_dwarf:

Drunk Dwarf
===========

.. code-block::
Single-Player/Mini-Grid/minigrid-drunkdwarf.yaml
Description
-------------

Expand Down Expand Up @@ -84,6 +90,9 @@ The most basic way to create a Griddly Gym Environment. Defaults to level 0 and
env.render() # Renders the environment from the perspective of a single player
env.render(observer='global') # Renders the entire environment
if done:
emv.reset()
Objects
Expand Down
Binary file modified docs/games/Eyeball/img/Eyeball-level-Vector-0.png
Binary file modified docs/games/Eyeball/img/Eyeball-tile-eye_drops-Vector.png
Binary file modified docs/games/Eyeball/img/Eyeball-tile-eyeball-Vector.png
Binary file modified docs/games/Eyeball/img/Eyeball-tile-wall-Vector.png
9 changes: 9 additions & 0 deletions docs/games/Eyeball/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. _doc_eyeball:

Eyeball
=======

.. code-block::
Single-Player/Mini-Grid/minigrid-eyeball.yaml
Description
-------------

Expand Down Expand Up @@ -48,6 +54,9 @@ The most basic way to create a Griddly Gym Environment. Defaults to level 0 and
env.render() # Renders the environment from the perspective of a single player
env.render(observer='global') # Renders the entire environment
if done:
emv.reset()
Objects
Expand Down
Binary file added docs/games/Foragers/img/Foragers-level-Vector-0.png
Binary file added docs/games/Foragers/img/Foragers-level-Vector-1.png
Binary file added docs/games/Foragers/img/Foragers-level-Vector-2.png
Loading

0 comments on commit 2934c86

Please sign in to comment.