diff --git a/virtupet/.idea/misc.xml b/virtupet/.idea/misc.xml index 5da332e..0a08196 100644 --- a/virtupet/.idea/misc.xml +++ b/virtupet/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/virtupet/.idea/virtupet.iml b/virtupet/.idea/virtupet.iml index e0841ce..6711606 100644 --- a/virtupet/.idea/virtupet.iml +++ b/virtupet/.idea/virtupet.iml @@ -2,7 +2,7 @@ - + diff --git a/virtupet/Pudgi.py b/virtupet/Pudgi.py index eddef90..998fd07 100644 --- a/virtupet/Pudgi.py +++ b/virtupet/Pudgi.py @@ -270,10 +270,6 @@ def go_left(self): def stop(self): self.change_x = 0 - def make_decision(self): - # make decision - return - def import_from_json(self, load): self.handler.load_file(load) self.json_object = self.handler.get_data() @@ -327,20 +323,122 @@ def select_parents(active_agent_list): high_happiness = [] parents = [] for pudgi in active_agent_list: - if pudgi.happiness > .8: - high_happiness.append(pudgi.uid) + if pudgi.happiness > 9: + high_happiness.append(pudgi) for i in range(len(high_happiness)): if len(high_happiness) >= 2: - parents.append((high_happiness.pop(), high_happiness.pop())) + parent01 = high_happiness.pop() + parent02 = high_happiness.pop() + parents.append((parent01.uid, parent02.uid)) + parent01.happiness = 2.0 + parent02.happiness = 2.0 return parents - def make_decicion(self): + def make_decision(self): self.handler.load_file("./data/decisions.json") decision_file = self.handler.get_data() - self.handler.load_file("./data/pudgi" + self.uid + ".json") - pudgi_file = self.handler.get_data() - - if (random.random() > 0.5): + self.handler.load_file("./data/pudgies/" + self.uid + ".json") + choice_index = -1 + happiness_optimized = 0 + t = 0 + choice = None + + w_att = self.weights["attachment"] + w_hum = self.weights["humor"] + w_enj = self.weights["enjoyment"] + w_exc = self.weights["excitement"] + w_conf = self.weights["confidence"] + w_cont = self.weights["contentment"] + w_vit = self.weights["vitality"] + w_phy = self.weights["physical"] + w_ment = self.weights["mental"] + + if random.random() > 0.5: + index = 0 for decision in self.known_decisions: name = decision["name"] + + att = None + hum = None + enj = None + exc = None + conf = None + cont = None + vit = None + phy = None + ment = None + ent = None + + for dec in decision_file: + if dec["name"] == name: + + att = dec["values"]["attachment"] + hum = dec["values"]["humor"] + enj = dec["values"]["enjoyment"] + exc = dec["values"]["excitement"] + conf = dec["values"]["confidence"] + cont = dec["values"]["contentment"] + vit = dec["values"]["vitality"] + phy = dec["values"]["physical_energy"] + ment = dec["values"]["mental_energy"] + ent = dec["values"]["entertainment"] + + for dec in self.known_decisions: + if dec["name"] == name: + t = dec["count"] + + happiness = .5 * (pow(ent, t) + ((pow(att, w_att))+(pow(hum, w_hum))+(pow(enj, w_enj)) + + (pow(exc, w_exc)) + (pow(conf, w_conf))+(pow(cont, w_cont)) - + (pow(vit, w_vit)) - (pow(phy, w_phy)) - (pow(ment, w_ment)))) + + if happiness > happiness_optimized: + happiness_optimized = happiness + choice = decision + choice_index = index + + index += 1 + + else: + dec_attempt = random.choice(decision_file) + for known in self.known_decisions: # iterate through all known + if dec_attempt["name"] == known["name"]: # if we find a match, break out. We don't want this + break + else: + choice = dec_attempt + att = choice["values"]["attachment"] + hum = choice["values"]["humor"] + enj = choice["values"]["enjoyment"] + exc = choice["values"]["excitement"] + conf = choice["values"]["confidence"] + cont = choice["values"]["contentment"] + vit = choice["values"]["vitality"] + phy = choice["values"]["physical_energy"] + ment = choice["values"]["mental_energy"] + ent = choice["values"]["entertainment"] + + happiness_optimized = .5 * (pow(ent, t)+((pow(att, w_att)) + (pow(hum, w_hum)) + (pow(enj, w_enj)) + + (pow(exc, w_exc)) + (pow(conf, w_conf)) + (pow(cont, w_cont)) - + (pow(vit, w_vit)) - (pow(phy, w_phy)) - (pow(ment, w_ment)))) + + self.known_decisions.append({"name": choice["name"], "count": 0}) + choice_index = len(self.known_decisions) - 1 + + if choice is not None: + if self.happiness + happiness_optimized <= 0: + self.happiness = 0 + else: + if self.happiness + happiness_optimized <= 10: + self.happiness += happiness_optimized + else: + self.happiness = 10 + + self.known_decisions[choice_index]["count"] += 1 + + print("---------------------------------------------") + print("Pudgi: " + self.name) + print("Choice: " + choice["name"]) + print("Happiness increased by: " + str(happiness_optimized)) + print("Times chosen: " + str(self.known_decisions[choice_index]["count"])) + print("---------------------------------------------") + print(str(self.name) + "'s Happiness: " + str(self.happiness)) diff --git a/virtupet/clock.py b/virtupet/clock.py index 7af5ac5..fb0194e 100644 --- a/virtupet/clock.py +++ b/virtupet/clock.py @@ -33,3 +33,9 @@ def time_stamp(self): def update_time(self): self.cur_time = int(self.elapsed_time()) + + def get_minutes(self): + return "%02d" % (datetime.datetime.now().second, ) + + def get_seconds(self): + return "%02d" % (datetime.datetime.now().microsecond, ) diff --git a/virtupet/data/decisions.json b/virtupet/data/decisions.json index d7ac95a..184222e 100644 --- a/virtupet/data/decisions.json +++ b/virtupet/data/decisions.json @@ -7,9 +7,9 @@ "confidence": 0.2, "contentment": 0.6, "entertainment": 1, - "vitality": -0.1, - "mental_energy": -0.2, - "physical_energy": -0.2 + "vitality": 0.1, + "mental_energy": 0.2, + "physical_energy": 0.2 } }, {"name": "push_car", "values": @@ -20,9 +20,9 @@ "confidence": 0.3, "contentment": 0.6, "entertainment": 1, - "vitality": -0.1, - "mental_energy": -0.2, - "physical_energy": -0.2 + "vitality": 0.1, + "mental_energy": 0.2, + "physical_energy": 0.2 } }, {"name": "eat_cake", "values": @@ -33,12 +33,12 @@ "confidence": 0.1, "contentment": 0.7, "entertainment": 1, - "vitality": -0.7, - "mental_energy": -0.5, + "vitality": 0.7, + "mental_energy": 0.5, "physical_energy": 0.3 } }, - {"name": "sleep", "values": + {"name": "sleep", "values": {"attachment": 0.1, "humor": 0.1, "enjoyment": 0.1, @@ -49,21 +49,24 @@ "vitality": 0.8, "mental_energy": 0.5, "physical_energy": 0.5 - } - }, + } + }, { "name": "reading", - "values": { - "attachment": 0.1, + "values": + {"attachment": 0.1, "humor": 0.5, "enjoyment": 0.9, "excitement": 0.4, "confidence": 0.3, "contentment": 0.7, "entertainment": 0.7, - "vitality": -0.1, - "mental_energy": -0.5, - "physical_energy": -0.1 + "vitality": 0.1, + "mental_energy": 0.5, + "physical_energy": 0.1, + "vitality": 0.1, + "mental_energy": 0.5, + "physical_energy": 0.1 } }, { "name": "eat_veggies", "values": @@ -74,9 +77,10 @@ "confidence": 0.4, "contentment": 0.1, "entertainment": 0.1, - "vitality": -0.1, + "vitality": 0.1, "mental_energy": 0.1, - "physical_energy": 0.1} + "physical_energy": 0.1 + } }, {"name": "meditate", "values": {"attachment": 0.3, @@ -100,9 +104,9 @@ "confidence": 0.1, "contentment": 0.1, "entertainment": 0.5, - "vitality": -0.1, - "mental_energy": -0.1, - "physical_energy": -0.1 + "vitality": 0.1, + "mental_energy": 0.1, + "physical_energy": 0.1 } } ] diff --git a/virtupet/data/pudgies/0x10404.json b/virtupet/data/pudgies/0x10404.json new file mode 100644 index 0000000..3a4a041 --- /dev/null +++ b/virtupet/data/pudgies/0x10404.json @@ -0,0 +1,153 @@ +{ + "uid": "0x10404", + "name": "Jaidyn", + "dna": [ + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0 + ], + "color": "Purple", + "personality": "ISTJ", + "parents": [ + null, + null + ], + "happiness": 4.9400687759036614, + "known_decisions": [ + { + "name": "nothing", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x116eb.json b/virtupet/data/pudgies/0x116eb.json new file mode 100644 index 0000000..634fff9 --- /dev/null +++ b/virtupet/data/pudgies/0x116eb.json @@ -0,0 +1,153 @@ +{ + "uid": "0x116eb", + "name": "Caroline", + "dna": [ + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 0 + ], + "color": "Vampire", + "personality": "ISFJ", + "parents": [ + null, + null + ], + "happiness": 3.0, + "known_decisions": [ + { + "name": "nothing", + "count": 0 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x127.json b/virtupet/data/pudgies/0x127.json new file mode 100644 index 0000000..92ca5f5 --- /dev/null +++ b/virtupet/data/pudgies/0x127.json @@ -0,0 +1,161 @@ +{ + "uid": "0x127", + "name": "Savanna", + "dna": [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 1 + ], + "color": "Midnight", + "personality": "ENTJ", + "parents": [ + null, + null + ], + "happiness": 2.001426294207687, + "known_decisions": [ + { + "name": "nothing", + "count": 0 + }, + { + "name": "roll_ball", + "count": 1 + }, + { + "name": "sleep", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x135c7.json b/virtupet/data/pudgies/0x135c7.json new file mode 100644 index 0000000..ca9e5f1 --- /dev/null +++ b/virtupet/data/pudgies/0x135c7.json @@ -0,0 +1,157 @@ +{ + "uid": "0x135c7", + "name": "Remy", + "dna": [ + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 0 + ], + "color": "White", + "personality": "INTP", + "parents": [ + null, + null + ], + "happiness": 3.933562213656309, + "known_decisions": [ + { + "name": "nothing", + "count": 1 + }, + { + "name": "meditate", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x14362.json b/virtupet/data/pudgies/0x14362.json new file mode 100644 index 0000000..101586a --- /dev/null +++ b/virtupet/data/pudgies/0x14362.json @@ -0,0 +1,161 @@ +{ + "uid": "0x14362", + "name": "Makenzie", + "dna": [ + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0 + ], + "color": "Midnight", + "personality": "ISTP", + "parents": [ + null, + null + ], + "happiness": 7.74372861565943, + "known_decisions": [ + { + "name": "nothing", + "count": 4 + }, + { + "name": "eat_veggies", + "count": 1 + }, + { + "name": "meditate", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x15c85.json b/virtupet/data/pudgies/0x15c85.json new file mode 100644 index 0000000..d9e9fc9 --- /dev/null +++ b/virtupet/data/pudgies/0x15c85.json @@ -0,0 +1,153 @@ +{ + "uid": "0x15c85", + "name": "Tania", + "dna": [ + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1 + ], + "color": "Green", + "personality": "INTP", + "parents": [ + null, + null + ], + "happiness": 7.3352723166997436, + "known_decisions": [ + { + "name": "nothing", + "count": 2 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x1664c.json b/virtupet/data/pudgies/0x1664c.json new file mode 100644 index 0000000..e55f8a6 --- /dev/null +++ b/virtupet/data/pudgies/0x1664c.json @@ -0,0 +1,165 @@ +{ + "uid": "0x1664c", + "name": "Ivy", + "dna": [ + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1 + ], + "color": "Angel", + "personality": "ESTJ", + "parents": [ + null, + null + ], + "happiness": 5.166811523731614, + "known_decisions": [ + { + "name": "nothing", + "count": 0 + }, + { + "name": "push_car", + "count": 8 + }, + { + "name": "sleep", + "count": 1 + }, + { + "name": "eat_cake", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x172a.json b/virtupet/data/pudgies/0x172a.json new file mode 100644 index 0000000..dd1545f --- /dev/null +++ b/virtupet/data/pudgies/0x172a.json @@ -0,0 +1,153 @@ +{ + "uid": "0x172a", + "name": "Bethany", + "dna": [ + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1 + ], + "color": "Purple", + "personality": "ESTJ", + "parents": [ + "0x5c0b", + "0x1664c" + ], + "happiness": 8.544700546452308, + "known_decisions": [ + { + "name": "nothing", + "count": 4 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x1607.json b/virtupet/data/pudgies/0x17402.json similarity index 79% rename from virtupet/data/pudgies/0x1607.json rename to virtupet/data/pudgies/0x17402.json index 5fa75a5..1299d5e 100644 --- a/virtupet/data/pudgies/0x1607.json +++ b/virtupet/data/pudgies/0x17402.json @@ -1,17 +1,19 @@ { - "uid": "0x1607", - "name": "Haiden", + "uid": "0x17402", + "name": "Efrain", "dna": [ 1, - 0, + 1, 1, 0, 1, 1, - 0, + 1, 0, 1, 1, + 0, + 0, 1, 1, 1, @@ -26,13 +28,17 @@ 0, 0, 0, + 0, 1, 1, 1, - 0, 1, 0, 0, + 0, + 1, + 1, + 1, 1, 1, 0, @@ -40,20 +46,16 @@ 1, 1, 1, - 0, 1, - 0, 1, - 0, - 0, 1, 1, - 0, + 1, + 1, 0, 0, 1, 1, - 0, 1, 1, 0, @@ -61,12 +63,16 @@ 0, 0, 1, - 1, - 1, + 0, + 0, + 0, + 0, 0, 1, + 0, 1, 1, + 0, 1, 1, 0, @@ -76,6 +82,9 @@ 1, 1, 0, + 0, + 1, + 1, 1, 1, 0, @@ -85,31 +94,23 @@ 1, 0, 0, - 1, - 0, 0, 1, - 1, 0, 0, 1, - 1, 0, 1, - 1, - 1, - 1, - 1, - 1, + 0, 0, 0, 1, 1, 1, + 0, 1, 1, 0, - 1, 0, 0, 1, @@ -119,30 +120,42 @@ 1, 1, 1, - 0, 1, + 1, + 0, 0, 1, + 0, + 0, 1, 1, - 0, 1, 1, 0, - 0, - 0, 1, 1, - 0, 1, 1 ], - "color": "Blue", - "personality": "ISFP", + "color": "Angel", + "personality": "INTP", "parents": [ null, null ], - "happiness": 0.5, - "known_decisions": [] + "happiness": 3.159129889855766, + "known_decisions": [ + { + "name": "nothing", + "count": 0 + }, + { + "name": "eat_cake", + "count": 1 + }, + { + "name": "reading", + "count": 3 + } + ] } \ No newline at end of file diff --git a/virtupet/data/pudgies/0x176a2.json b/virtupet/data/pudgies/0x176a2.json new file mode 100644 index 0000000..daac531 --- /dev/null +++ b/virtupet/data/pudgies/0x176a2.json @@ -0,0 +1,157 @@ +{ + "uid": "0x176a2", + "name": "Lukas", + "dna": [ + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1 + ], + "color": "Angel", + "personality": "INFJ", + "parents": [ + null, + null + ], + "happiness": 9.245745024897785, + "known_decisions": [ + { + "name": "nothing", + "count": 1 + }, + { + "name": "eat_veggies", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x5c0b.json b/virtupet/data/pudgies/0x5c0b.json new file mode 100644 index 0000000..d673d7f --- /dev/null +++ b/virtupet/data/pudgies/0x5c0b.json @@ -0,0 +1,169 @@ +{ + "uid": "0x5c0b", + "name": "Dana", + "dna": [ + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 0 + ], + "color": "White", + "personality": "ENFJ", + "parents": [ + null, + null + ], + "happiness": 10, + "known_decisions": [ + { + "name": "nothing", + "count": 2 + }, + { + "name": "push_car", + "count": 4 + }, + { + "name": "eat_veggies", + "count": 1 + }, + { + "name": "meditate", + "count": 1 + }, + { + "name": "sleep", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0x62f6.json b/virtupet/data/pudgies/0x62f6.json new file mode 100644 index 0000000..0826bd7 --- /dev/null +++ b/virtupet/data/pudgies/0x62f6.json @@ -0,0 +1,161 @@ +{ + "uid": "0x62f6", + "name": "Paxton", + "dna": [ + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1 + ], + "color": "Blue", + "personality": "ESTJ", + "parents": [ + "0x5c0b", + "0x1664c" + ], + "happiness": 2.5653303772150235, + "known_decisions": [ + { + "name": "nothing", + "count": 3 + }, + { + "name": "meditate", + "count": 2 + }, + { + "name": "eat_veggies", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0xbbca.json b/virtupet/data/pudgies/0xbbca.json new file mode 100644 index 0000000..42dcbff --- /dev/null +++ b/virtupet/data/pudgies/0xbbca.json @@ -0,0 +1,153 @@ +{ + "uid": "0xbbca", + "name": "Giovanni", + "dna": [ + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "color": "Vampire", + "personality": "ISTJ", + "parents": [ + "0xf709", + "0xd3f3" + ], + "happiness": 3.0, + "known_decisions": [ + { + "name": "nothing", + "count": 0 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0xf1f.json b/virtupet/data/pudgies/0xca5f.json similarity index 83% rename from virtupet/data/pudgies/0xf1f.json rename to virtupet/data/pudgies/0xca5f.json index fefea16..6df5568 100644 --- a/virtupet/data/pudgies/0xf1f.json +++ b/virtupet/data/pudgies/0xca5f.json @@ -1,37 +1,34 @@ { - "uid": "0xf1f", - "name": "Leah", + "uid": "0xca5f", + "name": "Felix", "dna": [ - 1, - 0, - 0, - 1, - 0, 0, 1, 1, - 0, 1, 0, 1, 1, - 0, - 1, 1, 0, 0, 0, + 1, + 1, + 1, 0, + 1, 0, 1, 0, 0, 1, - 0, 1, - 0, 1, 0, + 1, + 1, + 1, 0, 0, 0, @@ -39,11 +36,8 @@ 1, 1, 1, - 1, - 1, 0, 1, - 0, 1, 0, 0, @@ -53,96 +47,107 @@ 0, 1, 1, - 0, - 0, - 1, 1, 0, 0, + 1, 0, 0, 1, 0, - 1, 0, - 1, 0, 0, 0, - 1, + 0, 0, 1, 1, 1, 0, - 1, 0, - 1, 0, - 1, - 1, 0, 1, 1, - 0, + 1, 0, 0, 0, 1, 0, 1, - 0, - 0, - 0, + 1, + 1, 0, 0, 0, 0, 0, 1, - 0, + 1, 1, 0, 1, + 1, + 1, + 1, 0, + 1, + 1, 0, 0, + 1, 0, 1, 1, 1, + 1, + 1, + 0, + 0, 0, 1, 1, 1, 0, + 1, + 0, 0, 0, 0, 1, 0, + 1, 0, 0, - 1, 0, 0, 1, 0, 0, 0, + 0, 1, - 1, + 0, + 0, 1, 0, 0, - 1 + 1, + 0 ], "color": "Midnight", - "personality": "ISFP", + "personality": "INTP", "parents": [ null, null ], - "happiness": 0.5, - "known_decisions": [] + "happiness": 3.0, + "known_decisions": [ + { + "name": "nothing", + "count": 0 + } + ] } \ No newline at end of file diff --git a/virtupet/data/pudgies/0xcc34.json b/virtupet/data/pudgies/0xcc34.json new file mode 100644 index 0000000..b51290a --- /dev/null +++ b/virtupet/data/pudgies/0xcc34.json @@ -0,0 +1,169 @@ +{ + "uid": "0xcc34", + "name": "Gia", + "dna": [ + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1 + ], + "color": "Midnight", + "personality": "ESTP", + "parents": [ + null, + null + ], + "happiness": 2.5972978884672453, + "known_decisions": [ + { + "name": "nothing", + "count": 0 + }, + { + "name": "reading", + "count": 1 + }, + { + "name": "eat_cake", + "count": 1 + }, + { + "name": "push_car", + "count": 1 + }, + { + "name": "roll_ball", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0xcc8a.json b/virtupet/data/pudgies/0xcc8a.json new file mode 100644 index 0000000..eb0e828 --- /dev/null +++ b/virtupet/data/pudgies/0xcc8a.json @@ -0,0 +1,153 @@ +{ + "uid": "0xcc8a", + "name": "Emelia", + "dna": [ + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0 + ], + "color": "Midnight", + "personality": "ESTJ", + "parents": [ + null, + null + ], + "happiness": 4.846843524913967, + "known_decisions": [ + { + "name": "nothing", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0xd3f3.json b/virtupet/data/pudgies/0xd3f3.json new file mode 100644 index 0000000..a05d276 --- /dev/null +++ b/virtupet/data/pudgies/0xd3f3.json @@ -0,0 +1,165 @@ +{ + "uid": "0xd3f3", + "name": "Cael", + "dna": [ + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0 + ], + "color": "Vampire", + "personality": "ISTJ", + "parents": [ + null, + null + ], + "happiness": 2.0, + "known_decisions": [ + { + "name": "nothing", + "count": 1 + }, + { + "name": "eat_cake", + "count": 3 + }, + { + "name": "push_car", + "count": 3 + }, + { + "name": "eat_veggies", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0xe1a8.json b/virtupet/data/pudgies/0xe1a8.json new file mode 100644 index 0000000..8edbca7 --- /dev/null +++ b/virtupet/data/pudgies/0xe1a8.json @@ -0,0 +1,153 @@ +{ + "uid": "0xe1a8", + "name": "Winston", + "dna": [ + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "color": "Blue", + "personality": "ESTJ", + "parents": [ + "0x62f6", + "0x1664c" + ], + "happiness": 5.911462983475736, + "known_decisions": [ + { + "name": "nothing", + "count": 1 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/0xf709.json b/virtupet/data/pudgies/0xf709.json new file mode 100644 index 0000000..427c242 --- /dev/null +++ b/virtupet/data/pudgies/0xf709.json @@ -0,0 +1,157 @@ +{ + "uid": "0xf709", + "name": "Macy", + "dna": [ + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0 + ], + "color": "Vampire", + "personality": "ENTJ", + "parents": [ + "0x14362", + "0xd3f3" + ], + "happiness": 2.0, + "known_decisions": [ + { + "name": "nothing", + "count": 0 + }, + { + "name": "push_car", + "count": 3 + } + ] +} \ No newline at end of file diff --git a/virtupet/data/pudgies/default.json b/virtupet/data/pudgies/default.json index 80cca7e..1051e05 100644 --- a/virtupet/data/pudgies/default.json +++ b/virtupet/data/pudgies/default.json @@ -76,6 +76,6 @@ "color": null, "personality": null, "parents": [null, null], - "happiness": 0.5, - "known_decisions": [] + "happiness": 3.0, + "known_decisions": [{"name": "nothing", "count": 0}] } diff --git a/virtupet/main.py b/virtupet/main.py index 442e75c..1c8cf37 100644 --- a/virtupet/main.py +++ b/virtupet/main.py @@ -7,6 +7,7 @@ import environments from clock import Clock from pudgi import Pudgi +import random def main(): @@ -22,24 +23,18 @@ def main(): size = [constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT] screen = pygame.display.set_mode(size) - #pygame.display.set_caption(json_object["name"]) - active_agent_list = [] - # parents = ["0x9c08", "0x11e66"] - # agent = Pudgi(parents) - # agent = Pudgi(None, "./data/pudgies/0x9c08.json") + agent = Pudgi() agent2 = Pudgi() + active_agent_list.append(agent) agent.export_to_json() active_agent_list.append(agent2) agent2.export_to_json() + pygame.display.set_caption("Pudgi Simulation") - parents = ["0x9c08", "0x11e66"] - # agent = Pudgi(parents) - agent = Pudgi(None, "./data/pudgies/0x8653.json") - # agent = Pudgi() env_list = [environments.EnvironmentHouse(agent)] current_env_no = 0 @@ -52,7 +47,7 @@ def main(): agent.rect.y = constants.SCREEN_HEIGHT - 140 agent2.rect.x = 100 agent2.rect.y = constants.SCREEN_HEIGHT - 140 - high_happiness = Pudgi.select_parents(active_agent_list) + # for parents in high_happiness: # pudgi = Pudgi(parents) # active_sprite_list.add(pudgi) @@ -63,7 +58,7 @@ def main(): done = False - clock = pygame.time.Clock() + game_clock = pygame.time.Clock() # ----------- JSON objects ------------ # handler.load_file("./data/metadata.json") @@ -73,13 +68,19 @@ def main(): # for char in number: # node = node[char] + frames_run = 0 # --------------Main While loop--------------- while not done: + high_happiness = Pudgi.select_parents(active_agent_list) + for parents in high_happiness: pudgi = Pudgi(parents) active_sprite_list.add(pudgi) active_agent_list.append(pudgi) + pudgi.export_to_json() + pudgi.rect.y = constants.SCREEN_HEIGHT - 140 + pudgi.rect.x = random.randint(100, 800) for event in pygame.event.get(): # User did something if event.type == pygame.QUIT: # If user clicked close @@ -116,11 +117,24 @@ def main(): screen.blit(clockSurface, clockRect) - clock.tick(30) + game_clock.tick(30) + + if int(time_clock.get_minutes()) % 15 == 0 and frames_run == 0: + for pudgi in active_agent_list: + pudgi.make_decision() + # print(str(pudgi.name) + "'s Happiness: " + str(pudgi.happiness)) + pygame.display.flip() - # agent.export_to_json() + frames_run += 1 + + if frames_run > 30: + frames_run = 0 + + for pudgi in active_agent_list: + pudgi.export_to_json() + pygame.quit()