-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGOL_User.py
79 lines (62 loc) · 3.44 KB
/
GOL_User.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
# import arcade
# import os, sys, time #, random, math
from different_world_physics import *
""" The user currently is the most basic cell that affects other cells but is not affected """
""" As the project became more interested in different world physics, this portion is kept simple for now ... """
# A User that interacts with the world of game of life,,,
# The player is made of cells but the cells behave slighly differently than normal cells,,,
# Important: property of user is that they affect the logic but is affected only by it's own cells,,,
class User:
def __init__(self):
self.color = (0, 255, 0)
self.decoration = None # for now,,,
# for now user is just a breathing cell
self.shape_location = [
[int(n / 2), int(n / 2)]
] # [[int(n/2 - 1), int(n/2)], [int(n/2), int(n/2)], [int(n/2 + 1), int(n/2)]]
# will need to update this and use it if user becomes more than a green cell
""" note: self.center is either a whole number or a half a whole number """
self.center = [int(n / 2), int(n / 2)]
""" very important to update these """
""" by calling update_most_type_locations whenever shape_location changes """
self.most_right = None # the indexed x location of the most right cell
self.most_left = None # the indexed x location of the most left cell
self.most_top = None # the indexed y location of the most top cell
self.most_bottom = None # the indexed y location of the most bottom cell
self.life = 10 # if a cell of user would disappear, deduct from life instead
self.energy = 100 # future: every move or action costs energy
def update_most_type_locations(self):
self.most_right = 0
self.most_left = n - 1
self.most_top = 0
self.most_bottom = n - 1
for i in range(0, len(self.shape_location)):
if self.shape_location[i][0] > self.most_right:
self.most_right = self.shape_location[i][0]
if self.shape_location[i][0] < self.most_left:
self.most_left = self.shape_location[i][0]
if self.shape_location[i][1] > self.most_top:
self.most_top = self.shape_location[i][1]
if self.shape_location[i][1] < self.most_bottom:
self.most_bottom = self.shape_location[i][1]
self.center[0] = self.most_right + self.most_left
self.center[1] = self.most_top + self.most_bottom
# future tasks outline:
# def createAdjacentCell(self): # costs One Energy point
# pass
# def pauseTheWorld(self): # costs 1000 energy point
# pass
# def metamorph(self, objectName): # costs 500 energy point just to become a Glider,,,
# pass
# def eatEntropy(self): # costs nothing
# pass
# def detectEntropyAroundSelf(self): # costs nothing #this is the AI part,,,
# pass
# def createObject(self, objectName): # costs A LOT of energy to make happen
# objectList = [["Block", "celldataForBlock", "energyCostForBlock"], ["Beehive", "", ""],
# ["Loaf", "", ""], ["Boat", "", ""], ["Tub", "", ""],
# ["Blinker", "", ""], # this is the same as the default user shape for now,,,
# ["Toad", "", ""], ["Beacon", "", ""], ["Pulsar", "", ""], ["Pentadecathlon", "", ""],
# ["Glider", "", ""], ["LightWeightSpaceship", "", ""],
# ["MiddleWeightSpaceship", "", ""], ["HeavyWeightSpaceship", "", ""]]
# pass