Fuglepopulasjon#

! pip install matplotlib --quiet
WARNING: There was an error checking the latest version of pip.
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 22 19:23:49 2022

@author: sigur
"""

import math as m
import matplotlib.pyplot as plt

antall_generasjoner = 5

radius = 5
avstand = 10

x_start=1
y_start=0

x = x_start
y = y_start

brune = 8
rode = 2
plt.clf()
plt.axes()

for i in range(antall_generasjoner):
    
    #skriver ut antallet av hver type fugl
    print("andtall brune: "+ str(brune))
    print("antall røde: " + str(rode))
    
    #tegner en sirkel for hver fugl, røde og brune
    for j in range(brune):
        plt.gca().add_patch(plt.Circle((x, y), radius=0.3, fc='brown'))
        x+=1
    
    for j in range(rode):
        plt.gca().add_patch(plt.Circle((x, y), radius=0.3, fc='red'))
        x+=1
    
    # regner ut neste iterasjon
    rode =   m.floor(rode * (1/2))
    brune = m.floor(brune * (3/4))
    rode = rode * 4
    brune = brune
    x=x_start
    y-=1

plt.axis('scaled')
plt.show()

print("ferdig")
andtall brune: 8
antall røde: 2
andtall brune: 6
antall røde: 4
andtall brune: 4
antall røde: 8
andtall brune: 3
antall røde: 16
andtall brune: 2
antall røde: 32
_images/849f4574cb1069894c4dca141c5d780b216824e5087ae123bd280bb0239e7dcc.png
ferdig