Skip to content

Commit

Permalink
Merge branch 'release/1.2.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bam4d committed Nov 15, 2021
2 parents ac9911c + aa99abc commit 8650f8a
Show file tree
Hide file tree
Showing 85 changed files with 600 additions and 529 deletions.
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
BasedOnStyle: Google
---
Language: Cpp
UseTab: Never
ColumnLimit: 0
6 changes: 6 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Checks: "*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-modernize-use-trailing-return-type,-llvm-*,-llvmlibc-*"
WarningsAsErrors: "*"
HeaderFilterRegex: ""
FormatStyle: none
CheckOptions:
- key: altera-struct-pack-align.No
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.12]
- Version [e.g. 1.2.13]

**Additional context**
Add any other context about the problem here.
18 changes: 14 additions & 4 deletions 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.12)
project(Griddly VERSION 1.2.13)

set(BINARY ${CMAKE_PROJECT_NAME})

Expand Down Expand Up @@ -34,6 +34,8 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Don't use e.g. GNU extension (like -std=gnu++11) for portability
set(CMAKE_CXX_EXTENSIONS OFF)
# Relevant cmake files are in this folder
set(CMAKE_CONFIG_FOLDER ${CMAKE_SOURCE_DIR}/cmake)

# GLM
add_subdirectory("libs/glm")
Expand All @@ -48,6 +50,14 @@ set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "disable yaml contrib")
set(YAML_BUILD_SHARED_LIBS OFF CACHE BOOL "disable shared libs")
add_subdirectory("libs/yaml-cpp")

#enable clang-format and clang-tidy project wide
include(${CMAKE_CONFIG_FOLDER}/settings/Clang-cxx-dev-tools.cmake)

# standard compiler warnings
add_library(project_warnings INTERFACE)
include(${CMAKE_CONFIG_FOLDER}/settings/CompilerWarnings.cmake)
set_project_warnings(project_warnings)


find_package(Vulkan REQUIRED FATAL_ERROR)
set(VULKAN_SHADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Griddly/Core/Observers/Vulkan/resources/shaders)
Expand Down Expand Up @@ -84,7 +94,7 @@ set(STB_DIR "libs/stb")
include_directories(${STB_DIR})

add_library(${BINARY} STATIC ${GRIDDLY_SOURCES})
target_link_libraries(${BINARY} PRIVATE Vulkan::Vulkan yaml-cpp glm)
target_link_libraries(${BINARY} PRIVATE project_warnings Vulkan::Vulkan yaml-cpp glm)

# Add the pybind11 module
set(PYTHON_MODULE python_griddly)
Expand All @@ -99,7 +109,7 @@ if(MSVC)
endif()

set_target_properties(${PYTHON_MODULE} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIR})
target_link_libraries(${PYTHON_MODULE} PRIVATE ${BINARY} Vulkan::Vulkan yaml-cpp glm)
target_link_libraries(${PYTHON_MODULE} PRIVATE ${BINARY} project_warnings Vulkan::Vulkan yaml-cpp glm )

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
Expand All @@ -110,5 +120,5 @@ include(CTest)
enable_testing()

if(BUILD_TESTING)
add_subdirectory (tests)
add_subdirectory(tests)
endif()
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.12";
m.attr("version") = "1.2.13";

