Skip to content

Commit

Permalink
Merge branch 'release/1.2.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bam4d committed Sep 1, 2021
2 parents dd42222 + dd34958 commit fc3e1bd
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 34 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. 1.2.6]
- Version [e.g. 1.2.7]

**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 1.2.6)
project(Griddly VERSION 1.2.7)

set(BINARY ${CMAKE_PROJECT_NAME})

Expand Down
3 changes: 1 addition & 2 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") = "1.2.6";
m.attr("version") = "1.2.7";

#ifndef NDEBUG
spdlog::set_level(spdlog::level::debug);
Expand Down Expand Up @@ -102,7 +102,6 @@ PYBIND11_MODULE(python_griddly, m) {


py::enum_<ObserverType> observer_type(m, "ObserverType");
observer_type.value("NONE", ObserverType::NONE);
observer_type.value("SPRITE_2D", ObserverType::SPRITE_2D);
observer_type.value("BLOCK_2D", ObserverType::BLOCK_2D);
observer_type.value("ISOMETRIC", ObserverType::ISOMETRIC);
Expand Down
2 changes: 1 addition & 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 = '1.2.6'
release = '1.2.7'


# -- General configuration ---------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion docs/games/Partially_Observable_Zelda/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,15 @@ YAML
Commands:
- spawn: attack_fire
Dst:
Object: [spider, _empty]
Object: spider
Commands:
- remove: true
- Src:
Object: avatar
Commands:
- spawn: attack_fire
Dst:
Object: _empty
Objects:
- Name: avatar
Z: 3
Expand Down
9 changes: 8 additions & 1 deletion docs/games/Zelda/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,16 @@ YAML
Commands:
- spawn: attack_fire
Dst:
Object: [spider, _empty]
Object: spider
Commands:
- remove: true
- Src:
Object: avatar
Commands:
- spawn: attack_fire
Dst:
Object: _empty
Objects:
- Name: avatar
Z: 3
Expand Down
8 changes: 7 additions & 1 deletion docs/games/Zelda_Sequential/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,15 @@ YAML
Commands:
- spawn: attack_fire
Dst:
Object: [spider, _empty]
Object: spider
Commands:
- remove: true
- Src:
Object: avatar
Commands:
- spawn: attack_fire
Dst:
Object: _empty
Objects:
- Name: avatar
Z: 3
Expand Down
19 changes: 19 additions & 0 deletions docs/reference/GDY/Actions/items/Trigger/Type/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. _#/properties/Actions/items/properties/Trigger/properties/Type:

.. #/properties/Actions/items/properties/Trigger/properties/Type
Type
====

:Description: The type of trigger to use.

.. list-table::

* - **YAML Key**
- **Allowed Values**
- **Default Value**
* - ``Type``
- ``RANGE_BOX_AREA``, ``RANGE_BOX_BOUNDARY``
- ``RANGE_BOX_AREA``


4 changes: 2 additions & 2 deletions docs/reference/GDY/Actions/items/Trigger/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Trigger

* - **Property**
- **Required**
* - :ref:`TriggerType <#/properties/Actions/items/properties/Trigger/properties/TriggerType>`
* - :ref:`Type <#/properties/Actions/items/properties/Trigger/properties/Type>`
-
* - :ref:`Range <#/properties/Actions/items/properties/Trigger/properties/Range>`
-
Expand All @@ -30,5 +30,5 @@ Trigger
.. toctree::
:hidden:

TriggerType/index
Type/index
Range/index
12 changes: 6 additions & 6 deletions docs/tutorials/Proximity Triggers/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Additionally you can set a ``Probability`` for an action to set how likely the a
- Name: set_spider_on_fire_close
Probability: 1.0
Trigger:
TriggerType: RANGE_BOX_BOUNDARY
Type: RANGE_BOX_BOUNDARY
Range: 1
Behaviours:
- Src:
Expand All @@ -99,7 +99,7 @@ Additionally you can set a ``Probability`` for an action to set how likely the a
- Name: set_spider_on_fire
Probability: 0.1
Trigger:
TriggerType: RANGE_BOX_BOUNDARY
Type: RANGE_BOX_BOUNDARY
Range: 2
Behaviours:
- Src:
Expand All @@ -126,7 +126,7 @@ The action has a ``Probability`` of 0.1 of being executed.
- Name: douse_spider
Probability: 0.1
Trigger:
TriggerType: RANGE_BOX_AREA
Type: RANGE_BOX_AREA
Range: 2
Behaviours:
- Src:
Expand Down Expand Up @@ -180,7 +180,7 @@ There's a bit more boiler plate to fill out ... but otherwise proximity triggers
- Name: set_spider_on_fire_close
Probability: 1.0
Trigger:
TriggerType: RANGE_BOX_BOUNDARY
Type: RANGE_BOX_BOUNDARY
Range: 1
Behaviours:
- Src:
Expand All @@ -195,7 +195,7 @@ There's a bit more boiler plate to fill out ... but otherwise proximity triggers
- Name: set_spider_on_fire
Probability: 0.1
Trigger:
TriggerType: RANGE_BOX_BOUNDARY
Type: RANGE_BOX_BOUNDARY
Range: 2
Behaviours:
- Src:
Expand All @@ -209,7 +209,7 @@ There's a bit more boiler plate to fill out ... but otherwise proximity triggers
- Name: douse_spider
Probability: 0.1
Trigger:
TriggerType: RANGE_BOX_AREA
Type: RANGE_BOX_AREA
Range: 2
Behaviours:
- Src:
Expand Down
12 changes: 6 additions & 6 deletions python/examples/rllib/rllib_multi_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
import sys

import ray

from examples.rllib.vector_agent import VectorAgent
from griddly.util.rllib.callbacks import VideoCallbacks
from ray import tune
from ray.rllib.agents.impala import ImpalaTrainer
from ray.rllib.models import ModelCatalog
from ray.tune.registry import register_env

from griddly import gd
from griddly.util.rllib.torch.agents.conv_agent import SimpleConvAgent
from griddly.util.rllib.callbacks import VideoCallbacks
from griddly.util.rllib.environment.core import RLlibMultiAgentWrapper, RLlibEnv
from griddly.util.rllib.torch.agents.conv_agent import SimpleConvAgent

if __name__ == '__main__':
sep = os.pathsep
Expand All @@ -22,14 +20,16 @@

env_name = 'ray-ma-env'


# Create the gridnet environment and wrap it in a multi-agent wrapper for self-play
def _create_env(env_config):
env = RLlibEnv(env_config)
return RLlibMultiAgentWrapper(env, env_config)


register_env(env_name, _create_env)

ModelCatalog.register_custom_model('SimpleConv', VectorAgent)
ModelCatalog.register_custom_model('SimpleConv', SimpleConvAgent)

max_training_steps = 50000000

Expand Down Expand Up @@ -59,7 +59,7 @@ def _create_env(env_config):
'yaml_file': 'Multi-Agent/robot_tag_12.yaml',
'global_observer_type': gd.ObserverType.VECTOR,
'player_observer_type': gd.ObserverType.VECTOR,
#'max_steps': 500,
# 'max_steps': 500,
},
'entropy_coeff_schedule': [
[0, 0.01],
Expand Down
9 changes: 5 additions & 4 deletions python/examples/rllib/rllib_single_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import sys

import ray
from griddly.util.rllib.callbacks import VideoCallbacks
from ray import tune
from ray.rllib.agents.impala import ImpalaTrainer
from ray.rllib.agents.ppo import PPOTrainer
from ray.rllib.models import ModelCatalog
from ray.tune.registry import register_env

from griddly import gd
from griddly.util.rllib.torch import GAPAgent
from griddly.util.rllib.callbacks import VideoCallbacks
from griddly.util.rllib.environment.core import RLlibEnv
from griddly.util.rllib.torch import GAPAgent

if __name__ == '__main__':
sep = os.pathsep
Expand All @@ -29,6 +29,7 @@
'framework': 'torch',
'num_workers': 8,
'num_envs_per_worker': 4,
'num_gpus': 1,

'callbacks': VideoCallbacks,

Expand Down Expand Up @@ -63,4 +64,4 @@
"timesteps_total": max_training_steps,
}

