import random
WINNING_POSITION = 30
class Player:
def __init__(self, name):
self.name = name
self.position = 0
def move(self, dice_roll):
self.position += dice_roll
if self.position > WINNING_POSITION:
self.position = WINNING_POSITION
def __str__(self):
return f"{self.name} is at position {self.position}"
def roll_dice():
return random.randint(1, 6)
def main():
print("=== Welcome to Mini Ludo ===")
print(f"First to reach position {WINNING_POSITION} wins!\n")
player1 = Player("Player 1")
player2 = Player("Player 2")
turn = 1
while True:
current_player = player1 if turn == 1 else player2
input(f"{current_player.name}'s turn. Press Enter to roll the dice...")
dice = roll_dice()
print(f"{current_player.name} rolled a {dice}")
current_player.move(dice)
print(current_player)
if current_player.position == WINNING_POSITION:
print(f"🎉 {current_player.name} wins! 🎉")
break
turn = 2 if turn == 1 else 1
print("Game Over!")
if __name__ == "__main__":
main()