#ifndef NDEBUG
spdlog::set_level(spdlog::level::debug);
Expand Down
20 changes: 20 additions & 0 deletions cmake/settings/Clang-cxx-dev-tools.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
file(GLOB_RECURSE
ALL_CXX_SOURCE_FILES
src/*.[ch]pp
src/*.h
tests/*.[ch]pp
tests/*.h
)

# Adding clang-format target if executable is found
message(STATUS "finding clang format")
find_program(CLANG_FORMAT "clang-format")
if(CLANG_FORMAT)
add_custom_target(
clang-format
COMMAND ${CLANG_FORMAT}
-i
-style=file
${ALL_CXX_SOURCE_FILES}
)
endif()
87 changes: 87 additions & 0 deletions cmake/settings/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
function(set_project_warnings project_name)

set(MSVC_WARNINGS
/W4 # Baseline reasonable warnings
/w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss
# of data
/w14254 # 'operator': conversion from 'type1:field_bits' to
# 'type2:field_bits', possible loss of data
/w14263 # 'function': member function does not override any base class
# virtual member function
/w14265 # 'classname': class has virtual functions, but destructor is not
# virtual instances of this class may not be destructed correctly
/w14287 # 'operator': unsigned/negative constant mismatch
/we4289 # nonstandard extension used: 'variable': loop control variable
# declared in the for-loop is used outside the for-loop scope
/w14296 # 'operator': expression is always 'boolean_value'
/w14311 # 'variable': pointer truncation from 'type1' to 'type2'
/w14545 # expression before comma evaluates to a function which is missing
# an argument list
/w14546 # function call before comma missing argument list
/w14547 # 'operator': operator before comma has no effect; expected
# operator with side-effect
/w14549 # 'operator': operator before comma has no effect; did you intend
# 'operator'?
/w14555 # expression has no effect; expected expression with side- effect
/w14619 # pragma warning: there is no warning number 'number'
/w14640 # Enable warning on thread un-safe static member initialization
/w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may
# cause unexpected runtime behavior.
/w14905 # wide string literal cast to 'LPSTR'
/w14906 # string literal cast to 'LPWSTR'
/w14928 # illegal copy-initialization; more than one user-defined
# conversion has been implicitly applied
/permissive- # standards conformance mode for MSVC compiler.
)

set(CLANG_WARNINGS
-Wall
-Wextra # reasonable and standard
-Wshadow # warn the user if a variable declaration shadows one from a
# parent context
-Wnon-virtual-dtor # warn the user if a class with virtual functions has a
# non-virtual destructor. This helps catch hard to
# track down memory errors
-Wold-style-cast # warn for c-style casts
-Wcast-align # warn for potential performance problem casts
-Wunused # warn on anything being unused
-Woverloaded-virtual # warn if you overload (not override) a virtual
# function
-Wpedantic # warn if non-standard C++ is used
-Wconversion # warn on type conversions that may lose data
#-Wsign-conversion # warn on sign conversions
-Wnull-dereference # warn if a null dereference is detected
-Wdouble-promotion # warn if float is implicit promoted to double
-Wformat=2 # warn on security issues around functions that format output
# (ie printf)
)

if (WARNINGS_AS_ERRORS)
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
endif()

set(GCC_WARNINGS
${CLANG_WARNINGS}
-Wmisleading-indentation # warn if indentation implies blocks where blocks
# do not exist
-Wduplicated-cond # warn if if / else chain has duplicated conditions
-Wduplicated-branches # warn if if / else branches have duplicated code
-Wlogical-op # warn about logical operations being used where bitwise were
# probably wanted
-Wuseless-cast # warn if you perform a cast to the same type
)

if(MSVC)
set(PROJECT_WARNINGS ${MSVC_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(PROJECT_WARNINGS ${CLANG_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(PROJECT_WARNINGS ${GCC_WARNINGS})
else()
message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif()

target_compile_options(${project_name} INTERFACE ${PROJECT_WARNINGS})

endfunction()
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.12'
release = '1.2.13'


# -- General configuration ---------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions python/examples/clone_environments/clone_environments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gym
import griddly
import numpy as np

env = gym.make('GDY-Sokoban-v0')
Expand Down
29 changes: 21 additions & 8 deletions python/griddly/GymWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,16 @@ def step(self, action):
else:
raise ValueError(f'The supplied action is in the wrong format for this environment.\n\n'
f'A valid example: {self.action_space.sample()}')

for p in range(self.player_count):
# Copy only if the environment is done (it will reset itself)
# This is because the underlying data will be released
self._player_last_observation[p] = np.array(self._players[p].observe(), copy=False)
# In the case where the environment is cloned, but no step has happened to replace the last obs,
# we can do that here
if len(self._player_last_observation) == 0:
for p in range(self.player_count):
self._player_last_observation.append(np.array(self._players[p].observe(), copy=False))
else:
for p in range(self.player_count):
# Copy only if the environment is done (it will reset itself)
# This is because the underlying data will be released
self._player_last_observation[p] = np.array(self._players[p].observe(), copy=False)

obs = self._player_last_observation[0] if self.player_count == 1 else self._player_last_observation

Expand All @@ -169,6 +174,9 @@ def reset(self, level_id=None, level_string=None, global_observations=False):

self.initialize_spaces()

for p in range(self.player_count):
self._player_last_observation.append(np.array(self._players[p].observe(), copy=False))

if global_observations:
self._global_last_observation = np.array(self.game.observe(), copy=False)

Expand Down Expand Up @@ -203,9 +211,6 @@ def initialize_spaces(self):

self.action_space = self._create_action_space()

for p in range(self.player_count):
self._player_last_observation.append(np.array(self._players[p].observe(), copy=False))

def render(self, mode='human', observer=0):

if observer == 'global':
Expand All @@ -223,6 +228,12 @@ def render(self, mode='human', observer=0):
return ascii_string

else:
# In the case where the environment is cloned, but no step has happened to replace the last obs,
# we can do that here
if len(self._player_last_observation) == 0:
for p in range(self.player_count):
self._player_last_observation.append(np.array(self._players[p].observe(), copy=False))

observation = self._player_last_observation[observer]
if self._player_observer_type[observer] == gd.ObserverType.VECTOR:
observation = self._vector2rgb.convert(observation)
Expand Down Expand Up @@ -261,6 +272,8 @@ def close(self):

self._renderWindow = {}

self.game.release()

def __del__(self):
self.close()

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.12",
version="1.2.13",
author_email="[email protected]",
description="Griddly Python Libraries",
long_description=long_description,
Expand Down
Loading

0 comments on commit 8650f8a

Please sign in to comment.