Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ Makefile
compile_commands.json
cmake_install.cmake
CMakeCache.txt

# Documentation artifacts
sphinx_docs/_build/
sphinx_docs/_doxygen/
__pycache__/
*.pyc
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
- id: clang-tidy
args: ["-p=build"]
- id: cppcheck
args: ["--enable=all", "-Iinclude/", "--quiet", "src"]
args: ["--enable=all", "-Iinclude/", "--quiet", "src", "--suppress=normalCheckLevelMaxBranches", "--suppress=checkersReport", "--suppress=missingIncludeSystem", "--suppress=useStlAlgorithm", "--suppress=unusedFunction", "--suppress=unusedStructMember", "--suppress=unmatchedSuppression", "--inline-suppr"]

- repo: https://github.com/crate-ci/typos
rev: v1.40.0
Expand All @@ -53,7 +53,7 @@ repos:
hooks:
- id: check-added-large-files
name: "📁 filesystem/🤏 size · Prevent giant files from being committed"
args: [ '--maxkb=200' ]
args: [ '--maxkb=2000' ]
- id: check-executables-have-shebangs
name: "📁 filesystem/⚙️ exec · Verify shebang presence"
- id: check-shebang-scripts-are-executable
Expand Down
67 changes: 61 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,33 @@ project(MicroMouse-Simulator LANGUAGES CXX)

# Sets the C++ standard for the entire project to C++17.
# This ensures consistency across all source files and compilers.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(CXX_EXPORT_BUILD_COMMANDS ON)

# --- SFML Integration using FetchContent (Source Code) ---
include(FetchContent)
FetchContent_Declare(
sfml
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.1
)

# Configure SFML options to build only what we need, statically
set(SFML_BUILD_WINDOW ON CACHE BOOL "" FORCE)
set(SFML_BUILD_GRAPHICS ON CACHE BOOL "" FORCE)
set(SFML_BUILD_SYSTEM ON CACHE BOOL "" FORCE)
set(SFML_BUILD_AUDIO OFF CACHE BOOL "" FORCE)
set(SFML_BUILD_NETWORK OFF CACHE BOOL "" FORCE)
set(SFML_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(SFML_BUILD_DOC OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) # Force static linking

FetchContent_MakeAvailable(sfml)

# Note: FetchContent_MakeAvailable(sfml) provides the targets SFML::Graphics, SFML::Window, etc.
# directly, so find_package is not needed. The targets will handle include directories automatically.

# --- GoogleTest Integration (Conditional) ---

# This block executes only if the user configures CMake with -DBUILD_TESTING=ON.
Expand All @@ -23,7 +46,7 @@ if(BUILD_TESTING)
GIT_TAG 52eb8108c5bdec04579160ae17225d66034bd723
# Recommended: Add DOWNLOAD_EXTRACT_TIMESTAMP TRUE for build robustness (CMP0135).
)

# Makes the googletest targets (GTest::gtest, GTest::gtest_main, etc.) available
# for linking in subsequent targets (like mms-test).
FetchContent_MakeAvailable(googletest)
Expand All @@ -38,18 +61,38 @@ endif()
# --- Core Logic Library Definition ---

# Define the source files that contain the reusable application logic.
set(CORE_SOURCES src/MazeGen.cpp)
set(CORE_SOURCES
src/model/generators/RecursiveBacktracker.cpp
src/model/generators/EllersGenerator.cpp
src/model/MazeUtils.cpp
src/view/UI.cpp
src/view/UIComponents.cpp
src/controller/Simulator.cpp
src/model/solvers/BFSSolver.cpp
src/model/solvers/DFSSolver.cpp
src/model/solvers/AStarSolver.cpp
src/model/solvers/FloodFillSolver.cpp
src/model/solvers/WallFollowerSolver.cpp
)

# Create a Static Library target. This bundles the core logic into a reusable
# library that can be linked by both the main executable and the test executable.
add_library(mms-core STATIC ${CORE_SOURCES})

