Skip to content

Commit

Permalink
Merge branch 'release/1.2.23'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bam4d committed Dec 13, 2021
2 parents 6f4e30b + a0ab834 commit e692a3a
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 9 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.22]
- Version [e.g. 1.2.23]

**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.22)
project(Griddly VERSION 1.2.23)

set(BINARY ${CMAKE_PROJECT_NAME})

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

#ifndef NDEBUG
spdlog::set_level(spdlog::level::debug);
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.22'
release = '1.2.23'


# -- General configuration ---------------------------------------------------
Expand Down
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.22",
version="1.2.23",
author_email="[email protected]",
description="Griddly Python Libraries",
long_description=long_description,
Expand Down
64 changes: 64 additions & 0 deletions python/tests/env_state_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import numpy as np
import gym
import pytest
from griddly import GymWrapperFactory, gd

@pytest.fixture
def test_name(request):
return request.node.name


def build_test_env(test_name, yaml_file):
wrapper_factory = GymWrapperFactory()

wrapper_factory.build_gym_from_yaml(
test_name,
yaml_file,
global_observer_type=gd.ObserverType.VECTOR,
player_observer_type=gd.ObserverType.VECTOR,
)

env = gym.make(f'GDY-{test_name}-v0')
env.reset()
return env

def test_state_hash_consistent_under_nop(test_name):
"""
Test that under NOP actions, the state hash stays the same no state change other than environment steps
"""
env = build_test_env(
test_name,
"tests/gdy/test_step_SinglePlayer_SingleActionType.yaml"
)

first_state = env.get_state()
env.step(0)
second_state = env.get_state()

assert first_state['Hash'] == second_state['Hash']


def test_state_hash_consistent_return_to_state(test_name):
"""
Test that if we move to one state and back, the two states should have consistent states
"""
env = build_test_env(
test_name,
"tests/gdy/test_step_SinglePlayer_SingleActionType.yaml"
)

first_state_hashes = []
second_state_hashes = []
first_state_hashes.append(env.get_state()['Hash'])

env.step(1)
second_state_hashes.append(env.get_state()['Hash'])

env.step(3)
first_state_hashes.append(env.get_state()['Hash'])

env.step(1)
second_state_hashes.append(env.get_state()['Hash'])

assert len(set(first_state_hashes)) == 1
assert len(set(second_state_hashes)) == 1
12 changes: 8 additions & 4 deletions src/Griddly/Core/GameProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,14 @@ std::vector<uint32_t> GameProcess::getAvailableActionIdsAtLocation(glm::ivec2 lo
void GameProcess::generateStateHash(StateInfo& stateInfo) const {
// Hash global variables
for (auto variableIt : stateInfo.globalVariables) {
hash_combine(stateInfo.hash, variableIt.first);
for (auto playerVariableIt : variableIt.second) {
hash_combine(stateInfo.hash, playerVariableIt.second);
hash_combine(stateInfo.hash, playerVariableIt.first);

// Ignore the internal _steps count
if(variableIt.first != "_steps") {
hash_combine(stateInfo.hash, variableIt.first);
for (auto playerVariableIt : variableIt.second) {
hash_combine(stateInfo.hash, playerVariableIt.second);
hash_combine(stateInfo.hash, playerVariableIt.first);
}
}
}

Expand Down

0 comments on commit e692a3a

Please sign in to comment.