Welcome back to one of my old games, Roll A Dozen! Due to some personal reasons, i was unable to keep the original Ra12 game alive. Thus, I have created a new thread to continue the game!
Once again, here are the objectives:
Objective:
- Players must reach exactly 12 to win.
How to Play:
- A six-sided die is used.
- The player must roll the die. If an even number is used (e.g, 2, 4, 6),
you add that number to the previous rolled number.
- If an odd number is rolled (1, 3, 5) you subtract that amount from the
previous number.
- A new count always begins with the number 1.
- The player who restarts the count must roll the dice and add/subtract the
resulting number from 1.
- The count must be restarted if:
- The count reaches zero or goes into negative numbers.
- A player rolls the same number as the previous poster.
I was inspired and wrote the game in Python:
import random
count=1
posts=0
lastnumber=7
roll=0
while count !=12: print "Current count is: " + count.__str__() roll = random.randint(1,6) print "You rolled a " + roll.__str__()
if roll % 2 == 0: print count.__str__() + " + "+roll.__str__()+ " = "+(count+roll).__str__() count += roll else: print count.__str__() + " - " + roll.__str__() + " = " + (count - roll).__str__() count -= roll
posts += 1
print "New count is %s"%count if roll == lastnumber: count = 1 posts = 0 lastnumber = 7 print "Ut oh, you rolled the same number twice. Reset. "
if count > 0: x=12 else: count = 1 posts = 0 lastnumber = 7 print "Went negative, reset. " lastnumber=roll print
print "You won! It took %s posts to get to 12." %posts
Here's this game in Java:
import java.util.*;
public class RA12 {
public static void main(String[] args) { Random rand = new Random(); int posts=0; int count=1; int lastnumber=7; int roll; while (count !=12) { System.out.println("Current count is: "+count); roll = rand.nextInt(5)+1; System.out.println("You rolled a "+roll);
posts++; System.out.println("New count is "+count);
if (roll==lastnumber) { System.out.println("Ut oh, you rolled the same number twice! Reset." count = 1; posts = 0; lastnumber = 7; }else { lastnumber=roll; }
if (count<=0) { System.out.println("Ut oh, the count reached 0 or went negative! Reset." count = 1; posts = 0; lastnumber = 7; } System.out.println(); } System.out.println("Congrats! It took "+posts+ " posts to get to 12."