# Configure Include Directories
# Configure Include Directories for mms-core
# Set the project's header directory as PUBLIC for the 'mms-core' library.
target_include_directories(mms-core
PUBLIC
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/include/model
${CMAKE_SOURCE_DIR}/include/view
${CMAKE_SOURCE_DIR}/include/controller
)
target_link_libraries(mms-core PUBLIC sfml-graphics sfml-window sfml-system)
if(WIN32)
target_link_libraries(mms-core PUBLIC comdlg32)
endif()
target_compile_definitions(mms-core PUBLIC SFML_STATIC)
# The PUBLIC keyword ensures that any target that links to 'mms-core' (like 'mms'
# and 'mms-test') automatically inherits this include path.

Expand All @@ -61,7 +104,19 @@ set(APP_SOURCES src/Main.cpp)
# Create the main executable target
add_executable(mms ${APP_SOURCES})

# Link the core logic library to the main executable.
# Link the core logic library and SFML to the main executable.
# PRIVATE linkage means the executable uses the library internally,
# but downstream targets don't need to know about it (standard best practice).
# Link the core logic library and SFML to the main executable.
# PRIVATE linkage means the executable uses the library internally,
# but downstream targets don't need to know about it (standard best practice).
target_link_libraries(mms PRIVATE mms-core)
target_link_libraries(mms PRIVATE mms-core sfml-graphics sfml-window sfml-system)

# Define SFML_STATIC to ensure headers use static linkage conventions
target_compile_definitions(mms PRIVATE SFML_STATIC)

# --- Assets Management ---
# Copy the assets directory to the build directory so the executable can find them
file(COPY "${CMAKE_SOURCE_DIR}/assets" DESTINATION "${CMAKE_BINARY_DIR}")


96 changes: 60 additions & 36 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# 🤝 Contributing to MicroMouse Simulator
# Contributing to MicroMouse Simulator

Thank you for your interest in contributing to the MicroMouse Simulator project! This guide will help you get started with contributing code, reporting issues, and following our development practices.

---

## 📋 Table of Contents
## Table of Contents

