-
Notifications
You must be signed in to change notification settings - Fork 0
/
Universe.py
141 lines (111 loc) · 5.37 KB
/
Universe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import random
from Star import *
from Planet import *
class Universe():
def __init__(self,numberOfStars):
self.totalStar = numberOfStars
self.StarList = []
self.dwarfStartRockyPlanetCount = 0
self.dwarfStartGaseousPlanetCount = 0
self.dwarfStartHabitablePlanetCount = 0
self.dwarfIntelligentLifeCount = 0
self.giantStartRockyPlanetCount = 0
self.giantStartGaseousPlanetCount = 0
self.giantStartHabitablePlanetCount = 0
self.giantIntelligentLifeCount = 0
self.mediumStartRockyPlanetCount = 0
self.mediumStartGaseousPlanetCount = 0
self.mediumStartHabitablePlanetCount = 0
self.mediumIntelligentLifeCount = 0
def generateStars(self):
self.giantStar=0
self.dwarfStar=0
self.mediumStar=0
for i in range(self.totalStar):
x = random.randint(0, 2)
if x == 0:
a = GiantStar()
a.coordinateControl(self.StarList)
self.StarList.append(a)
y = random.randint(0, 2)
for i in range (a.numberPlanets):
if y == 0:
r = RockyPlanet()
a.PlanetList.append(r)
self.giantStartRockyPlanetCount+=1
elif y == 1:
g = GaseousPlanet()
a.PlanetList.append(g)
self.giantStartGaseousPlanetCount+=1
elif y == 2:
h = HabitablePlanet()
if random.randint(0, 10000) < a.lifeChance*10000:
if (h.distance<a.goldilockZoneMax and h.distance>a.goldilockZoneMin):
h.isLife=True
self.giantIntelligentLifeCount+=1
a.PlanetList.append(h)
self.giantStartHabitablePlanetCount+=1
self.giantStar+=1
elif x ==1:
b =DwarfStar()
b.coordinateControl(self.StarList)
self.StarList.append(b)
y = random.randint(0, 2)
for i in range(b.numberPlanets):
if y == 0:
r = RockyPlanet()
b.PlanetList.append(r)
self.dwarfStartRockyPlanetCount+=1
elif y == 1:
g = GaseousPlanet()
b.PlanetList.append(g)
self.dwarfStartGaseousPlanetCount+=1
elif y == 2:
h = HabitablePlanet()
if random.randint(0, 10000) < b.lifeChance*10000:
if (h.distance<b.goldilockZoneMax and h.distance>b.goldilockZoneMin):
h.isLife=True
self.dwarfIntelligentLifeCount+=1
b.PlanetList.append(h)
self.dwarfStartHabitablePlanetCount+=1
self.dwarfStar+=1
elif x ==2:
c = MediumStar()
c.coordinateControl(self.StarList)
self.StarList.append(c)
y = random.randint(0, 2)
for i in range(c.numberPlanets):
if y == 0:
r = RockyPlanet()
c.PlanetList.append(r)
self.mediumStartRockyPlanetCount+=1
elif y == 1:
g = GaseousPlanet()
c.PlanetList.append(g)
self.mediumStartGaseousPlanetCount+=1
elif y == 2:
h = HabitablePlanet()
if random.randint(0, 10000) < c.lifeChance*10000:
if (h.distance<c.goldilockZoneMax and h.distance>c.goldilockZoneMin):
h.isLife = True
self.mediumIntelligentLifeCount+=1
c.PlanetList.append(h)
self.mediumStartHabitablePlanetCount+=1
self.mediumStar+=1
def printUniverse(self):
print ("Total number of stars in my universe",self.totalStar)
print ("There are",self.giantStar ,"Giant Stars with:")
print ("\t",self.giantStartGaseousPlanetCount," Gaseous Planets")
print ("\t",self.giantStartRockyPlanetCount," Rocky Planets")
print ("\t",self.giantStartHabitablePlanetCount," Habitable Planets")
print ("\t",self.giantIntelligentLifeCount," Planets with Intelligent Life")
print ("There are",self.dwarfStar ,"Dwarf Stars with:")
print ("\t", self.dwarfStartGaseousPlanetCount, " Gaseous Planets")
print ("\t", self.dwarfStartRockyPlanetCount, " Rocky Planets")
print ("\t", self.dwarfStartHabitablePlanetCount, " Habitable Planets")
print ("\t",self.dwarfIntelligentLifeCount," Planets with Intelligent Life")
print ("There are",self.mediumStar ,"Medium Stars with:")
print ("\t", self.mediumStartGaseousPlanetCount, " Gaseous Planets")
print ("\t", self.mediumStartRockyPlanetCount, " Rocky Planets")
print ("\t", self.mediumStartHabitablePlanetCount, " Habitable Planets")
print ("\t",self.mediumIntelligentLifeCount," Planets with Intelligent Life")