Stock Market Simulator main e8c3612
A game that provides a realistic stock buying experience with unpredictable trends to test investment strategies.
|
Name | UID | Profile |
---|---|---|
Cheng Ho Ming | 3036216734 | |
Chung Shing Hei | 3036216760 | |
Chow Yui Hei | 3036222446 | |
Chu Chun Yin | 3036270778 | |
Wong Sonny | 3036222458 |
"Stock Market Simulator" is a game that attempts to introduce a realistic stock buying experience to players. The game utilizes the random number generation capability of the operating system to mimic real-life stock unpredictable trends while giving players breathing room to better think about their investing strategies.
Prerequisite:
g++
compiler that supports C++17
make
To compile:
To run the game:
Or if you prefer one step:
To ensure an optimal gaming experience, please adopt the following recommendations before running the game:
Maximize your terminal window to its fullest extent.
On Windows, you can achieve this by pressing the Alt+Enter
key combination, which will toggle the terminal to fullscreen mode.
Reduce your terminal's font size initially.
Unsuitably large font sizes may cause the table displaying stock information and data to be cut off or misaligned within the terminal window.
Start with a smaller font size, such as 10
, to ensure the stock table displays correctly, and then increase the size if needed.
After displaying the ASCII game logo, you will be prompted by this screen:
Type 0
and press Enter
. Type your preferred name and press Enter
again.
Now you should enter the game's main menu.
Some user inputs the game receives (case-insensitive):
B
: Buy a stock.S
: Sell a stock.T
: Select a stock (or 0
for Happy Stock Index) to display a corresponding price history graph, which shows the historical performance of a stock and the fluctuations in stock price. Enter T
again to hide the pop-up.E
: Display all ongoing events that affect the performance of stocks. Enter E
again to hide the pop-up.N
: Proceed to the next round. The game will generate new stock prices and events.X
: Exit the game.You may wonder why there is no save button. The answer is — you don't need it!
Each time when you enter N: Next Round
, the game data is saved automatically in the saves/
folder. See more information on File I/O part.
Table column explanation:
#
: The index of the stock. You will enter it when you are purchasing/selling a stock.Category
: The respective categories a stock corresponds to. Some events are applied to a specific category only!Name
: Self-explainatory.$Price
: The current price (per unit) of the stock.Change
: The change in the stock price compared to the last round.Change
: The percentage change of stock price.#Has
: Number of stocks that you can sell.#Max
: Number of stocks that you can buy. This takes account of trading_fees_percent
.Some additional columns are hidden, they served for debugging purposes only.
Generation of stock prices:
Generation of in-game events:
Stock_event.probability_permille
member variable.In stock.h, we declared class Stock which utilizes STL vector
, list
and map
to store various game data.
The class Stock
itself represents an Stock object, which you can purchase, sell, generate a new price for it, etc.
Other than class Stock
, we have struct Stock_event that represents an in-game event.
std::vector<float>
that stores the history of the stock prices.std::list<Stock_event>
that stores on-going events that applies to the stock itself.std::map<stock_modifiers, float>
that stores the properties related to stock price generation.This game provides players with the ability to create a new save file, load an existing save, or delete a save upon starting the game. The save files are distinguished by the std::string playerName
variable.
.save
file.playerstatus.save
file.hsi.save
file.To prevent loss of progress and prevent rollbacks, the game automatically saves the current state at the end of every round.
The game heavily relies on the <filesystem>
library introduced in C++17
to maintain file organization. This library enables the game to:
If you are running the game on macOS
or Linux
and not from the terminal, the saves
folder will be located in the root directory.
We split our program codes into multiple files according to their functionality and purpose. Click me to see the details of each file.
We enforce our code formatting style via the use of clang-format tool. You can see our configuration file here.
For naming styles, different members of our group has different preferences. Some notable examples (list may not include all styles and files):
We place a strong emphasis on code documentation in our project. We utilize the JavaDoc
format to write our comments, which enables seamless integration with third-party documentation auto-generation tools like Doxygen.
If you've noticed the numerous hyperlinks throughout this README.md
file, they are pointing to the automatically generated documentation hosted on our GitHub Pages site. You can access this documentation by clicking here.
For printing prettified tables in our code, we used the VariadicTable library. VariadicTable is a third-party header-only library licensed under LGPL-2.1.
The logo used in this game is generated with Text to ASCII.
Back to top