Python Strategy Game

📅 2024 📁 Development & AI ⏱️ 6 min read

Overview

Development of a turn-based strategy game featuring complex AI behavior. This project served as a playground for implementing advanced pathfinding algorithms and exploring scalable object-oriented design patterns.

a_star_pathfinder.py
def heuristic(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) def get_path(grid, start, goal): frontier = PriorityQueue() frontier.put(start, 0) came_from = {start: None} cost_so_far = {start: 0} # ... A* algorithm logic ...

Architecture & Patterns

The project utilizes the State pattern to manage different game phases (Menu, Combat, Victory) and the Factory pattern to instantiate various unit types with unique attributes.

unit_factory.py
class UnitFactory: @staticmethod def create_unit(unit_type): if unit_type == "soldier": return SoldierUnit(hp=100, attack=15) elif unit_type == "archer": return ArcherUnit(hp=80, attack=12) raise ValueError("Unknown Unit")

Key Features

Intelligent AI that adapts to user strategies, dynamic tactical maps, and a fully modular plugin system for adding new units without modifying the core engine.