D
Daniel Moore
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
The three rules of Ruby Quiz:
1. Please do not post any solutions or spoiler discussion for this
quiz until 48 hours have elapsed from the time this message was
sent.
2. Support Ruby Quiz by submitting ideas and responses
as often as you can! Visit: <http://rubyquiz.strd6.com>
3. Enjoy!
Suggestion: A [QUIZ] in the subject of emails about the problem
helps everyone on Ruby Talk follow the discussion. Please reply to
the original quiz message, if you can.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Midpoint Displacement (#197)
Haileo Rubyists,
The [midpoint displacement algorithm][1] is used to generate random
terrain in one dimension. The idea behind the algorithm is to start
with a line segment and adjust the middle by a random amount. This is
repeated for each new segment, with a decreasing random threshold. In
the end you will end up with an interesting looking ridge line.
This week's quiz is to develop a Ruby implementation of the algorithm.
The details of the implementation are up to you, but the output should
be an array containing the heights. This can be displayed visually for
extra credit. Golfers are welcome, but easily explainable solutions
are cool too.
[1]: http://gameprogrammer.com/fractal.html#midpoint
The three rules of Ruby Quiz:
1. Please do not post any solutions or spoiler discussion for this
quiz until 48 hours have elapsed from the time this message was
sent.
2. Support Ruby Quiz by submitting ideas and responses
as often as you can! Visit: <http://rubyquiz.strd6.com>
3. Enjoy!
Suggestion: A [QUIZ] in the subject of emails about the problem
helps everyone on Ruby Talk follow the discussion. Please reply to
the original quiz message, if you can.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Midpoint Displacement (#197)
Haileo Rubyists,
The [midpoint displacement algorithm][1] is used to generate random
terrain in one dimension. The idea behind the algorithm is to start
with a line segment and adjust the middle by a random amount. This is
repeated for each new segment, with a decreasing random threshold. In
the end you will end up with an interesting looking ridge line.
This week's quiz is to develop a Ruby implementation of the algorithm.
The details of the implementation are up to you, but the output should
be an array containing the heights. This can be displayed visually for
extra credit. Golfers are welcome, but easily explainable solutions
are cool too.
[1]: http://gameprogrammer.com/fractal.html#midpoint