result = tune.run(ImpalaTrainer, config=config, stop=stop)
result = tune.run(PPOTrainer, config=config, stop=stop)
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def griddly_package_data(config='Debug'):

setup(
name='griddly',
version="1.2.6",
version="1.2.7",
author_email="[email protected]",
description="Griddly Python Libraries",
long_description=long_description,
Expand Down
4 changes: 3 additions & 1 deletion src/Griddly/Core/Grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ std::unordered_map<uint32_t, int32_t> Grid::processCollisions() {
std::shared_ptr<Action> collisionAction = std::shared_ptr<Action>(new Action(shared_from_this(), actionName, playerId, 0));
collisionAction->init(object, collisionObject);

executeAndRecord(0, collisionAction);
auto rewards = executeAndRecord(0, collisionAction);

accumulateRewards(collisionRewards, rewards);
}
}
}
Expand Down
19 changes: 13 additions & 6 deletions tests/src/Griddly/Core/GridTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,17 +844,17 @@ TEST(GridTest, performActionTriggeredByCollision) {
EXPECT_CALL(*mockObjectPtr3, isValidAction).Times(2).WillRepeatedly(Return(true));

EXPECT_CALL(*mockObjectPtr1, onActionDst).Times(2).WillRepeatedly(Return(BehaviourResult{false, {{1, 1}}}));
EXPECT_CALL(*mockObjectPtr2, onActionDst).Times(2).WillRepeatedly(Return(BehaviourResult{false, {{1, 2}}}));
EXPECT_CALL(*mockObjectPtr3, onActionDst).Times(2).WillRepeatedly(Return(BehaviourResult{false, {{1, 3}}}));
EXPECT_CALL(*mockObjectPtr2, onActionDst).Times(2).WillRepeatedly(Return(BehaviourResult{false, {{2, 2}}}));
EXPECT_CALL(*mockObjectPtr3, onActionDst).Times(2).WillRepeatedly(Return(BehaviourResult{false, {{3, 3}}}));

EXPECT_CALL(*mockObjectPtr1, onActionSrc(Eq("object_2"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{1, 1}}}));
EXPECT_CALL(*mockObjectPtr1, onActionSrc(Eq("object_3"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{1, 1}}}));

