junglejourney

view tools/maps/series.py @ 230:f7b16fb00dda

Added tools created in an experimental map making repository.
author David Boddie <david@boddie.org.uk>
date Sun Feb 05 00:28:07 2012 +0100
parents
children e24e7d33b5e7
line source
1 def values(first, second, number):
3 # Add the two values as in the Fibonacci sequence, but take the modulus of
4 # 256 of the result to avoid overflowing into values that require two bytes
5 # or more.
7 while number > 0:
9 new_value = (first + second) & 0xff
11 yield new_value
13 first = second
14 second = new_value
16 number -= 1
18 def unlimited_values(first, second):
20 # Add the two values as in the Fibonacci sequence, but take the modulus of
21 # 256 of the result to avoid overflowing into values that require two bytes
22 # or more.
24 while True:
26 new_value = (first + second) & 0xff
28 yield new_value
30 first = second
31 second = new_value