- [Getting Started](#getting-started)
- [Development Workflow](#development-workflow)
Expand All @@ -19,7 +19,7 @@ Thank you for your interest in contributing to the MicroMouse Simulator project!

---

## 🚀 Getting Started
## Getting Started

### Prerequisites

Expand Down Expand Up @@ -84,7 +84,7 @@ Before contributing, ensure you have:

---

## 🔄 Development Workflow
## Development Workflow

### Branching Model

Expand Down Expand Up @@ -165,19 +165,19 @@ git rebase dev

---

## 💻 Coding Standards
## Coding Standards

### Naming Conventions

#### 1. File Names
Use **PascalCase** for all source files:
```
✅ Good:
Correct:
- MazeGen.cpp / MazeGen.hpp
- PathFinder.cpp / PathFinder.hpp
- RobotController.cpp / RobotController.hpp

❌ Bad:
Incorrect:
- maze_gen.cpp
- pathfinder.cpp
- robot-controller.cpp
Expand All @@ -190,13 +190,13 @@ Use **PascalCase** for all source files:
#### 2. Variable Names
Use **snake_case** for variables. Names should be descriptive and self-explanatory:
```cpp
✅ Good:
Correct:
int cell_count;
double path_length;
bool is_visited;
std::vector<Position> current_path;

❌ Bad:
Incorrect:
int cc;
double pl;
bool v;
Expand All @@ -206,12 +206,12 @@ std::vector<Position> cp;
#### 3. Class Names
Use **PascalCase** for class names:
```cpp
✅ Good:
Correct:
class MazeGenerator;
class PathFinder;
class RobotController;

❌ Bad:
Incorrect:
class maze_generator;
class pathfinder;
class robot_controller;
Expand All @@ -220,30 +220,44 @@ class robot_controller;
#### 4. Function Names
Use **snake_case** for function names:
```cpp
✅ Good:
Correct:
void generate_maze();
int calculate_distance();
bool is_wall_present();

❌ Bad:
Incorrect:
void generateMaze();
int calculateDistance();
bool isWallPresent();
```

#### 5. Constants and Macros
Use **UPPER_SNAKE_CASE** for constants:
Use **UPPER_SNAKE_CASE** for all constants, including global constants, class constants, and local `static constexpr` values:
```cpp
✅ Good:
Correct:
const int MAX_MAZE_SIZE = 16;
static constexpr float K_SIDEBAR_WIDTH = 280.0F;

❌ Bad:
Incorrect:
const int maxMazeSize = 16;
```

#### 6. Global Variables and State
Avoid non-const global variables. If global state is necessary, encapsulate it in a `struct` within an anonymous namespace to maintain modularity and satisfy static analysis (`cppcoreguidelines-avoid-non-const-global-variables`):

```cpp
namespace {
struct SimulationState {
int maze_rows = 16;
bool is_solving = false;
};
SimulationState G_STATE;
}
```

---

## 🛠️ Development Tools Setup
## Development Tools Setup

### Clang-Format Configuration

Expand Down Expand Up @@ -332,7 +346,7 @@ clang-tidy src/filename.cpp -p build/

---

## 🔨 Build System
## Build System

### CMake Configuration

Expand Down Expand Up @@ -374,19 +388,14 @@ ctest --test-dir build --output-on-failure
```
MicroMouse-Simulator/
├── CMakeLists.txt # Main build configuration
├── include/ # Header files
│ └── header files (.hpp)
├── src/ # Source files
│ ├── Main.cpp
│ └── other .cpp files
└── tests/ # Test files
├── CMakeLists.txt # Test build configuration
└── test files (.cpp)
├── include/ # Header files (.hpp)
├── src/ # Source files (.cpp)
├── tests/ # Test files
```

---

## 🔒 Pre-commit Hooks
## Pre-commit Hooks

The project uses pre-commit hooks to automatically check code quality before commits. Configuration is in `.pre-commit-config.yaml`.

Expand Down Expand Up @@ -465,7 +474,7 @@ git commit --no-verify -m "WIP: temporary commit"

---

## 📝 Commitizen Configuration
## Commitizen Configuration

The project uses Commitizen (configured in `cz.yaml`) to enforce consistent commit message formatting.

Expand Down Expand Up @@ -525,20 +534,20 @@ When using `git commit` directly (not recommended, but validated by pre-commit),

**Examples:**
```bash
✅ Good:
Correct:
git commit -m "feat(pathfinding): add Dijkstra algorithm implementation"
git commit -m "fix(maze): resolve wall generation bug in corner cases"
git commit -m "docs(readme): update build instructions for Windows"

❌ Bad:
Incorrect:
git commit -m "fixed stuff"
git commit -m "updates"
git commit -m "WIP"
```

---

## 🧪 Testing Guidelines
## Testing Guidelines

### Prerequisites

Expand Down Expand Up @@ -583,9 +592,24 @@ TEST(MazeGenTest, BasicGeneration) {
}
```

## Documentation Workflow

All public classes, methods, and structures must be documented using Doxygen-style comments.

**Rule: Document in Headers ONLY**
To avoid redundancy and maintain a single source of truth, all Doxygen comments must reside in the header files (`.hpp`). Do not add Doxygen comments to implementation files (`.cpp`) for functions already documented in the header.

```cpp
/**
* @brief Brief description.
* @param name Description of parameter.
* @return Description of return value.
*/
```

---

## 📤 Submitting Changes
## Submitting Changes

### Pull Request Checklist

Expand Down Expand Up @@ -618,7 +642,7 @@ Closes #123

---

## 🐛 Reporting Issues
## Reporting Issues

### Before Opening an Issue

Expand Down Expand Up @@ -668,7 +692,7 @@ For feature requests, include:

---

## 🎯 Good First Issues
## Good First Issues

Looking for a place to start? Check out issues labeled:

Expand All @@ -678,7 +702,7 @@ Looking for a place to start? Check out issues labeled:

---

## 📚 Additional Resources
## Additional Resources

- [Git Workflow Guide](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow)
- [Conventional Commits](https://www.conventionalcommits.org/)
Expand All @@ -689,7 +713,7 @@ Looking for a place to start? Check out issues labeled:

---

## 💬 Questions?
## Questions?

If you have questions about contributing:

Expand Down
Loading