diff --git a/docs/game.exe b/docs/game.exe new file mode 100644 index 00000000..ddb08686 Binary files /dev/null and b/docs/game.exe differ diff --git a/docs/main.cpp b/docs/main.cpp new file mode 100644 index 00000000..c83f039e --- /dev/null +++ b/docs/main.cpp @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include + +using namespace std; + +int rollDice() { + return rand() % 6 + 1; +} + +int main() { + srand(time(0)); + + map snakes = {{14, 7}, {31, 12}, {37, 3}, {73, 56}}; + map ladders = {{2, 23}, {8, 34}, {20, 77}, {32, 68}}; + + vector playerPositions = {0, 0}; // 2 players + + bool won = false; + int turn = 0; + + while (!won) { + int player = turn % playerPositions.size(); + cout << "Player " << player + 1 << "'s turn. Press Enter to roll dice."; + cin.ignore(); + + int dice = rollDice(); + cout << "Rolled a " << dice << endl; + + playerPositions[player] += dice; + + if (snakes[playerPositions[player]]) + playerPositions[player] = snakes[playerPositions[player]]; + + if (ladders[playerPositions[player]]) + playerPositions[player] = ladders[playerPositions[player]]; + + cout << "Player " << player + 1 << " is now at position " << playerPositions[player] << endl; + + if (playerPositions[player] >= 100) { + cout << "Player " << player + 1 << " wins!" << endl; + won = true; + } + + turn++; + } + + return 0; +} diff --git a/docs/main.exe b/docs/main.exe new file mode 100644 index 00000000..f10014cf Binary files /dev/null and b/docs/main.exe differ