Samik Hafeez
All work

Year 2 university group project · 2024–25 · completed

OrOgins, Year 2: a Unity game and an AI that never met

My Year 2 university group project on OrOgins, a 2015 elemental strategy game. As Project Manager I built the game in Unity while a teammate trained a reinforcement-learning agent in Python, but the two halves were never connected. This page covers the university project only; my current commercial work on OrOgins has its own page.

Context
Year 2 university group project
My role
Project Manager, Scrum Master (Sprints 1 and 3), Unity developer and tester
Team
3 students
Dates
Nov 2024 – Apr 2025
Status
Completed: a Unity game and a separate learning prototype, never connected; 15 of 26 whole-game checks passed

Stack

  • Unity
  • C#
  • Python
  • Gym
  • Stable-Baselines3 (PPO)
On this page

The brief

OrOgins is a two-player elemental strategy game whose digital version was created in 2015. In this Year 2 university project, the brief was to modernise its interface and let people play it against an AI opponent.

· 2024–25 · completed

Two halves that never met

I managed our three-person team and built the game in Unity; a teammate encoded the rules in a Python Gym environment and trained a PPO agent on it. The plan was to export the trained policy and run it inside Unity. The export was never written, nothing in Unity called the model wrapper, and when the module ended the game and the AI still could not talk to each other.

