Cyber Pet
The Cyber Pet was a first-semester C++ console application built around changing state. The player named a pet, viewed its condition, fed it, put it to bed, or played an Eye Spy minigame.
Hunger and tiredness were stored as integer values. Separate functions translated those values into descriptions and ASCII expressions, while interaction functions increased the values when the pet was fed or rested.
I used three detached background threads:
- one reduced hunger every five minutes
- one reduced tiredness every five minutes
- one recalculated mood from the combined state
The menu continued to accept input while those timers ran. That was my first attempt to make a programme change independently of the user’s current action.
The implementation also exposed concurrency problems I had not yet designed around. The threads and menu functions share global variables without synchronisation, and the mood thread loops continuously. In a later design I would use a controlled application clock, std::atomic or protected state, condition variables, and threads whose lifetime is owned and joined.
The application included more than the initial feed-and-sleep brief. The Eye Spy minigame selected an item from a set, accepted guesses, and returned the player to the pet menu. It gave the project a second interaction loop and required its own input and state handling.
Darts 501
The Darts 501 coursework was a larger object-oriented programme. It supported both simulation and interactive play, with single-player and multiplayer paths.
I divided the programme into six main classes:
BoardPlayerGameThrowResultsInteractive
The main function selected simulation or playable mode. From there, the programme constructed players, accepted names and accuracy values, selected who would throw first, and created the game or interactive objects needed for the chosen mode.
Player and game state
The Player class kept the player’s name, score, accuracy, target, strategy, wins, and round wins. Methods changed the score, reset a game, selected a target, and recorded results.
The Game class held two player pointers and applied the 501 rules. A temporary score was retained during each turn so a bust could return the player to the correct previous value. Games and rounds were recorded before the result data was passed to the Results object.
Separating the state by class made it possible to run the same game rules with different players and execution modes. It also made faults easier to isolate than they would have been in one procedural source file.
Throw simulation and strategy
The Throw class modelled bulls, singles, doubles, and trebles. A player’s accuracy affected the chance of reaching the intended target, while random variation produced misses.
The computer strategy used the remaining score to choose a route towards a valid finish. It could target the bull at 50, try to move towards 40 for a double-20 finish, halve an even score for another double, or use a single to turn an odd score into an even one.
This was a rule-based strategy rather than machine learning. Its purpose was to encode checkout decisions and give the simulation a repeatable player model.
Simulation and interactive modes
Simulation mode accepted two player profiles and a number of games, ran the matches, then calculated and displayed the results. The same object model supported interactive play, where one or two human players could enter the target and throw result through the console.
The project used manual dynamic allocation for players, games, results, and interactive objects. It also contains an old comma-expression deletion pattern that does not delete every pointer as intended. Modern C++ ownership through stack objects and smart pointers would make the lifetime rules clearer.
The stronger part of the work is the decomposition. Compared with the earlier Cyber Pet, Darts 501 has a more deliberate model of responsibilities, reusable state, game rules, strategy, and reporting. It records the point where my C++ coursework moved from functions around global state towards cooperating objects.
