Skip to content

Commit

Permalink
edit pudgi creation from parent function
Browse files Browse the repository at this point in the history
  • Loading branch information
Kcunningham20 committed Apr 20, 2018
2 parents aade609 + 646eb1b commit 6ba19cf
Show file tree
Hide file tree
Showing 14 changed files with 5,016 additions and 2,036 deletions.
4 changes: 4 additions & 0 deletions virtupet/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion virtupet/.idea/virtupet.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 9 additions & 12 deletions virtupet/Pudgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,24 @@ def __init__(self, parents=None, load_file=None):
self.parents = parents
else:
self.dna = DNA()
self.dna.gen_rand() # todo modify this for proper randomization of genes
self.dna.gen_rand()

self.handler.load_file(constants.DEFAULT_PUDGI)
self.json_object = self.handler.get_data()

self.name = self.json_object["name"]
self.happiness = self.json_object["happiness"]
self.uid = hex(random.randint(0, 100000))

# self.json_object["dna"] = self.dna.get_strand()
# self.json_object["uid"] = self.uid

self.handler.load_file("./data/names.json")
names = self.handler.get_data()
self.name = random.choice(names)

self.handler.close()
self.handler.close()

# ------- general data -------
self.known_decisions = []
self.known_decisions = self.json_object["known_decisions"]

# TODO move this so it only happens upon creation of new Pudgi. Load pudgi should grab json attributes
self.splice_dna()

# ------- animation variables -------
Expand Down Expand Up @@ -207,10 +206,6 @@ def decode_personality(self):
mental = int((pow(mental, -1)) % 16)
attribute.append(data["mental"][mental])

#personality = self.weights["personality"]
#personality = int((pow(personality, -1)) % 16)
#attribute.append(data["personality"][personality])

most_common = None
most = 0
for item in attribute:
Expand Down Expand Up @@ -308,13 +303,15 @@ def export_to_json(self):
self.json_object["personality"] = self.personality
self.json_object["known_decisions"] = self.known_decisions
self.json_object["parents"] = self.parents
self.json_object["dna"] = self.dna.get_strand()

self.handler.save_as("./data/pudgies/" + self.uid + ".json", self.json_object)

print("---Exporting Pudgi---")
print("UID: " + str(self.uid))
print("Name: " + self.name)
print("Color: " + self.color)
print("Happiness: " + str(self.happiness))
print("Personality: " + self.personality)
print("Parents: " + str(self.parents))
return
Expand All @@ -330,7 +327,7 @@ def select_parents(active_agent_list):
high_happiness = []
parents = []
for pudgi in active_agent_list:
if pudgi.happiness > .4:
if pudgi.happiness > .8:
high_happiness.append(pudgi.uid)
for i in range(len(high_happiness)):
if len(high_happiness) >= 2:
Expand Down
19 changes: 15 additions & 4 deletions virtupet/clock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# this file will have the functions to deal with the accumulation of time data and the printing of a timestamp

import time
import datetime


class Clock:
Expand All @@ -15,10 +16,20 @@ def elapsed_time(self):

def time_stamp(self):
stamp = ""
hours = "%02d" % ((int((self.elapsed_time()))/60),)
minutes = "%02d" % (int((self.elapsed_time())),)

return hours + ":" + minutes
# hours = "%02d" % ((int((self.elapsed_time()))/ 60),)
# minutes = "%02d" % (int((self.elapsed_time()))% 60,)
# hours = "%02d" % ((int((time.time())) / 60),)
# minutes = "%02d" % ((int((time.time())) % 60),)
time = datetime.datetime.now()
hours = "%02d" % (time.minute % 24,)
minutes = "%02d" % (time.second,)

if int(hours) == 00:
return str(12) + ":" + minutes + "am"
elif int(hours) == 13:
return str(12) + ":" + minutes + "pm"
else:
return str(int(hours) % 12) + ":" + minutes + "pm"

def update_time(self):
self.cur_time = int(self.elapsed_time())
Loading

0 comments on commit 6ba19cf

Please sign in to comment.