예제 #1
0
    def mixNormalCells(self,mother,father):
        attIgnoreList=[0,4,7,11,12,16,17,18,19]
        print "\n\n"
        print "mixing normal cells"
        newCell=baseCell(father)
        for i in xrange(0,len(father.getAtts())):
            if i in attIgnoreList:
                continue

            fathertext=0

            choice=randint(0,1)

            if i==0: ##angle
                if choice==fathertext:
                    newCell.angle=father.angle
                else:
                    newCell.angle=mother.angle
            elif i==1: ##timeToLay+left
                if choice==fathertext:
                    newCell.timeToLay=father.timeToLay
                else:
                    newCell.timeToLay=mother.timeToLay
            elif i==2: ##eggWithdraw
                if choice==fathertext:
                    newCell.eggwithdraw=father.eggwithdraw
                else:
                    newCell.eggwithdraw=mother.eggwithdraw
            elif i==3: ##carnivore
                if choice==fathertext:
                    newCell.carnivore=father.carnivore
                else:
                    newCell.carnivore=mother.carnivore
            elif i==4: ##food
                newCell.food=50
            elif i==5: ##foodWithdraw
                if choice==fathertext:
                    newCell.foodWithdraw=father.foodWithdraw
                else:
                    newCell.foodWithdraw=mother.foodWithdraw
            elif i==6: ##ID
                newCell.ID=algorithm.getNextID()
            elif i==7: ##lastmother
                if choice==fathertext:
                    newCell.lastmother=father.lastmother
                else:
                    newCell.lastmother=mother.lastmother
            elif i==8: ##lifetime
                if choice==fathertext:
                    newCell.lifeTime=father.lifeTime
                else:
                    newCell.lifeTime=mother.lifeTime
            elif i==9: ##lifetimeWithdraw
                if choice==fathertext:
                    newCell.lifewithdraw=father.lifewithdraw
                else:
                    newCell.lifewithdraw=mother.lifewithdraw
            elif i==10: ##speed
                if choice==fathertext:
                    newCell.speed=father.speed
                else:
                    newCell.speed=mother.speed
            elif i==11: ##location
                if choice==fathertext:
                    newCell.location=father.location
                else:
                    newCell.location=mother.location
            elif i==12: ##rad
                if choice==fathertext:
                    newCell.rad=father.rad
                else:
                    newCell.rad=mother.rad
            elif i==13: ##ai
                if choice==fathertext:
                    newCell.AI=father.AI
                else:
                    newCell.AI=mother.AI
            elif i==14: ##vision
                if choice==fathertext:
                    newCell.vision=father.vision
                else:
                    newCell.vision=mother.vision
            elif i==15: ##eggHatchTime
                if choice==fathertext:
                    newCell.eggHatchTime=father.eggHatchTime
                else:
                    newCell.eggHatchTime=mother.eggHatchTime
            elif i==20: ##strength
                if choice==fathertext:
                    newCell.strength=father.strength
                else:
                    newCell.strength=mother.strength
        return newCell
예제 #2
0
    def mixPlayerCells(self,mother,father):
        choice=None
        while choice not in ["Manual","Auto"]:
            choice=graphics.askBoard("manual","Manual or Auto?","Manual","Auto")
        if choice=="Auto":
            return self.mixNormalCells(mother,father)
        else: ## manual mode
            attIgnoreList=[0,4,7,11,12,16,17,18,19]
            print "\n\n"
            print "mixing cells manual"
            newCell=baseCell(father)
            for i in xrange(0,len(father.getAtts())):
                if i in attIgnoreList:
                    continue
                ##print colored("(1)","blue"), colored(father.getAtts()[i].ljust(25),"magenta"),
                ##print colored("(2)","blue"), colored(mother.getAtts()[i],"magenta")
                ##choice=raw_input()
                if i!=6:
                    fathertext=father.getAtts()[i]
                    mothertext=mother.getAtts()[i]
                    choice=None
                    while choice not in [fathertext,mothertext]:
                        choice=graphics.askBoard("manual","choose attribute",fathertext,mothertext)

                if i==1: ##timeToLay+left
                    if choice==fathertext:
                        newCell.timeToLay=father.timeToLay
                    else:
                        newCell.timeToLay=mother.timeToLay
                if i==2: ##eggWithdraw
                    if choice==fathertext:
                        newCell.eggwithdraw=father.eggwithdraw
                    else:
                        newCell.eggwithdraw=mother.eggwithdraw
                if i==3: ##carnivore
                    if choice==fathertext:
                        newCell.carnivore=father.carnivore
                    else:
                        newCell.carnivore=mother.carnivore
                if i==5: ##foodWithdraw
                    if choice==fathertext:
                        newCell.foodWithdraw=father.foodWithdraw
                    else:
                        newCell.foodWithdraw=mother.foodWithdraw
                if i==6: ##ID
                    newCell.ID=algorithm.getNextID()
                if i==8: ##lifetime
                    if choice==fathertext:
                        newCell.lifeTime=father.lifeTime
                    else:
                        newCell.lifeTime=mother.lifeTime
                if i==9: ##lifetimeWithdraw
                    if choice==fathertext:
                        newCell.lifewithdraw=father.lifewithdraw
                    else:
                        newCell.lifewithdraw=mother.lifewithdraw
                if i==10: ##speed
                    if choice==fathertext:
                        newCell.speed=father.speed
                    else:
                        newCell.speed=mother.speed
                if i==13: ##ai
                    if choice==fathertext:
                        newCell.AI=father.AI
                    else:
                        newCell.AI=mother.AI
                if i==14: ##vision
                    if choice==fathertext:
                        newCell.vision=father.vision
                    else:
                        newCell.vision=mother.vision
                if i==15: ##eggHatchTime
                    if choice==fathertext:
                        newCell.eggHatchTime=father.eggHatchTime
                    else:
                        newCell.eggHatchTime=mother.eggHatchTime
                if i==20: ##strength
                    if choice==fathertext:
                        newCell.strength=father.strength
                    else:
                        newCell.strength=mother.strength
        return newCell