Python Forum
[PyGame] Fibonacci graphics ideas? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: [PyGame] Fibonacci graphics ideas? (/thread-32749.html)

Pages: 1 2 3


Fibonacci graphics ideas? - michael1789 - Mar-03-2021

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.


RE: Fibonacci graphics ideas? - metulburr - Mar-04-2021

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


RE: Fibonacci graphics ideas? - BashBedlam - Mar-04-2021

I don't know if this would be considered inspiration or not but it's kind of fun to play with Big Grin

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 ()



RE: Fibonacci graphics ideas? - michael1789 - Mar-04-2021

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.


RE: Fibonacci graphics ideas? - Serafim - Mar-04-2021

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.


RE: Fibonacci graphics ideas? - michael1789 - Mar-04-2021

(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.


RE: Fibonacci graphics ideas? - michael1789 - Mar-04-2021

(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 Big Grin

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 :)


RE: Fibonacci graphics ideas? - michael1789 - Mar-04-2021

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


RE: Fibonacci graphics ideas? - Serafim - Mar-04-2021

(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.


RE: Fibonacci graphics ideas? - michael1789 - Mar-06-2021

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)))