Author Topic: Dice doesn't need to be this complicated.:/  (Read 6039 times)

SarahW

  • Newcomer
  • Posts: 33
  • Karma: +0/-0
    • View Profile
    • Email
Dice doesn't need to be this complicated.:/
« on: March 02, 2017, 05:26:59 AM »
I'm having a difficult understanding what this guy is trying to gain on Ruby Quiz: http://rubyquiz.com/quiz61.html

There is a much simpler way to do dice in Ruby.

eDice = ['1', '2', '3', '4, '5', '6']
3.times do
  puts eDice.sample
end

Or if you want to do it on the same line:

eDice = ['1 ', '2 ', '3 ', '4 ', '5 ', '6 ']
3.times do
  print eDice.sample
end

I don't need something so absurdly complicated for sake of being complicated, such as: dice.gsub(/d(%|00)(\D|$)/, 'd100\2') I don't get the purpose of using symbols for something that can be reasonably presented in English.

Rubygame::EventGame or whatever is bad enough.

This is why tutorials drive me nuts. It's like they like finding the most complicated solutions for simple problems.

Meanwhile I figured my own solution for the Random Dungeons not loading problem. But can't seem to find any for producing turns. The way I keep track of time is using steps. The graphic is changed using a graphic update function the input function loops three if certain variables are switched to false. The things like the @ character is drawn to the actual file being read.

Say you want to do a DnD style dice roll.

eDice = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '20']
print "You roll a D20 to overcome enemy defenses: "
puts eDice.sample
print "Enemy rolls to try to counter attack: "
puts eDice.sample

I don't get it when people decide to use symbols, it doesn't make it simpler. At least not for me. If anything it obfuscates a tutorial that should be about learning how to make a roguelike, not scratching your head on what something does.

My G.E.D. math teacher would have been wagging her finger at this guy, cause he's making it more complicated than it needs to be.

I get math, at least up to Algebra (though quite rusty on algebra). But symbols? Not what I'm here for.
« Last Edit: March 02, 2017, 05:53:10 AM by SarahW »

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: Dice doesn't need to be this complicated.:/
« Reply #1 on: March 05, 2017, 08:19:09 PM »
That tutorial is doing pretty generic dice roller, that can handle lots of different types of die. It can roll one die "d6", two dice "2d6", three different types of die "d4+d6+d8" and so on. This is the main reason why the code is rather complex. Your solution however, is much clearer when rolling single die of specific type. If only simple roll is needed, no need to build complex solution.
Everyone you will ever meet knows something you don't.
 - Bill Nye