Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 19 additions & 78 deletions BULBASAUR NO HUMANS.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,104 +2,44 @@
import math
import csv

from utility import *


MalePop = 14
FemalePop = 2
tick = 0
Egg0 = 0
Egg1 = 0
Egg2 = 0
Egg3 = 0
Egg4 = 0
Egg5 = 0
Egg6 = 0
Egg7 = 0
Egg8 = 0
Egg9 = 0
Egg10 = 0
Egg11 = 0
Egg12 = 0
Egg13 = 0
Egg14 = 0
Egg15 = 0
Egg16 = 0
Egg17 = 0
Egg18 = 0
Egg19 = 0
Egg20 = 0

with open('BulbasaurPopulationNoHuman.csv', 'a', newline='') as csv_file:
Eggs = [0] * 20

with open('BulbasaurPopulationNoHuman.csv', 'a') as csv_file:
fieldnames = ['tick', 'females', 'males']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
writer.writeheader()
csv_file.close()


while True:
with open('BulbasaurPopulationNoHuman.csv', 'a', newline='') as csv_file:
with open('BulbasaurPopulationNoHuman.csv', 'a' ) as csv_file:
fieldnames = ['tick', 'females', 'males']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
writer.writerow({'tick': tick, 'females': FemalePop, 'males': MalePop})
csv_file.close()
tick += 1
print("Tick:", tick)
for x in range(FemalePop):
death = random.randint(1,10000)
if death <= 243:
FemalePop += -1


for x in range(MalePop):
death = random.randint(1,10000)
if death <= 243:
MalePop += -1


if Egg0 > 0:
print (Egg0, "Bulbasaur eggs are hatching!")
for x in range(Egg0):
sexroll = random.randint(1,8)
if sexroll <= 7:
MalePop += 1
else:
FemalePop += 1

Egg0 = Egg0-Egg0+Egg1
Egg1 = Egg1-Egg1+Egg2
Egg2 = Egg2-Egg2+Egg3
Egg3 = Egg3-Egg3+Egg4
Egg4 = Egg4-Egg4+Egg5
Egg5 = Egg5-Egg5+Egg6
Egg6 = Egg6-Egg6+Egg7
Egg7 = Egg7-Egg7+Egg8
Egg8 = Egg8-Egg8+Egg9
Egg9 = Egg9-Egg9+Egg10
Egg10 = Egg10-Egg10+Egg11
Egg11 = Egg11-Egg11+Egg12
Egg12 = Egg12-Egg12+Egg13
Egg13 = Egg13-Egg13+Egg14
Egg14 = Egg14-Egg14+Egg15
Egg15 = Egg15-Egg15+Egg16
Egg16 = Egg16-Egg16+Egg17
Egg17 = Egg17-Egg17+Egg18
Egg18 = Egg18-Egg18+Egg19
Egg19 = Egg19-Egg19+Egg20
Egg20 = Egg20-Egg20

FemalePop = checkDeath(FemalePop)
MalePop = checkDeath(MalePop)

if Eggs[0] > 0:
print (Eggs[0], "Bulbasaur eggs are hatching!")
MalePop, FemalePop = determinSex(MalePop,FemalePop,Eggs[0])

updateEggs(Eggs)
if MalePop >=1:
for x in range(FemalePop):
egg = random.randint(1,100)
if egg <= 50:
Egg20 += 1

elif FemalePop >=1:
createEgg(FemalePop,50,Eggs)

for x in range(FemalePop):
egg = random.randint(1,100)
if egg <=10:
Egg20 += 1

elif FemalePop >=1:
createEgg(FemalePop,10,Eggs)


print("Total Population:", FemalePop+MalePop)
Expand All @@ -112,6 +52,7 @@
print("Population max reached")

break
elif FemalePop == 0 and Egg0 == 0 and Egg1 == 0 and Egg2 == 0 and Egg3 == 0 and Egg4 == 0 and Egg5 == 0 and Egg6 == 0 and Egg7 == 0 and Egg8 == 0 and Egg9 == 0 and Egg10 == 0 and Egg11 == 0 and Egg12 == 0 and Egg13 == 0 and Egg14 == 0 and Egg15 == 0 and Egg16 == 0 and Egg17 == 0 and Egg18 == 0 and Egg19 == 0 and Egg20 == 0:
elif FemalePop == 0 and IsExtinct(Eggs):
print("Extinction")
break
break

86 changes: 17 additions & 69 deletions BULBASAUR.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,24 @@
import csv


from utility import *


MalePop = 14
FemalePop = 2
tick = 0
Egg0 = 0
Egg1 = 0
Egg2 = 0
Egg3 = 0
Egg4 = 0
Egg5 = 0
Egg6 = 0
Egg7 = 0
Egg8 = 0
Egg9 = 0
Egg10 = 0
Egg11 = 0
Egg12 = 0
Egg13 = 0
Egg14 = 0
Egg15 = 0
Egg16 = 0
Egg17 = 0
Egg18 = 0
Egg19 = 0
Egg20 = 0

