Original author: Daniel Freidus

Dice is not a game. It is a dice simulator. It ask's how many times you want to roll two dices, counts how much they are together, saves result on array and prints out results at the end of program.
Easy way to simulate 1 to 1000000 rounds of two dice's.

This follows original source pretty much. Line numbers are removed with few useless variables that are replaced with direct functions.
Also added an % meter for huge number of rounds to simulate.

Randomize TIMER

DIM YesNo AS String
DIM AS Integer Totals()
DIM AS Integer Rounds, Counter, Dice1, Dice2
    COLOR 14, 0
    Print TAB(34); "Dice"
    Print TAB(15); "Creative Computing Morristown, New Jersey"

    Color 15, 0
    Print TAB(17); "Remade for FreeBASIC by E.K.Virtanen."
    Print TAB(22); "http://retro2fb.wikidot.com"
    Print TAB(29); "Public Domain"
    Print ""
    Print "" 
    Print ""

    Print "This program simulates the rolling of a pair of dice."
    Print "Enter the number of times computer will 'roll' the dice."
    Print "Then, you see results of how it did go."

    INPUT "How many rolls"; Rounds
    REDIM Totals(2 TO 12)

    FOR Counter = 1 TO Rounds
        LOCATE 13, 1 : Print "Rolling round: "; Counter ; " ("; INT((Counter / Rounds) * 100); " % finished)";
        Dice1 = INT(RND * 6) + 1
        Dice2 = INT(RND * 6) + 1
        Totals(Dice1 + Dice2) = Totals(Dice1 + Dice2) + 1
    Next Counter

    Print "Total spots", "Number of times"

    FOR Counter = 2 TO 12
        Print Counter, Totals(Counter)
    Next Counter

    Print ""
    INPUT "Try again (Y/N)"; YesNo
LOOP Until YesNo <> "y" AND YesNo <> "Y"
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.