#include #include #include #define BOARD_SIZE 100 // Function to roll a dice and get a random number between 1 and 6 int rollDice() { return (rand() % 6) + 1; } // Function to display the board (simplified) void displayBoard(int playerPosition) { printf("\nLudo Board (Player's Position):\n"); for (int i = 1; i <= BOARD_SIZE; i++) { if (i == playerPosition) printf("[P] "); else printf("[ ] "); if (i % 10 == 0) printf("\n"); } } int main() { int playerPosition = 1; int diceValue; char choice; // Initialize random number generator srand(time(NULL)); printf("Welcome to the simple Ludo Game!\n"); // Main game loop while (playerPosition < BOARD_SIZE) { printf("\nPlayer's current position: %d\n", playerPosition); displayBoard(playerPosition); // Roll the dice printf("\nPress 'r' to roll the dice or 'q' to quit: "); scanf(" %c", &choice); if (choice == 'q') { printf("\nGame Over. You chose to quit.\n"); break; } if (choice == 'r') { diceValue = rollDice(); printf("You rolled a %d\n", diceValue); // Move the player playerPosition += diceValue; // Check if the player goes beyond the board size if (playerPosition > BOARD_SIZE) { playerPosition = BOARD_SIZE; } // Check if the player reaches the finish line if (playerPosition == BOARD_SIZE) { printf("\nCongratulations! You reached the end of the board!\n"); break; } } else { printf("\nInvalid choice! Please press 'r' to roll or 'q' to quit.\n"); } } return 0; }