1

I want to simulate dice roll functionality. However, I don't get what I expect. I want to get a Dice with value ranging from 1 to 6 inclusively (dice).

I tried to find it in Eiffel Documentation, but it is very hard to do.

Dragos Strugar
  • 1,314
  • 3
  • 12
  • 30

1 Answers1

1

The following code prints values for 10 consecutive rolls:

local
    r: RANDOM
do
    across
        1 |..| 10 as i
    from
        create r.set_seed (...) -- ... is the initial "seed"
        r.start
    loop
        io.put_integer (r.item \\ 6 + 1)
        io.put_new_line
        r.forth
    end
end
Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35