EXPECT_CALL(*mockObjectPtr2, onActionSrc(Eq("object_1"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{1, 2}}}));
EXPECT_CALL(*mockObjectPtr2, onActionSrc(Eq("object_3"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{1, 2}}}));
EXPECT_CALL(*mockObjectPtr2, onActionSrc(Eq("object_1"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{2, 2}}}));
EXPECT_CALL(*mockObjectPtr2, onActionSrc(Eq("object_3"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{2, 2}}}));

EXPECT_CALL(*mockObjectPtr3, onActionSrc(Eq("object_2"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{1, 3}}}));
EXPECT_CALL(*mockObjectPtr3, onActionSrc(Eq("object_1"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{1, 3}}}));
EXPECT_CALL(*mockObjectPtr3, onActionSrc(Eq("object_2"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{3, 3}}}));
EXPECT_CALL(*mockObjectPtr3, onActionSrc(Eq("object_1"), _)).Times(1).WillOnce(Return(BehaviourResult{false, {{3, 3}}}));

grid->initObject("object_1", {});
grid->initObject("object_2", {});
Expand All @@ -874,6 +874,13 @@ TEST(GridTest, performActionTriggeredByCollision) {
.WillOnce(Return(std::unordered_set<std::shared_ptr<Object>>{mockObjectPtr1, mockObjectPtr2, mockObjectPtr3}));

auto rewards = grid->update();

ASSERT_EQ(rewards[0], 0);
ASSERT_EQ(rewards[1], 4);
ASSERT_EQ(rewards[2], 8);
ASSERT_EQ(rewards[3], 12);


}

} // namespace griddly

0 comments on commit fc3e1bd

Please sign in to comment.