Skip to content

Commit

Permalink
Merge pull request #3 from MSU-CSE491/development
Browse files Browse the repository at this point in the history
Merge in Development branch from class
  • Loading branch information
Felicivi authored Dec 4, 2023
2 parents 862efab + 4efb92e commit ad99169
Show file tree
Hide file tree
Showing 80 changed files with 6,329 additions and 812 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ cmake-build-*/

#mac
.DS_Store

#savedata/ #issues with xml save location

savedata/GPAgent/*.xml
#AgentData_*.xml


site
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "third_party/SFML"]
path = third_party/SFML
url = https://github.com/SFML/SFML.git
[submodule "third_party/tinyxml2"]
path = third_party/tinyxml2
url = https://github.com/leethomason/tinyxml2.git
217 changes: 154 additions & 63 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,91 +6,182 @@ project(CSE_491)
# For now, default to building both the main app and tests
set(BUILD_MAIN 1)
set(BUILD_TESTS 1)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Test")
set(BUILD_MAIN 0)
set(BUILD_TESTS 1)
endif()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Test")
set(BUILD_MAIN 0)
set(BUILD_TESTS 1)
endif ()

# Create a function to make .cmake files simpler
function(add_source_to_target TARGET_NAME SOURCE_PATH)
message(STATUS "Loading source: ${SOURCE_PATH}")
target_sources(${TARGET_NAME}
PRIVATE ${CMAKE_SOURCE_DIR}/${SOURCE_PATH}
)
message(STATUS "Loading source: ${SOURCE_PATH}")
target_sources(${TARGET_NAME}
PRIVATE ${CMAKE_SOURCE_DIR}/${SOURCE_PATH}
)
endfunction()

# Set the necessary C++ flags, some of which are configuration-specific
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wcast-align -Winfinite-recursion -Wnon-virtual-dtor -Wnull-dereference -Woverloaded-virtual -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-align -Winfinite-recursion -Wnon-virtual-dtor -Wnull-dereference -Woverloaded-virtual -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")

set(CMAKE_CXX_FLAGS_COVERAGE "-O2 -g -fcoverage-mapping -fprofile-instr-generate -fprofile-arcs")

# Place all executables in the executable directory
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/executable)

# Move assets to build directory
file(COPY ./assets DESTINATION ${CMAKE_CURRENT_BINARY_DIR})


#option(BUILD_CLANG_LLVM "Build with clang for LLVM" OFF)
option(SANITIZE_MEMORY "Build with sanitizers for GP" OFF)
if (SANITIZE_MEMORY)

set(BUILD_MAIN 0)
set(BUILD_TESTS 0)

set(CMAKE_CXX_COMPILER "/opt/homebrew/opt/llvm/bin/clang++")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory")

set(XML_SRC_DIR third_party/tinyxml2)
set(XML_BUILD_DIR xml_build)
add_subdirectory(${XML_SRC_DIR} ${XML_BUILD_DIR})

#added the executable
add_executable(gp_train_main source/gp_train_main.cpp)

#linking the targets
target_sources(gp_train_main PRIVATE source/core/Entity.cpp)
target_include_directories(gp_train_main
PRIVATE ${CMAKE_SOURCE_DIR}/source/core
${CMAKE_SOURCE_DIR}/source/Agents
)
target_link_libraries(gp_train_main
PRIVATE tinyxml2
PRIVATE pthread
)


endif ()





# Build the gp_train_main executable, if requested without SFML and Catch2
option(BUILD_GP_ONLY "Build only gp_main.cpp" OFF)
if (BUILD_GP_ONLY)
set(BUILD_MAIN 0)
set(BUILD_TESTS 0)

# Configure all of tinyxml2
set(XML_SRC_DIR third_party/tinyxml2)
set(XML_BUILD_DIR xml_build)
add_subdirectory(${XML_SRC_DIR} ${XML_BUILD_DIR})

#added the executable
add_executable(gp_train_main source/gp_train_main.cpp)

#linking the targets
target_sources(gp_train_main PRIVATE source/core/Entity.cpp)
target_include_directories(gp_train_main
PRIVATE ${CMAKE_SOURCE_DIR}/source/core
${CMAKE_SOURCE_DIR}/source/Agents
)
target_link_libraries(gp_train_main
PRIVATE tinyxml2
PRIVATE pthread
)

endif ()


# Build the main application executables, if requested
if(${BUILD_MAIN})

# Configure all of SFML
set(SFML_SRC_DIR third_party/SFML)
set(SFML_BUILD_DIR sfml_build)
add_subdirectory(${SFML_SRC_DIR} ${SFML_BUILD_DIR})

# Find all the main files for the various applications
# Currently this means any *.cpp file in the root of source
file(GLOB EXE_SOURCES CONFIGURE_DEPENDS RELATIVE ${CMAKE_SOURCE_DIR}/source source/*.cpp)
message(STATUS "List of main files to build: ${EXE_SOURCES}")

# Loop through each executable and build it!
foreach(EXE_SOURCE ${EXE_SOURCES})
# Rip the .cpp off the end of the string
string(REPLACE ".cpp" "" EXE_NAME ${EXE_SOURCE})
# Create list of source files (currently just the one .cpp file)
# Create executable and link to includes / libraries
add_executable(${EXE_NAME} ${CMAKE_SOURCE_DIR}/source/${EXE_SOURCE})
target_include_directories(${EXE_NAME}
PRIVATE ${CMAKE_SOURCE_DIR}/source
)
target_link_libraries(${EXE_NAME}
PRIVATE sfml-window sfml-audio sfml-graphics sfml-system sfml-network
)
if(EXISTS ${CMAKE_SOURCE_DIR}/source/${EXE_NAME}.cmake)
message(STATUS "Loading ${EXE_NAME}.cmake")
include(${CMAKE_SOURCE_DIR}/source/${EXE_NAME}.cmake)
else()
message(WARNING "Cannot find ${EXE_NAME}.cmake")
endif()
endforeach()
endif()
if (${BUILD_MAIN})
# line to set santizers
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=[sanitizer]")
# can be set to address, undefined, thread, memory, or leak

# Build the test executables, if requested
if(${BUILD_TESTS})

# Configure Catch
set(CATCH_SRC_DIR third_party/Catch2)
set(CATCH_BUILD_DIR catch_build)
add_subdirectory(${CATCH_SRC_DIR} ${CATCH_BUILD_DIR})

# Configure only the networking portion of SFML
if(NOT ${BUILD_MAIN})
set(SFML_BUILD_WINDOW FALSE)
set(SFML_BUILD_GRAPHICS FALSE)
set(SFML_BUILD_AUDIO FALSE)
# Configure all of SFML
set(SFML_SRC_DIR third_party/SFML)
set(SFML_BUILD_DIR sfml_build)
add_subdirectory(${SFML_SRC_DIR} ${SFML_BUILD_DIR})
endif()

# Setup CTest
include(CTest)
enable_testing()

# Tunnel into test directory CMake infrastructure
add_subdirectory(tests)
endif()
#configure the xml library
set(XML_SRC_DIR third_party/tinyxml2)
set(XML_BUILD_DIR xml_build)
add_subdirectory(${XML_SRC_DIR} ${XML_BUILD_DIR})


# Find all the main files for the various applications
# Currently this means any *.cpp file in the root of source
file(GLOB EXE_SOURCES CONFIGURE_DEPENDS RELATIVE ${CMAKE_SOURCE_DIR}/source source/*.cpp)
message(STATUS "List of main files to build: ${EXE_SOURCES}")



# Loop through each executable and build it!
foreach (EXE_SOURCE ${EXE_SOURCES})
# Rip the .cpp off the end of the string
string(REPLACE ".cpp" "" EXE_NAME ${EXE_SOURCE})
# Create list of source files (currently just the one .cpp file)
# Create executable and link to includes / libraries
add_executable(${EXE_NAME} ${CMAKE_SOURCE_DIR}/source/${EXE_SOURCE} ${CMAKE_SOURCE_DIR}/source/core/Entity.cpp)
target_include_directories(${EXE_NAME}
PRIVATE ${CMAKE_SOURCE_DIR}/source
)
target_link_libraries(${EXE_NAME}
PRIVATE sfml-window sfml-audio sfml-graphics sfml-system sfml-network
)

target_link_libraries(${EXE_NAME}
PRIVATE tinyxml2
)

if (EXISTS ${CMAKE_SOURCE_DIR}/source/${EXE_NAME}.cmake)
message(STATUS "Loading ${EXE_NAME}.cmake")
include(${CMAKE_SOURCE_DIR}/source/${EXE_NAME}.cmake)
else ()
message(WARNING "Cannot find ${EXE_NAME}.cmake")
endif ()
endforeach ()
endif ()

# Build the test executables, if requested
if (${BUILD_TESTS})

# Configure Catch
set(CATCH_SRC_DIR third_party/Catch2)
set(CATCH_BUILD_DIR catch_build)
add_subdirectory(${CATCH_SRC_DIR} ${CATCH_BUILD_DIR})


# Configure only the networking portion of SFML
if (NOT ${BUILD_MAIN})
set(SFML_BUILD_WINDOW FALSE)
set(SFML_BUILD_GRAPHICS FALSE)
set(SFML_BUILD_AUDIO FALSE)
set(SFML_SRC_DIR third_party/SFML)
set(SFML_BUILD_DIR sfml_build)
add_subdirectory(${SFML_SRC_DIR} ${SFML_BUILD_DIR})

set(XML_SRC_DIR third_party/tinyxml2)
set(XML_BUILD_DIR xml_build)
add_subdirectory(${XML_SRC_DIR} ${XML_BUILD_DIR})


endif ()


# Setup CTest
include(CTest)
enable_testing()

# Tunnel into test directory CMake infrastructure
add_subdirectory(tests)
endif ()
29 changes: 29 additions & 0 deletions assets/grids/default_maze2.grid
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# # # #
# ### # ########## # ########## # ######### #
# # # # # # # # # # # #
# # ### ## # ### # ############ ##### ### # #
# # # # # # # # # # #
# ##### # # # ### # ###### ###### ##### ### #
# # # # # # # # # # #
##### # ###### # ###### # ## # ###### ####### # ## #
# # # # ## # # # #
# ############## ##### # # # ###### # ######### #
# # # # # # # # # #
############### # ### ###### # # #### # # ##### # #
# # # # # # # # # # #
# ############### ##### # # ######## ##### # # #
# # # # # # # #
# #################### ########### # ######### #
# # # # #
# # # ################### ############# ########## #
# # # # #
# ################ ############### ####### #
# # # # # # #
# # # # # ##################################### # #
# # # # # # # # #
# # # # # # ################################### # #
# # # # # # # #
# # ################################ # #
# # # # # # # # # #
# # # # # # # ############################### # #
# # # # # # # # # #
9 changes: 9 additions & 0 deletions assets/grids/empty_maze.grid
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*
*
*
*
*
*
*
*
*
85 changes: 85 additions & 0 deletions docs/Group_7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Group 7 : Genetic Programming Agents
-- --
authors: Aman, Simon, Rajmeet, Jason



<img src="assets/GP_Group7/Group7Photo.jpeg" style="max-width: 700px">

(Img: Rajmeet, Simon, Jason, Aman)

## Introduction

## GP Agent Base Class

## LGP Agent

## CGP Agent

## GP Loop


## It runs on my machine
we have used cmake to ensure that our code compiles on all platforms. but....
we have tested our code on the following machines/architectures:
- Windows 11
- Windows 10
- Ubuntu 20.04
- HPCC Cluster Centos7
- MacOS Sonoma (ARM)
- mlcollard/linux-dev (Docker Container)

Tested in the following IDEs:
- CLion
- VSCode

Tested on the following compilers:
- gcc 9.3.0
- Apple clang 12.0.0
- LLVM clang 11.0.0

### Profiled with and optimized with:
- clion profiler
<br />/
<img src="assets/GP_Group7/ProfilerGP_Clion.png" style="max-width: 800px; max-width: 300px;">


- Xcode instruments
<br />
<img src="assets/GP_Group7/ProfilerGP_Xcode.png" style="max-width: 800px; max-width: 300px;">

- intel vtune
<br />
<img src="assets/GP_Group7/ProfilerGP_IntelVTune.png" style="max-width: 800px; max-width: 300px;">

- very sleepy
Didnt deserve a screenshot. /s

- code coverage in clion
<img src="assets/GP_Group7/CodeCoverage_Clion.png" style="max-width: 800px; max-width: 300px;">


### Sanitized with:

- clang sanitizer Memory
- valgrind
- gcc sanitizer Memory
- gcc sanitizer address
- Used to find and fix memory UB in the code.
<img src="assets/GP_Group7/UB_Behavior.png" />


## Other Contributions

### EasyLogging
Created a logging class that is can be used to log debug messages in debug mode. Teams can be specified to log with different levels of verbosity. This is useful for debugging and profiling.

### CMake
Initial cmake setup for the project. This is useful for cross platform compilation and testing.

### serializationUsingTinyXML2
Created and tested a serialization class that can be used to serialize and deserialize objects to and from xml files. This is useful for saving and loading the state of the GP agents.
Implemented serialization pattern using tinyxml2 library.

### mkdocs documentation
Created and tested a mkdocs documentation for the project. This is useful for creating a website for the project.
Binary file added docs/assets/GP_Group7/CodeCoverage_Clion.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 added docs/assets/GP_Group7/Group7Photo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/GP_Group7/ProfilerGP_Clion.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 added docs/assets/GP_Group7/ProfilerGP_IntelVtune.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 added docs/assets/GP_Group7/ProfilerGP_Xcode.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 added docs/assets/GP_Group7/UB_Behavior.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ad99169

Please sign in to comment.