This is a simple dice rolling game application. The user can specify the number of dice to roll and the number of sides on each die. The application then simulates the rolling of the dice and displays the results.
Here's a possible implementation using Python:
import random
def roll_dice(num_dice, num_sides):
"""Rolls a specified number of dice with a specified number of sides.
Args:
num_dice: The number of dice to roll.
num_sides: The number of sides on each die.
Returns:
A list of the results of each die roll.
"""
results = []
for _ in range(num_dice):
results.append(random.randint(1, num_sides))
return results
def main():
"""Gets user input and runs the dice rolling simulation."""
while True:
try:
num_dice = int(input("Enter the number of dice to roll (or 0 to quit): "))
if num_dice == 0:
break
num_sides = int(input("Enter the number of sides on each die: "))
if num_sides < 1:
print("Number of sides must be at least 1.")
continue
results = roll_dice(num_dice, num_sides)
print("Results:", results)
print("Total:", sum(results))
except ValueError:
print("Invalid input. Please enter integers only.")
if __name__ == "__main__":
main()
This application prompts the user for the number of dice and the number of sides. It then uses the random.randint() function to simulate the dice rolls and displays the individual results and their sum. Error handling is included to manage invalid user input. The user can enter 0 for the number of dice to exit the application. This is a basic example; more sophisticated features could be added (e.g., a graphical user interface, different types of dice, saving results).
Latest Version1.6.38 |
Category |
Requires AndroidAndroid 5.1+ |
Available on |