Who did what, from the design work, reflection and contribution tables
AreaMy partTeammates
ManagementProject Manager; Scrum Master for Sprints 1 and 3; project plan in Microsoft Project; risk assessment and quality plan.Trello board, GitHub; Scrum Master for Sprint 2.
Requirements and designFunctional and non-functional requirements; chose Unity over Unreal; board and piece art.Five-phase plan and player-experience questions.
Unity gameUnity set-up, board, piece prefabs, and the C# scripts for pieces, moves, capture and neutral squares.Unity game logic assigned to a teammate; the element rules stayed unfinished.
Learning environmentHelped with the environment design and debugging.Gym environment, state and action spaces, and the Pygame prototype rules.
ModelModel testing, debugging and monitoring training, with the teammate.Chose and trained PPO with Stable-Baselines3.
TestingWrote, ran and documented the test and validation scripts; analysed the failures.Model validation.
Explanatory diagramDerived from the academic repository (C# scripts, env.py, train.py, AIModelManager.cs) and the reports

Two systems that were meant to meet

Two systems that were meant to meetWhat existed on each side, and the planned bridge between them. Dashed blue parts were planned and never built; dashed red parts were started but unfinished.UNITY GAME · C# (MY BUILD)PLANNED INTEGRATIONPYTHON RL · TEAMMATE'S ENVIRONMENT AND TRAININGGame.cs controllercreates 10 pieces a side; neutralsquares fill the restPieces + move platesOrOrginsMan.cs, MovePlate.cs:click to move, captureNeutral-square ruleexperiment: fire pieces onlyElement, capture, victory andturn rulesnot implemented in UnityAIModelManagerBarracuda wrapper; never calledExport policy to ONNXMap Unity board → 100-valueobservationOriginsEnv (Gym)board rules, rewards, game-overchecksPPO trainingStable-Baselines3 MlpPolicy,100k steps configuredppo_origins.zipsaved SB3 modelPygame play loopopponent plays random legalmovesTest + validation scripts9 tests, 9 validators, 4 evaluatorsobservations, rewardschosen moveexercise the rules
Two systems that were meant to meetWhat existed on each side, and the planned bridge between them. Dashed blue parts were planned and never built; dashed red parts were started but unfinished.UNITY GAME · C# (MY BUILD)PLANNEDPYTHON RL · TEAMMATE'S ENVIRONMENT AND TRAININGGame.cs controllercreates 10 pieces a side;neutral squares fill therestPieces + move platesOrOrginsMan.cs,MovePlate.cs: click tomove, captureNeutral-square ruleexperiment: fire piecesonlyElement, capture,victory and turn rulesnot implemented in UnityAIModelManagerBarracuda wrapper; nevercalledExport policy to ONNXMap Unity board →100-value observationOriginsEnv (Gym)board rules, rewards,game-over checksPPO trainingStable-Baselines3MlpPolicy, 100k stepsconfiguredppo_origins.zipsaved SB3 modelPygame play loopopponent plays randomlegal movesTest + validationscripts9 tests, 9 validators, 4evaluators
  • Implemented
  • My contribution
  • Stored data
  • Incomplete, or a gap found in testing
  • Planned or proposed — not built
What existed on each side, and the planned bridge between them. Dashed blue parts were planned and never built; dashed red parts were started but unfinished.

The trained policy was saved in Stable-Baselines3's own format. Nothing exported it to ONNX, nothing in Unity called the Barracuda wrapper, and nothing mapped the Unity board to the environment's 100-value observation. That missing bridge is the project's main unfinished piece.

Two systems that were meant to meet

100%
Two systems that were meant to meetUNITY GAME · C# (MY BUILD)PLANNED INTEGRATIONPYTHON RL · TEAMMATE'S ENVIRONMENT AND TRAININGGame.cs controllercreates 10 pieces a side; neutralsquares fill the restPieces + move platesOrOrginsMan.cs, MovePlate.cs:click to move, captureNeutral-square ruleexperiment: fire pieces onlyElement, capture, victory andturn rulesnot implemented in UnityAIModelManagerBarracuda wrapper; never calledExport policy to ONNXMap Unity board → 100-valueobservationOriginsEnv (Gym)board rules, rewards, game-overchecksPPO trainingStable-Baselines3 MlpPolicy,100k steps configuredppo_origins.zipsaved SB3 modelPygame play loopopponent plays random legalmovesTest + validation scripts9 tests, 9 validators, 4 evaluatorsobservations, rewardschosen moveexercise the rules
Text version of this diagram

Parts

  • Unity game · C# (my build)
    • Game.cs controller — creates 10 pieces a side; neutral squares fill the rest; my contribution
    • Pieces + move plates — OrOrginsMan.cs, MovePlate.cs: click to move, capture; my contribution
    • Neutral-square rule — experiment: fire pieces only; incomplete or failed in testing; my contribution
    • Element, capture, victory and turn rules — not implemented in Unity; incomplete or failed in testing
    • AIModelManager — Barracuda wrapper; never called; incomplete or failed in testing
  • Planned integration (planned, not built)
    • Export policy to ONNX — planned, not built
    • Map Unity board → 100-value observation — planned, not built
  • Python RL · teammate's environment and training
    • OriginsEnv (Gym) — board rules, rewards, game-over checks; teammate
    • PPO training — Stable-Baselines3 MlpPolicy, 100k steps configured; teammate
    • ppo_origins.zip — saved SB3 model
    • Pygame play loop — opponent plays random legal moves; teammate
  • Test + validation scripts — 9 tests, 9 validators, 4 evaluators; my contribution; I wrote, ran and documented the model tests

Connections

  • Game.cs controller → Pieces + move plates
  • Pieces + move plates → Neutral-square rule
  • Game.cs controller → Element, capture, victory and turn rules (incomplete or failed in testing)
  • OriginsEnv (Gym) → PPO training: observations, rewards
  • PPO training → ppo_origins.zip
  • OriginsEnv (Gym) → Pygame play loop
  • ppo_origins.zip → Export policy to ONNX (planned, not built)
  • Export policy to ONNX → AIModelManager (planned, not built)
  • Map Unity board → 100-value observation → AIModelManager (planned, not built)
  • AIModelManager → Game.cs controller: chosen move (planned, not built)
  • Test + validation scripts → OriginsEnv (Gym): exercise the rules

What the agent learned from, what the tests showed, and how we ran it

Reading the environment code shows how narrow the agent's choice really was. It picks a square; the environment then moves that piece to the first legal destination it finds. Rewards say “legal move” or “illegal move” and ±100 at the end, so good play was never directly rewarded.

Explanatory diagramDerived from OriginsEnv.step() and reset() in env.py and the PPO settings in train.py

One step of the observation–action–reward loop, as coded

One step of the observation–action–reward loop, as codedOne step of training as the environment implements it. Dashed red boxes mark mismatches found by reading the code: reward sign and declared observation bounds.PPO policy (MlpPolicy)one policy plays both sidesAction: a square, 0–79the policy never picks a destinationOwn piece on that square?Reward −1same player tries againAny legal move?Reward −1turn passesTake the first legal destinationfixed direction orderMove, convert path squares,capturereward +1Game over?both arrived, a royal lost, or nomovesReward ±100 and resetsign follows the mover, not the winnerSwitch turnObservation: 100 integers80 squares, turn, 4 arrival flags,padding; bounds declared ±3 butpieces use ±6noyesnoyesyesnonext step
One step of the observation–action–reward loop, as codedOne step of training as the environment implements it. Dashed red boxes mark mismatches found by reading the code: reward sign and declared observation bounds.PPO policy (MlpPolicy)one policy plays bothsidesAction: a square, 0–79the policy never picks adestinationOwn piece on thatsquare?Reward −1same player tries againAny legal move?Reward −1turn passesTake the first legaldestinationfixed direction orderMove, convert pathsquares, capturereward +1Game over?both arrived, a royallost, or no movesReward ±100 andresetsign follows the mover,not the winnerSwitch turnObservation: 100integers80 squares, turn, 4 arrivalflags, padding; boundsdeclared ±3 but piecesuse ±6noyesnoyesyesno
  • Implemented
  • Decision
  • Incomplete, or a gap found in testing
One step of training as the environment implements it. Dashed red boxes mark mismatches found by reading the code: reward sign and declared observation bounds.

One step of the observation–action–reward loop, as coded

100%
One step of the observation–action–reward loop, as codedPPO policy (MlpPolicy)one policy plays both sidesAction: a square, 0–79the policy never picks a destinationOwn piece on that square?Reward −1same player tries againAny legal move?Reward −1turn passesTake the first legal destinationfixed direction orderMove, convert path squares,capturereward +1Game over?both arrived, a royal lost, or nomovesReward ±100 and resetsign follows the mover, not the winnerSwitch turnObservation: 100 integers80 squares, turn, 4 arrival flags,padding; bounds declared ±3 butpieces use ±6noyesnoyesyesnonext step
Text version of this diagram

Parts

  • PPO policy (MlpPolicy) — one policy plays both sides; teammate
  • Action: a square, 0–79 — the policy never picks a destination
  • Own piece on that square?
  • Reward −1 — same player tries again
  • Any legal move?
  • Reward −1 — turn passes
  • Take the first legal destination — fixed direction order
  • Move, convert path squares, capture — reward +1
  • Game over? — both arrived, a royal lost, or no moves
  • Reward ±100 and reset — sign follows the mover, not the winner; incomplete or failed in testing
  • Switch turn
  • Observation: 100 integers — 80 squares, turn, 4 arrival flags, padding; bounds declared ±3 but pieces use ±6; incomplete or failed in testing

Connections

  • PPO policy (MlpPolicy) → Action: a square, 0–79
  • Action: a square, 0–79 → Own piece on that square?
  • Own piece on that square? → Reward −1: no
  • Own piece on that square? → Any legal move?: yes
  • Any legal move? → Reward −1: no
  • Any legal move? → Take the first legal destination: yes
  • Take the first legal destination → Move, convert path squares, capture
  • Move, convert path squares, capture → Game over?
  • Game over? → Reward ±100 and reset: yes
  • Game over? → Switch turn: no
  • Switch turn → Observation: 100 integers
  • Reward −1 → Observation: 100 integers
  • Reward −1 → Observation: 100 integers
  • Observation: 100 integers → PPO policy (MlpPolicy): next step

Without capture and victory rules in place, a win rate could not measure anything, so I tested what could be checked deterministically. The failures were the useful part: they pointed at missing rules rather than at the learning code.

Test and validation results recorded in the final reflection

  • Board dimensions Passed10 columns × 8 rows
  • Board initialisation MixedPieces and starting positionsTests passed; the stricter validator failed 1 of 4 checks.
  • Observation encoding PassedLength and piece codes of the 100-value observation
  • Element interactions MixedThe strength cycle, including fire against airTests passed; the air-against-earth validation crashed with an index error.
  • Movement FailedPieces move in their allowed directions“Evolutionist man should move up”.
  • Turn switching FailedThe turn passes after a move
  • Destination timing MixedThe goal rows are recognisedStalemate after a maximum number of turns failed.
  • AI decision checks MixedCapture and protective moves are availableChecks the rules, never the trained policy; strategic progress failed.
  • Whole-game validation Mixed26 rule checks across the environment15 of 26 passed.

Several copies of the environment existed, so these results describe the build tested at the time, not a single final version.

Terminal output: board dimensions test passed (8x10 grid confirmed), initial piece placement test passed, starting positions test passed, all board initialisation tests passed.
Test outputBoard initialisation tests passing, from the Year 2 final reflection.Open full size

We worked in Agile sprints with a Trello backlog, stand-ups and reviews; SDLC structured the game track and CRISP-DM the learning track. Sprint 1 ran long because Unity and the rules took far more time than planned, so by the time the environment and PPO arrived there was little room left to connect them.

Explanatory diagramDerived from the sprint plan and contribution tables in the final reflection

Three sprints, two tracks, one unfinished connection

Three sprints, two tracks, one unfinished connectionDecJan 2025FebMarAprSPRINTSSprint 1SM: meSprint 2SM: teammateS3GAME TRACK (SDLC)Requirements, plans, Unity board and piecesLEARNING TRACK(CRISP-DM)Gym environment+ PPO (teammate)INTEGRATIONTrained policy insideUnity: not reachedTESTINGTests + validation
Sprint goals and my part in each
SprintTeam goal (sprint plan)My part
Sprint 125 Nov – 16 MarInitialise the project, set up Unity, build the board and pieces.Scrum Master. Requirements, project, risk and quality plans; Unity setup, board, pieces and C# scripts.
Sprint 217 Mar – 3 AprCustom Gym environment, PPO training and integration.Model testing and debugging with the teammate who built the environment.
Sprint 34 Apr – 6 AprCompletion, evaluation, validation and the presentation.Scrum Master. Ran and documented the test and validation scripts; sprint review.
  1. Sprint 125 Nov – 16 MarScrum Master: me

    Initialise the project, set up Unity, build the board and pieces.

    My part Requirements, project, risk and quality plans; Unity setup, board, pieces and C# scripts.

    • Game track (SDLC) Requirements, plans, Unity board and pieces
  2. Sprint 217 Mar – 3 Apr

    Custom Gym environment, PPO training and integration.

    My part Model testing and debugging with the teammate who built the environment.

    • Learning track (CRISP-DM) Gym environment + PPO (teammate)
    • Integration Trained policy inside Unity: not reached
  3. Sprint 34 Apr – 6 AprScrum Master: me

    Completion, evaluation, validation and the presentation.

    My part Ran and documented the test and validation scripts; sprint review.

    • Integration Trained policy inside Unity: not reached
    • Testing Tests + validation
  • Sprint or work
  • Mine
  • Planned, not reached
Sprint dates from the final reflection. Tinted sprints are the ones I ran as Scrum Master; the dashed blue bar is the integration the team planned but did not reach.

Three sprints, two tracks, one unfinished connection

100%
Three sprints, two tracks, one unfinished connectionDecJan 2025FebMarAprSPRINTSSprint 1SM: meSprint 2SM: teammateS3GAME TRACK (SDLC)Requirements, plans, Unity board and piecesLEARNING TRACK(CRISP-DM)Gym environment+ PPO (teammate)INTEGRATIONTrained policy insideUnity: not reachedTESTINGTests + validation
Text version of this diagram
  • Sprint 1 (25 Nov – 16 Mar): Initialise the project, set up Unity, build the board and pieces. I was Scrum Master. My part: Requirements, project, risk and quality plans; Unity setup, board, pieces and C# scripts.
  • Sprint 2 (17 Mar – 3 Apr): Custom Gym environment, PPO training and integration. My part: Model testing and debugging with the teammate who built the environment.
  • Sprint 3 (4 Apr – 6 Apr): Completion, evaluation, validation and the presentation. I was Scrum Master. My part: Ran and documented the test and validation scripts; sprint review.
  • Game track (SDLC): Requirements, plans, Unity board and pieces (25 Nov – 16 Mar)
  • Learning track (CRISP-DM): Gym environment + PPO (teammate) (17 Mar – 3 Apr)
  • Integration: Trained policy inside Unity: not reached (17 Mar – 6 Apr)
  • Testing: Tests + validation (4 Apr – 6 Apr)
Explanatory diagramDerived from the CRISP-DM figure and text in the final reflection

CRISP-DM for the learning track

CRISP-DM for the learning trackCRISP-DMreinforcement learning has no fixed dataset: theenvironment is the data01Business understandingAn AI opponent for atwo-player strategy game02Data understandingRules, board state, actions andobservations03Data preparationRules coded into OriginsEnv;only legal moves allowed04ModellingPPO with Stable-Baselines3(teammate)05EvaluationMy test and validation scripts;rule checks, not a win rate06DeploymentPolicy inside the Unity game:not reached
  1. Business understandingAn AI opponent for a two-player strategy game
  2. Data understandingRules, board state, actions and observations
  3. Data preparationRules coded into OriginsEnv; only legal moves allowed
  4. ModellingPPO with Stable-Baselines3 (teammate)
  5. EvaluationMy test and validation scripts; rule checks, not a win rate
  6. DeploymentPolicy inside the Unity game: not reached
  • Stage
  • My contribution
  • Incomplete, or a gap found in testing
  • Not reached
The learning track mapped to CRISP-DM. Evaluation was mine and only partial; deployment into Unity was not reached.

CRISP-DM for the learning track

100%
CRISP-DM for the learning trackCRISP-DMreinforcement learning has no fixed dataset: theenvironment is the data01Business understandingAn AI opponent for atwo-player strategy game02Data understandingRules, board state, actions andobservations03Data preparationRules coded into OriginsEnv;only legal moves allowed04ModellingPPO with Stable-Baselines3(teammate)05EvaluationMy test and validation scripts;rule checks, not a win rate06DeploymentPolicy inside the Unity game:not reached
Text version of this diagram
  1. Business understanding: An AI opponent for a two-player strategy game
  2. Data understanding: Rules, board state, actions and observations
  3. Data preparation: Rules coded into OriginsEnv; only legal moves allowed
  4. Modelling: PPO with Stable-Baselines3 (teammate)
  5. Evaluation: My test and validation scripts; rule checks, not a win rate (my contribution)
  6. Deployment: Policy inside the Unity game: not reached (not done)

What I took from it

Situation
An unfamiliar engine, complex rules and two technologies developed side by side.
Task
Plan the work, build the Unity foundation and keep the team heading for a working game with an AI opponent.
Action
I set up the plans, built the board and scripts, and turned testing into a record of which rules worked and which did not.
Result
A Unity prototype and a separate trained-agent pipeline, but no working connection between them.
Learning
Plan smaller end-to-end milestones, agree one environment specification, and test the integration boundary first.
  • Test the connection first: the game and the model never met.
  • Keep the rules in one place: they lived in both Unity and Python, and neither copy was complete.
  • Reward good play, not just legal play: the agent was rewarded for legal moves.
  • Test the policy, not only the rules: our checks never loaded the trained model.

OrOgins later became a separate commercial project, where I am Technical Lead. That work has its own page.

Contact

I’m open to graduate and early-career roles in AI, machine learning and software engineering. Get in touch to discuss a role or my project work.