##### [PyGame] Fibonacci graphics ideas?
 [PyGame] Fibonacci graphics ideas? michael1789 Minister of Silly Walks Posts: 419 Threads: 34 Joined: May 2019 Reputation: Mar-03-2021, 04:15 AM ```def gen_fib(start, length): fib = [0, start] for i in range(length): fib.append(fib[-2] + fib[-1]) return fib print(gen_fib(1, 20))```I wrote this sequence generator, but I'm short on ideas of how to interpret this graphically. I want to play with it, see what I can get and hopefully make a puzzle game from what I figure out. I can use this on the points in a pygame polygons/lines, RGB values... but that's all that comes to mind. I want maybe generate shapes that fit together or something. Don't know. I wrote this function this afternoon, but I haven't really played with it yet. If I want to make "Fibonacci: The Game", I could use some inspiration for experiments. Reply metulburr The Castle of aaarrrrggh Posts: 5,121 Threads: 394 Joined: Sep 2016 Reputation: Mar-04-2021, 02:15 AM 2048 A long time ago i did a text game (well more of an animation) of rabbits breeding using the fibonacci sequence to calculate the offspring. lucas chess fibonacci board maybe that might spark some ideas Recommended Tutorials: BBcode, Forum Rules and Instructions, How to ask smart questions, the Basics, Classes, Python Gotchas Reply BashBedlam Spam, spam, eggs, and spam Posts: 289 Threads: 2 Joined: Jan 2021 Reputation: Mar-04-2021, 03:09 AM (This post was last modified: Mar-04-2021, 03:09 AM by BashBedlam.) I don't know if this would be considered inspiration or not but it's kind of fun to play with ```import turtle turtle.speed (11) def fib_generator (seed, start, length) : fib = [seed, start] for i in range (length) : fib.append (fib[-2] + fib[-1]) return iter (fib) for diameter in fib_generator (9, 13, 6) : for i in range (4) : turtle.circle (diameter) turtle.left (91) turtle.done ()``` michael1789 likes this post Reply michael1789 Minister of Silly Walks Posts: 419 Threads: 34 Joined: May 2019 Reputation: Mar-04-2021, 03:34 AM That chess board is too Menza for me, man. lol. I have to look into making fractal shapes, then gameify why I learn. You see all those ever expanding patterns... maybe something like that, you make a move and it zooms in/out to draw the next "branch". Fibonacci alone won't be enough. I need more Mathmaticians; a few more with named formulas. I can use them to control variables in drawing (zoom, rotate, scale, blit off center then scale/rotate, then set_alpha(), etc, ect. Just brain storming. metulburr likes this post Reply Serafim Lumberjack Posts: 101 Threads: 0 Joined: Jan 2021 Reputation: Mar-04-2021, 09:47 AM (This post was last modified: Mar-04-2021, 09:47 AM by Serafim.) There is a list of integer sequences on wikipedia, of which a lot are named after the person that found them interesting or important. Some of these sequences are connected to unsolved mathematical problems and som have to do with graph problems. Maybe a source of inspiration. The Lucas number sequence is closely related to the Fibonacci number sequence. michael1789 likes this post Reply michael1789 Minister of Silly Walks Posts: 419 Threads: 34 Joined: May 2019 Reputation: Mar-04-2021, 04:03 PM (Mar-04-2021, 09:47 AM)Serafim Wrote: There is a list of integer sequences on wikipedia, of which a lot are named after the person that found them interesting or important. Some of these sequences are connected to unsolved mathematical problems and som have to do with graph problems. Maybe a source of inspiration. The Lucas number sequence is closely related to the Fibonacci number sequence. That's certainly a lot of mathematicians! :) I'll code some sort of drawing loop ala spirograph, plug some of best suited sequences as some of the variables and see what it looks like. Reply michael1789 Minister of Silly Walks Posts: 419 Threads: 34 Joined: May 2019 Reputation: Mar-04-2021, 05:48 PM (Mar-04-2021, 03:09 AM)BashBedlam Wrote: I don't know if this would be considered inspiration or not but it's kind of fun to play with Yes it would. ``````Error: turtle.speed(11) AttributeError: partially initialized module 'turtle' has no attribute 'speed' (most likely due to a circular import)``````How do I fix this? lol. Never touched turtle. np. I'll translate it to pygame and say I wrote it myself. Steal from the best, I say :) Reply michael1789 Minister of Silly Walks Posts: 419 Threads: 34 Joined: May 2019 Reputation: Mar-04-2021, 06:09 PM I'm coming closer to how to visualize this stuff. I'll add dimensions one at a time, but the current plan is to generate repeating expanding pattern(fractal) of points. When I like that, I'll add/subtract points as needed, and draw polygons with them. Then figure out 3d and how to texture map translucent glass texture. If I can't make a game out off that... lol Reply Serafim Lumberjack Posts: 101 Threads: 0 Joined: Jan 2021 Reputation: Mar-04-2021, 06:29 PM (Mar-04-2021, 04:03 PM)michael1789 Wrote: That's certainly a lot of mathematicians! :) I'll code some sort of drawing loop ala spirograph, plug some of best suited sequences as some of the variables and see what it looks like.Quite far down on the Fibonacci page on wikipedia you have some interesting generalizations, starting with "Tribonacci_numbers". From there and down the page there is a lot of funny examples. And if you take a look at the corresponding OEIS pages there are loads of comments that also may generate ideas. Reply michael1789 Minister of Silly Walks Posts: 419 Threads: 34 Joined: May 2019 Reputation: Mar-06-2021, 12:05 AM It's a start! ```def gen_fib(start, length): fib = [0, start] for i in range(length): fib.append(fib[-2] + fib[-1]) return fib class Fractal(): def __init__(self, game, pos): self.nodes = [vec(pos)] def update(self): dir = vec(random.randrange(-2, 2), random.randrange(-2, 2)) for i in gen_fib(1, 5): self.nodes.append((self.nodes[-1] + (i * dir)))``` Serafim likes this post Reply

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020