with open('BulbasaurPopulation.csv', 'a', newline='') as csv_file:
Eggs = [0] * 20


with open('BulbasaurPopulation.csv', 'a') as csv_file:
fieldnames = ['tick', 'females', 'males']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
writer.writeheader()
csv_file.close()

while True:
with open('BulbasaurPopulation.csv', 'a', newline='') as csv_file:
fieldnames = ['tick', 'females', 'males']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
writer.writerow({'tick': tick, 'females': FemalePop, 'males': MalePop})
csv_file.close()
SaveTick('BulbasaurPopulation.csv',tick,FemalePop,MalePop)
tick += 1
print("Tick:", tick)
for x in range(FemalePop):
Expand All @@ -54,51 +35,18 @@
MalePop += -1


if Egg0 > 0:
print (Egg0, "Bulbasaur eggs are hatching!")
for x in range(Egg0):
sexroll = random.randint(1,8)
if sexroll <= 7:
MalePop += 1
else:
FemalePop += 1
if Eggs[0] > 0:
print (Eggs[0], "Bulbasaur eggs are hatching!")
MalePop, FemalePop = determinSex(MalePop,FemalePop,Eggs[0])

Egg0 = Egg0-Egg0+Egg1
Egg1 = Egg1-Egg1+Egg2
Egg2 = Egg2-Egg2+Egg3
Egg3 = Egg3-Egg3+Egg4
Egg4 = Egg4-Egg4+Egg5
Egg5 = Egg5-Egg5+Egg6
Egg6 = Egg6-Egg6+Egg7
Egg7 = Egg7-Egg7+Egg8
Egg8 = Egg8-Egg8+Egg9
Egg9 = Egg9-Egg9+Egg10
Egg10 = Egg10-Egg10+Egg11
Egg11 = Egg11-Egg11+Egg12
Egg12 = Egg12-Egg12+Egg13
Egg13 = Egg13-Egg13+Egg14
Egg14 = Egg14-Egg14+Egg15
Egg15 = Egg15-Egg15+Egg16
Egg16 = Egg16-Egg16+Egg17
Egg17 = Egg17-Egg17+Egg18
Egg18 = Egg18-Egg18+Egg19
Egg19 = Egg19-Egg19+Egg20
Egg20 = Egg20-Egg20


updateEggs(Eggs)

if MalePop >=1 and tick <=100:
for x in range(FemalePop):
egg = random.randint(1,100)
if egg <= 50:
Egg20 += 1
if MalePop >=1:
createEgg(FemalePop,50,Eggs)


elif FemalePop >=1:

for x in range(FemalePop):
egg = random.randint(1,100)
if egg <=10:
Egg20 += 1
createEgg(FemalePop,10,Eggs)



Expand All @@ -112,6 +60,6 @@
print("Population max reached")

break
elif FemalePop == 0 and Egg0 == 0 and Egg1 == 0 and Egg2 == 0 and Egg3 == 0 and Egg4 == 0 and Egg5 == 0 and Egg6 == 0 and Egg7 == 0 and Egg8 == 0 and Egg9 == 0 and Egg10 == 0 and Egg11 == 0 and Egg12 == 0 and Egg13 == 0 and Egg14 == 0 and Egg15 == 0 and Egg16 == 0 and Egg17 == 0 and Egg18 == 0 and Egg19 == 0 and Egg20 == 0:
elif FemalePop == 0 and IsExtinct(Eggs):
print("Extinction")
break
45 changes: 45 additions & 0 deletions utility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import random
import math
import csv

def updateEggs(Eggs):
for x in range(len(Eggs)):
if x < len(Eggs) - 1:
Eggs[x] = Eggs[x + 1]
else:
Eggs[x] = 0

def createEgg(pop,limes,Egg):
for x in range(pop):
egg = random.randint(1,100)
if egg <= limes:
Egg[-1] += 1

def determinSex(malePop,femalePop,Egg):
for x in range(Egg):
sexroll = random.randint(1,8)
if sexroll <= 7:
malePop += 1
else:
femalePop += 1
return (malePop,femalePop)

def IsExtinct( list ):
bResult = False
for x in list:
bResult &= (x == 0)
return bResult

def checkDeath(pop):
for x in range(pop):
death = random.randint(1,10000)
if death <= 243:
pop += -1
return pop

def SaveTick(file, tick,fpop,mpop):
with open(file, 'a') as csv_file:
fieldnames = ['tick', 'females', 'males']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
writer.writerow({'tick': tick, 'females': fpop, 'males': mpop})
csv_file.close()