def _create_girl(self, girl_number, row_number): girl = Girl(self) girl_width, girl_height = girl.rect.size girl.x = girl_width + 2 * girl_width * girl_number girl.rect.x = girl.x girl.rect.y = girl.rect.height + 2 * girl.rect.height * row_number self.girls.add(girl)
def create_girl(hi_settings, screen, girls, girl_number, row_number): girl = Girl(hi_settings, screen) girl_width = girl.rect.width girl_height = girl.rect.height girl.x = 0.5 * girl_width + 2 * girl_width * girl_number girl.rect.x = girl.x girl.rect.y = 0.5 * girl_height + 1.7 * girl_height * row_number girls.add(girl)
def get_girl_list(): """ autogenerates a random girl list :return: """ girl_data = [] for i in range(1, 10): girl_data.append(Girl(str(i)+'choosy', random.randint(1, 1000), random.randint(1, 1000), random.randint(1, 10000), 'choosy')) girl_data.append(Girl(str(i)+'normal', random.randint(1, 1000), random.randint(1, 1000), random.randint(1, 10000), 'normal')) girl_data.append(Girl(str(i)+'desperate', random.randint(1, 1000), random.randint(1, 1000), random.randint(1, 10000), 'desperate')) return girl_data
def main(): randomInputGenerate() BoyCsv = open('./boys.csv') GirlCsv = open('./girls.csv') Boys = csv.reader(BoyCsv,delimiter = ",") Girls = csv.reader(GirlCsv,delimiter = ",") Blist = [] Glist = [] for row in Boys: Blist += [Boy(row[0],int(row[1]),int(row[2]),row[3],int(row[4]),int(row[5]))] BoyCsv.close() for row in Girls: Glist += [Girl(row[0],int(row[1]),int(row[2]),row[3],int(row[4]))] GirlCsv.close() logging.info('Started pairing up') for g in Glist: for b in Blist: logging.info('Girl '+g.name+' is checking on '+b.name) if (b.isEligible(g.maintainanceBudget,g.attractiveness)) and (g.isEligible(b.budget)) and (b.status == 'single') and (g.status == 'single'): b.status = 'commited' g.status = 'commited' b.gf = g.name g.bf = b.name logging.info(g.name+' is commited to '+b.name) break for g in Glist: if(g.status == 'single'): print(g.name+' is single') else: print(g.name+' is commited to '+g.bf)
def __init__(self, screen=None): # See if we've been given a screen to use if screen is None: self.screen = pygame.display.set_mode((600, 600)) else: self.screen = screen self.running = True self.clock = pygame.time.Clock() # Gots to have us a background and a walkable mask self.background = None self.mask = None # If anyone takes screenshots, they can do so with this! self.screenshot_counter = 0 # Initialize our reusable robotic girl self.girl = Girl() # What is the current state of our game self.state = "Running" # Load our music player self.music_player = MusicPlayer() self.sound_player = SoundPlayer() self.girl.sound_player = self.sound_player
def create_new_world(): global boy boy = Boy() game_world.add_object(boy, 1) global girl girl = Girl() game_world.add_object(girl, 7)
def matchMaker(): coupList = [] with open('boys.csv', 'rb') as csvfile: reader = csv.reader(csvfile, delimiter=',') By = [ Boy(line[0], int(line[1]), int(line[2]), int(line[3]), line[4], int(line[5])) for line in reader ] csvfile.close() with open('girls.csv', 'rb') as csvfile: reader = csv.reader(csvfile, delimiter=',') Gl = [ Girl(line[0], int(line[1]), int(line[2]), int(line[3]), line[4]) for line in reader ] csvfile.close() logging.info('Match in progress\n') #Checking conditions for g in Gl: for b in By: logging.info('Matching: Girl: ' + g.gname + ' with Boy: ' + b.bname) if g.gstatus == False and b.bstatus == False and g.gattract >= b.battractReq and g.gbudget <= b.bbudget: g.gstatus = True b.bstatus = True g.bf = b.bname b.gf = g.gname coupList.append(Coup('Couple' + str(len(coupList) + 1), b, g)) #print('-----'+' '+b.battractReq+' '+g.gattract+'\n') logging.info('Commitment: Girl: ' + g.gname + ' got commited with Boy: ' + b.bname) break #elif(g.gstatus==True or b.bstatus==True): # print (b.bname +' '+g.gname+' commited\n') #elif(g.gbudget>b.bbudget): # print (b.bname+' '+g.gname+' too costly '+b.bbudget+' '+g.gbudget+'\n') #elif(b.battractReq>g.gattract): # print (b.bname+' '+g.gname+' hotter '+b.battractReq+' '+g.gattract+' \n') logging.info('Match making done') with open('gifts.csv', 'rb') as csvfile: reader = csv.reader(csvfile, delimiter=',') Gi = [ Gift(line[0], int(line[1]), int(line[2]), line[3]) for line in reader ] csvfile.close() for c in coupList: print c.cname + ' : ' + c.bobj.bname + ' commited to ' + c.gobj.gname + '\n' if (c.bobj.btypes == 'Miser'): miserAllocate(c, Gi) if (c.bobj.btypes == 'Generous'): generousAllocate(c, Gi) if (c.bobj.btypes == 'Geek'): geekAllocate(c, Gi) print_gifts(coupList)
def get_girl_list(): """ autogenerates a random girl list :return: """ girl_data = [] for i in range(1, 30): girl_data.append( Girl(str(i), random.randint(1, 1000), random.randint(1, 1000), random.randint(1, 10000))) return girl_data
def create_fleet(hi_settings, screen, harold, girls): """ Creates a fleet of girls """ girl = Girl(hi_settings, screen) number_girls_x = get_number_girls_x(hi_settings, girl.rect.width) number_rows = get_number_rows(hi_settings, harold.rect.height, \ girl.rect.height) # Create fleet for row_number in range(number_rows): for girl_number in range(number_girls_x): # Create girl and place it in the row create_girl(hi_settings, screen, girls, girl_number, row_number)
def _create_fleet(self): girl = Girl(self) girl_width, girl_height = girl.rect.size availible_space_x = self.settings.screen_width - (2 * girl_width) numbers_girls_x = availible_space_x // (2 * girl_width) ship_height = self.ship.rect.height availible_space_y = self.settings.screen_height - ( 3 * girl_height) - ship_height numbers_rows = availible_space_y // (2 * girl_height) for row_number in range(numbers_rows): for girl_number in range(numbers_girls_x): self._create_girl(girl_number, row_number)
def initAgents(self, world): self.agentlayer = world.map.getLayer('TechdemoMapGroundObjectLayer') world.agentlayer = self.agentlayer self.boy = Boy(TDS, world, 'PC:boy', self.agentlayer) self.game.instance_to_agent[self.boy.agent.getFifeId()] = self.boy self.boy.start() self.agent_list.append(self.boy) self.girl = Girl(TDS, world, 'PC:girl', self.agentlayer, self) self.game.instance_to_agent[self.girl.agent.getFifeId()] = self.girl self.girl.start() self.agent_list.append(self.girl) self.wizard = Wizard(TDS, world, 'PC:wizard', self.agentlayer, self) self.game.instance_to_agent[self.wizard.agent.getFifeId()] = self.wizard self.wizard.start() self.agent_list.append(self.wizard) self.beekeepers = create_anonymous_agents(TDS, world, 'beekeeper', self.agentlayer, Beekeeper) for beekeeper in self.beekeepers: self.game.instance_to_agent[beekeeper.agent.getFifeId()] = beekeeper beekeeper.start() self.agent_list.append(beekeeper) self.cage = Cage(TDS, world, 'sword_crate', self.agentlayer) self.game.instance_to_agent[self.cage.agent.getFifeId()] = self.cage self.cage.start() self.agent_list.append(self.cage) self.bees = [] for i in range(1, 8): bee = code.agents.bee.Bee(TDS, world, 'NPC:bee:0{}'.format(i), self.agentlayer, self) self.bees.append(bee) self.game.instance_to_agent[bee.agent.getFifeId()] = bee bee.start() self.agent_list.append(bee) self.warrior = Warrior(TDS, world, 'PC:warrior', self.agentlayer) self.game.instance_to_agent[self.warrior.agent.getFifeId()] = self.warrior self.warrior.start() self.agent_list.append(self.warrior) self.chemist = Chemist(TDS, world, 'NPC:chemist', self.agentlayer) self.game.instance_to_agent[self.chemist.agent.getFifeId()] = self.chemist self.chemist.start() self.agent_list.append(self.chemist) self.playableAgent = [] self.reset()
def generateGirls(n): girl_types = ['Choosy', 'Normal', 'Desperate'] criteria = ['Attractive', 'Rich', 'Intelligent'] girls = [] fd2 = open('./Girls.csv', 'w') writer = csv.writer(fd2, delimiter=',') for i in range(0, n): g = [ Girl('Girl' + str(i), random.randint(1, 11), random.randint(1, 11), random.randint(1, 11), criteria[random.randint(0, 2)], girl_types[random.randint(0, 2)]) ] girls += g writer.writerow(g) fd2.close() return girls
def matchMaker(): with open('boys.csv', 'rb') as csvfile: reader = csv.reader(csvfile, delimiter=',') By = [ Boy(line[0], int(line[1]), int(line[2]), int(line[3]), line[4], int(line[5])) for line in reader ] csvfile.close() with open('girls.csv', 'rb') as csvfile: reader = csv.reader(csvfile, delimiter=',') Gl = [ Girl(line[0], int(line[1]), int(line[2]), int(line[3]), line[4]) for line in reader ] csvfile.close() logging.info('Match in progress\n') #Checking conditions for g in Gl: for b in By: logging.info('Matching: Girl: ' + g.gname + ' with Boy: ' + b.bname) if g.gstatus == False and b.bstatus == False and g.gattract >= b.battractReq and g.gbudget <= b.bbudget: g.gstatus = True b.bstatus = True g.bf = b.bname b.gf = g.gname #print('-----'+' '+b.battractReq+' '+g.gattract+'\n') logging.info('Commitment: Girl: ' + g.gname + ' got commited with Boy: ' + b.bname) break #elif(g.gstatus==True or b.bstatus==True): # print (b.bname +' '+g.gname+' commited\n') #elif(g.gbudget>b.bbudget): # print (b.bname+' '+g.gname+' too costly '+b.bbudget+' '+g.gbudget+'\n') #elif(b.battractReq>g.gattract): # print (b.bname+' '+g.gname+' hotter '+b.battractReq+' '+g.gattract+' \n') logging.info('Match making done') for g in Gl: if g.gstatus == False: print 'A Girl: ' + g.gname + ' has no boyfriend' else: print 'A Girl: ' + g.gname + ' has a boyfriend Boy: ' + g.bf
setattr(boy,boy.happiness,boy.budget - sum([i.price for i in gift])) if(boy.types == 'Generous'): setattr(boy,boy.happiness,girl.happiness) if(boy.types == 'Geeks'): setattr(boy,boy.happiness,girl.intel_level) generator() boycsv = open('boy.csv') girlcsv = open('girl.csv') giftcsv = open('gift.csv') readBoy = csv.reader(boycsv, delimiter = ',') readGirl = csv.reader(girlcsv, delimiter = ',') readGift = csv.reader(giftcsv, delimiter = ',') B = [ Boy(row[0],int(row[1]),int(row[2]),int(row[3]),int(row[4]),row[5]) for row in readBoy] G = [ Girl(row[0],int(row[1]),int(row[2]),int(row[3]),row[4]) for row in readGirl] gift = [ Gift(row[0],int(row[1]),int(row[2]),row[3]) for row in readGift] C = [] count = 0 for g in G: for b in B: #print ("Trying match :" + g.name + " with " + b.name) if(g.isElligible(b) and b.isElligible(g)): count += 1 print("GirlFriend : " + g.name + ", BoyFriend : " + b.name) g.changeStatus() b.changeStatus() logger(' commitment : ' + g.name + " and " + b.name)
class AgentManager(): def __init__(self, world): self.player = 0 self.player_faces = ['gui/images/hud_boy.png', 'gui/images/hud_girl.png', 'gui/images/hud_warrior.png', 'gui/images/hud_wizard.png'] self.agent_list = [] self.game = code.game.Game.getGame() """ Intializes all the agents. All these instances are also added to the self.agent_list list to simplify the searches by name or id. """ def initAgents(self, world): self.agentlayer = world.map.getLayer('TechdemoMapGroundObjectLayer') world.agentlayer = self.agentlayer self.boy = Boy(TDS, world, 'PC:boy', self.agentlayer) self.game.instance_to_agent[self.boy.agent.getFifeId()] = self.boy self.boy.start() self.agent_list.append(self.boy) self.girl = Girl(TDS, world, 'PC:girl', self.agentlayer, self) self.game.instance_to_agent[self.girl.agent.getFifeId()] = self.girl self.girl.start() self.agent_list.append(self.girl) self.wizard = Wizard(TDS, world, 'PC:wizard', self.agentlayer, self) self.game.instance_to_agent[self.wizard.agent.getFifeId()] = self.wizard self.wizard.start() self.agent_list.append(self.wizard) self.beekeepers = create_anonymous_agents(TDS, world, 'beekeeper', self.agentlayer, Beekeeper) for beekeeper in self.beekeepers: self.game.instance_to_agent[beekeeper.agent.getFifeId()] = beekeeper beekeeper.start() self.agent_list.append(beekeeper) self.cage = Cage(TDS, world, 'sword_crate', self.agentlayer) self.game.instance_to_agent[self.cage.agent.getFifeId()] = self.cage self.cage.start() self.agent_list.append(self.cage) self.bees = [] for i in range(1, 8): bee = code.agents.bee.Bee(TDS, world, 'NPC:bee:0{}'.format(i), self.agentlayer, self) self.bees.append(bee) self.game.instance_to_agent[bee.agent.getFifeId()] = bee bee.start() self.agent_list.append(bee) self.warrior = Warrior(TDS, world, 'PC:warrior', self.agentlayer) self.game.instance_to_agent[self.warrior.agent.getFifeId()] = self.warrior self.warrior.start() self.agent_list.append(self.warrior) self.chemist = Chemist(TDS, world, 'NPC:chemist', self.agentlayer) self.game.instance_to_agent[self.chemist.agent.getFifeId()] = self.chemist self.chemist.start() self.agent_list.append(self.chemist) self.playableAgent = [] self.reset() """ This method checks if the first 3 bees are near the beeboxes. """ def beesAtHome(self): for bee in self.bees: if int(bee.agentName[-2:]) <= 3 and bee.mode == code.agents.bee._MODE_WILD: return False return True """ This method checks if the bees whith id >= 4 are all dead. """ def beesDead(self): for bee in self.bees: if int(bee.agentName[-2:]) >= 4 and bee.mode != code.agents.bee._MODE_DEAD: return False return True def reset(self): for p in self.playableAgent: p.reset() self.playableAgent = [self.boy, self.girl] self.active_agent = self.boy """ Returns the current active agent. """ def getActiveAgent(self): return self.active_agent """ Returns the FIFE instance of the current active agent. """ def getActiveInstance(self): return self.active_agent.agent """ Returns the current active agent's location. """ def getActiveAgentLocation(self): return self.active_agent.agent.getLocation() def getHero(self): return self.active_agent def getGirl(self): return self.girl """ Changes the current active agent. The list self.playableAgent contains all the currently playable characters. """ def toggleAgent(self, world, face_button): self.player = (self.player + 1) % len(self.playableAgent) face_button.up_image = self.player_faces[self.player] face_button.down_image = self.player_faces[self.player] face_button.hover_image = self.player_faces[self.player] for i in range(len(self.playableAgent)): self.playableAgent[i].idle() if i == self.player: self.playableAgent[i].isActive = True world.cameras['main'].attach(self.playableAgent[i].agent) world.cameras['small'].attach(self.girl.agent) self.active_agent = self.playableAgent[i] else: self.playableAgent[i].isActive = False self.playableAgent[i].follow_hero() """ Returns the Agent to the agent with a specific fifeId. """ def getAgentFromId(self, fifeId): for ag in self.agent_list: if ag.agent.getFifeId() == fifeId: return ag return None """ Returns the Agent to the agent with a specific name. """ def getAgentByName(self, name): for ag in self.agent_list: if ag.agentName == name: return ag return None """ Adds a new playable agent if it's not yet present inside the playableAgent list. """ def addNewPlayableAgent(self, name): for a in self.playableAgent: if a.agentName == name: return for a in self.agent_list: if a.agentName == name: self.playableAgent.append(a) if a.agentName != self.active_agent.agentName: a.follow_hero() def destroy(self): for a in self.agent_list: a.destroy()
def __init__(self, gname, gattract, gintellij, gbudget, gtypes): Girl.__init__(self, gname, gattract, gintellij, gbudget, gtypes) self.gstatus = False self.ghappiness = 0 self.bf = ''
from boy import Boy from girl import Girl john = Male('John', 32) print(f'Lonely man: {john}') martha = Female('Martha', 54) print(f'Lonely woman: {martha}') parents = john % martha print(f'Then they had sex and become {type(parents.mother).__name__} and {type(parents.father).__name__}') print('9 months passed') bill = Boy('Bill', 0, parents.father, parents.mother) amy = Girl('Amy', 0, parents.father, parents.mother) print('Some kids were born:') print(f'{type(bill).__name__}: ({bill})') print(f'{type(amy).__name__}: ({amy})') print('Now both of them have children:') parents.mother.children.append(bill) parents.mother.children.append(amy) parents.father.children.append(bill) parents.father.children.append(amy) print(parents.mother) print(parents.father) newlywed = parents.mother & parents.father print(f'Finally they decided to get married and become {type(newlywed.husband).__name__} \ and {type(newlywed.wife).__name__}') print(newlywed.husband)