示例#1
0
 def generateMobs(self):
     """
     Función que genera las agrupaciones de mobs al azar
     :return: void
     """
     total_friends = (
                     self.player.getLightFriends() + self.player.getMediumFriends() + self.player.getStrongFriends()) + \
                     BASE_ENEMIES[self.dificultad]
     total_mobs = int(total_friends * ENEMY_COEFICIENT[self.dificultad])
     if self.enemies.getTipoAtaque() == "LARGO":
         large = True
     else:
         large = False
     while total_mobs > 0:  # Genero grupos de followers pesados
         mobs = min(total_mobs,
                    random.randint(int(
                        PARTITION_PLAYER[self.dificultad] * GROUP_MAX_SIZE[
                            self.dificultad]),
                        GROUP_MAX_SIZE[self.dificultad]))
         self.mobs.append(group("MB", mobs,
                                self.enemies.getLife() *
                                COEF_MOB["HP"] * (2 - self.dificultad_coef),
                                self.enemies.getAtaque() *
                                COEF_MOB["ATK"] *
                                (2 - self.dificultad_coef),
                                self.enemies.getDefensa() *
                                COEF_MOB["DEF"] *
                                (2 - self.dificultad_coef),
                                self.enemies.getImage(), large,
                                self.enemies.getTarget() *
                                COEF_MOB["TAR"] *
                                (2 - self.dificultad_coef),
                                ENEMY_MOVEMENT[self.dificultad],
                                self.enemies.getTipoAtaque()))
         total_mobs -= mobs
示例#2
0
 def generateMobs(self):
     """
     Función que genera las agrupaciones de mobs al azar
     :return: void
     """
     total_friends = (
                             self.player.getLightFriends() + self.player.getMediumFriends() + self.player.getStrongFriends()) + \
                     BASE_ENEMIES[self.dificultad]
     total_mobs = int(total_friends * ENEMY_COEFICIENT[self.dificultad])
     if self.enemies.getTipoAtaque() == "LARGO":
         large = True
     else:
         large = False
     while total_mobs > 0:  # Genero grupos de followers pesados
         mobs = min(
             total_mobs,
             random.randint(
                 int(PARTITION_PLAYER[self.dificultad] *
                     GROUP_MAX_SIZE[self.dificultad]),
                 GROUP_MAX_SIZE[self.dificultad]))
         self.mobs.append(
             group(
                 "MB", mobs,
                 self.enemies.getLife() * COEF_MOB["HP"] *
                 (2 - self.dificultad_coef),
                 self.enemies.getAtaque() * COEF_MOB["ATK"] *
                 (2 - self.dificultad_coef),
                 self.enemies.getDefensa() * COEF_MOB["DEF"] *
                 (2 - self.dificultad_coef), self.enemies.getImage(), large,
                 self.enemies.getTarget() * COEF_MOB["TAR"] *
                 (2 - self.dificultad_coef),
                 ENEMY_MOVEMENT[self.dificultad],
                 self.enemies.getTipoAtaque()))
         total_mobs -= mobs
示例#3
0
    def groupsBuild (self):
        """Costruisce il vettore dei Gruppi"""
        groups = []
        for i in range(len(self.T)):
            if len(self.T[i]) != 0 :
                g = group (self.T[i])
                groups.append (g)
        self.groups = groups

        for i in range (len (self.groups)):
            #print i
            errors = self.groups[i].cleanSet (self.coverage)
            #errors, tobecorr, chcorr = self.groups[i].cleanSet (self.coverage)
            #if chcorr != "-":
            #    chcorr = self.origM[chcorr][i]
            #    for e in tobecorr:
            #        if self.coverage > 2:
            #            self.origM[e] = self.origM[e][:i] + chcorr + self.origM[e][i+1:]
            #        self.M[e] = self.M[e][:i] + chcorr + self.M[e][i+1:]
            for e in errors:
                # This line is for test
                #self.M[e] = self.M[e][:i] + string.upper (self.M[e][i]) + self.M[e][i+1:]
                self.M[e] = self.M[e][:i] + "-" + self.M[e][i+1:]
示例#4
0
 def generatePlayers(self):
     """
     Función que genera las agrupaciones de followers al azar
     :return: void
     """
     # Se obtienen los followers
     light_friends = self.player.getLightFriends()
     medium_friends = self.player.getMediumFriends()
     strong_friends = self.player.getStrongFriends()
     # Se agrega al jugador
     self.players.append(
         group(
             "PL", 1,
             self.player.getMaxLife() - self.player.getDamage(),
             self.player.getAttack() *
             COEF_PLAYER["ATK"] * (2 - self.dificultad_coef),
             self.player.getDefensa(), self.player.getLinkImage(), True,
             self.player.getTarget(), COEF_VEL["P"][self.dificultad],
             "Player"))
     while light_friends > 0:  # Genero grupos de followers livianos
         followers = min(
             light_friends,
             random.randint(
                 int(PARTITION_PLAYER[self.dificultad] *
                     GROUP_MAX_SIZE[self.dificultad]),
                 GROUP_MAX_SIZE[self.dificultad]))
         if followers > 0:
             self.players.append(
                 group(
                     "FL", followers,
                     self.player.getMaxLife() * COEF_VIDA["L"] *
                     self.dificultad_coef,
                     self.player.getAttack() * COEF_ATK["L"] *
                     self.dificultad_coef,
                     self.player.getDefensa() *
                     COEF_DEF["L"] * self.dificultad_coef,
                     self.player.getLightImageFriend(), False,
                     self.player.getTarget() * COEF_TAR["L"] *
                     self.dificultad_coef, COEF_VEL["L"][self.dificultad],
                     "Normal"))
             light_friends -= followers
     while medium_friends > 0:  # Genero grupos de followers medios
         followers = min(
             medium_friends,
             random.randint(
                 int(PARTITION_PLAYER[self.dificultad] *
                     GROUP_MAX_SIZE[self.dificultad]),
                 GROUP_MAX_SIZE[self.dificultad]))
         if followers > 0:
             self.players.append(
                 group(
                     "FM", followers,
                     self.player.getMaxLife() * COEF_VIDA["M"] *
                     self.dificultad_coef,
                     self.player.getAttack() * COEF_ATK["M"] *
                     self.dificultad_coef,
                     self.player.getDefensa() *
                     COEF_DEF["M"] * self.dificultad_coef,
                     self.player.getMediumImageFriend(), False,
                     self.player.getTarget() * COEF_TAR["M"] *
                     self.dificultad_coef, COEF_VEL["M"][self.dificultad],
                     "Normal"))
             medium_friends -= followers
     while strong_friends > 0:  # Genero grupos de followers pesados
         followers = min(
             strong_friends,
             random.randint(
                 int(PARTITION_PLAYER[self.dificultad] *
                     GROUP_MAX_SIZE[self.dificultad]),
                 GROUP_MAX_SIZE[self.dificultad]))
         if followers > 0:
             self.players.append(
                 group(
                     "FS", followers,
                     self.player.getMaxLife() * COEF_VIDA["S"] *
                     self.dificultad_coef,
                     self.player.getAttack() * COEF_ATK["S"] *
                     self.dificultad_coef,
                     self.player.getDefensa() *
                     COEF_DEF["S"] * self.dificultad_coef,
                     self.player.getStrongImageFriend(), False,
                     self.player.getTarget() * COEF_TAR["S"] *
                     self.dificultad_coef, COEF_VEL["S"][self.dificultad],
                     "Normal"))
             strong_friends -= followers
示例#5
0
# End of first step

rowsA = set(a)
rowsB = set(b)
rowsA, rowsB, vCompares = SNP.reconstruction_step2(rowsA, rowsB)
h1 = SNP.outputHaplotype(rowsA)
h2 = SNP.outputHaplotype(rowsB)
print rowsA
print rowsB
print h1
print h2
print "Fine secondo step"

alpha, beta = SNP.reconstruction_step3(rowsA, rowsB, vCompares)
if alpha is not None and beta is not None:
    g1 = group(rowsA, rowsB)
    g2 = group(alpha, beta)
    m = g1.getComparMatrix(g2)
    canJoin = g2.detectErrorInGroupWeak(m, g1)
    if canJoin:
        m = g1.getComparMatrix(g2)
        g1.alpha = 0
        g1.beta = 1
        g1.labeled = True
        g2.labelingGroup(m, g1, True)
        rowsA = g1.sets[g1.alpha] | g2.sets[g2.alpha]
        rowsB = g1.sets[g1.beta] | g2.sets[g2.beta]

h1 = SNP.outputHaplotype(rowsA, True)
h2 = SNP.outputHaplotype(rowsB, True)
print rowsA
示例#6
0
def test_group_writer():
    small = 1000000
    test_group_primitives = [
        line(0,
             small * 2,
             0,
             -small,
             "C",
             0,
             "copper",
             thickness=0.25,
             clearance=None),
        circle(small, 0, 0, "copper", thickness=0.25, clearance=None),
        text(0,
             -small * 2,
             "Group",
             0.75,
             0,
             0,
             "copper",
             thickness=0.05,
             clearance=None),
        polygon(-small,
                0,
                0, [(-small, -small / 2), (-small, small / 2), (small, 0)],
                0,
                "copper",
                thickness=0.0,
                clearance=None),
        arc(small,
            0,
            small,
            "S",
            1,
            1,
            45,
            315,
            0,
            "copper",
            thickness=0.25,
            clearance=None)
    ]

    dist = 10000000
    test_primitives = [
        group(0, 0, 0, test_group_primitives, angle=0),
        group(dist, 0, 0, test_group_primitives, angle=0),
        group(dist, dist, 0, test_group_primitives, angle=45),
        group(0, dist, 0, test_group_primitives, angle=90),
        group(-dist, dist, 0, test_group_primitives, angle=135),
        group(-dist, 0, 0, test_group_primitives, angle=180),
        group(-dist, -dist, 0, test_group_primitives, angle=215),
        group(0, -dist, 0, test_group_primitives, angle=270),
        group(dist, -dist, 0, test_group_primitives, angle=315),
    ]

    large = 60000000
    #Groups containing groups
    offset_primitives = [group(large, 0, 0, test_primitives, angle=22.4)]

    final_primitives = [
        #center
        group(-large, 0, 0, offset_primitives, angle=0),
        group(0, 0, 0, offset_primitives, angle=0),
        group(0, 0, 0, offset_primitives, angle=45),
        group(0, 0, 0, offset_primitives, angle=90),
        group(0, 0, 0, offset_primitives, angle=135),
        group(0, 0, 0, offset_primitives, angle=180),
        group(0, 0, 0, offset_primitives, angle=215),
        group(0, 0, 0, offset_primitives, angle=270),
        group(0, 0, 0, offset_primitives, angle=315),
    ]

    writer = group_writer("group_export.gbr", final_primitives)
    writer.write()

    return
示例#7
0
    def labelGroup (self,alphaset, betaset, correctErrors):
        """ data una partizione iniziale delle righe restituisce, se possibile, una partizione piu ampia
        ottenuta confrontando il superGruppo costruito a partire dalla partizione iniziale con 
        tutti i gruppi non ancora etichettati. se il parametro correctErrors= True,
        gli errori riscontrati vengono corretti sia nei gruppi che nella matrice di input"""
        
        isChanged = False
        alpha = [0 for i in range (len (self.M))]
        beta = [0 for i in range (len (self.M))]
        alpha_err = set ()
        beta_err = set ()
        superGroup = group (alphaset, betaset)
        vCompares = self.buildVectorSuperGVSGroups ( superGroup )
        for i in range  (len(self.groups)):
            #print i, self.groups[i].labeled
            if( not self.groups[i].labeled and vCompares[i] != None  ):
              
                if correctErrors == True:
                    """prima corregge il gruppo e poi prova ad etichettarlo """
                    rowA, rowB, indA, indB = self.groups[i].markGroup (vCompares[i], superGroup)
                    characterA = self.M[indA][i]
                    characterB = self.M[indB][i]
                    for e in rowA :
                        self.M[e] = self.M[e][:i] + characterB  + self.M[e][i+1:]
                    for e in rowB :
                        self.M[e] = self.M[e][:i] + characterA  + self.M[e][i+1:]
                            
                    mcompares = self.groups[i].getComparMatrix (superGroup)
                    #print mcompares
                    a,b = self.groups[i].labelingGroup ( mcompares, superGroup, False)
                elif correctErrors == False:
                    a,b = self.groups[i].labelingGroup ( vCompares[i] , superGroup, False)
                else:
                    errA, errB = self.groups[i].detectErrorInGroup (vCompares[i], superGroup)
                    mcompares = self.groups[i].getComparMatrix (superGroup)
                    a,b = self.groups[i].labelingGroup ( mcompares , superGroup, False)
                    for e in errA:
                        alpha_err.add (e)
                    for e in errB:
                        beta_err.add (e)
                for x in a:
                    alpha[x] += 1
                for x in  b:
                    beta[x] += 1

        for err in alpha_err:
            alphaset.discard (err)
        for err in beta_err:
            betaset.discard (err)

        for i in range (len(self.M)):
            if alpha[i] > beta[i]:
                if(not i in betaset):
                    alphaset.add(i)
                    isChanged = True

            if alpha[i] < beta[i] :
                if(not i in alphaset):
                    betaset.add (i)
                    isChanged = True

        return isChanged, vCompares
示例#8
0
nodeset2 = nodeset(obj.doc,"age")
nodeset2.update_attributes("","false","true")
model_node.appendChild(nodeset2.return_object())

nodeset3 = nodeset(obj.doc,"birthday")
nodeset3.update_attributes("date","false","true")
nodeset3.add_lt_gt_constraint("today","","Birthdays cannot be in the future!")
model_node.appendChild(nodeset3.return_object())

nodeset4 = nodeset(obj.doc,"zipcode")
nodeset4.update_attributes("integer","false","true")
nodeset4.add_lt_gt_constraint("99950","00210","Zipcodes must less than 99951 and greater than 00209!")
model_node.appendChild(nodeset4.return_object())

body = obj.return_body_node()
grp_element = group(obj.doc,"person's details")
input_item = inputs(obj.doc,"Enter5 patients name")
input_item.add_referenceAttribute("name")
grp_element.add_group_item(input_item.return_object())

select1_item = select1(obj.doc,"Is the child suffering from malaria")
select1_item.add_referenceAttribute("age")
select1_item.add_item("yes","yes")
select1_item.add_item("no","no")

grp_element.add_group_item(select1_item.return_object())

item3 = inputs(obj.doc,"When was the person born")
item3.add_referenceAttribute("birthday")
grp_element.add_group_item(item3.return_object())
示例#9
0
 def generatePlayers(self):
     """
     Función que genera las agrupaciones de followers al azar
     :return: void
     """
     # Se obtienen los followers
     light_friends = self.player.getLightFriends()
     medium_friends = self.player.getMediumFriends()
     strong_friends = self.player.getStrongFriends()
     # Se agrega al jugador
     self.players.append(
         group("PL", 1, self.player.getMaxLife() - self.player.getDamage(),
               self.player.getAttack() *
               COEF_PLAYER["ATK"] *
               (2 - self.dificultad_coef),
               self.player.getDefensa(), self.player.getLinkImage(),
               True, self.player.getTarget(),
               COEF_VEL["P"][self.dificultad], "Player"))
     while light_friends > 0:  # Genero grupos de followers livianos
         followers = min(light_friends,
                         random.randint(int(
                             PARTITION_PLAYER[self.dificultad] *
                             GROUP_MAX_SIZE[self.dificultad]),
                             GROUP_MAX_SIZE[self.dificultad]))
         if followers > 0:
             self.players.append(
                 group("FL", followers,
                       self.player.getMaxLife() * COEF_VIDA[
                           "L"] * self.dificultad_coef,
                       self.player.getAttack() *
                       COEF_ATK["L"] * self.dificultad_coef,
                       self.player.getDefensa() *
                       COEF_DEF["L"] * self.dificultad_coef,
                       self.player.getLightImageFriend(), False,
                       self.player.getTarget() *
                       COEF_TAR["L"] * self.dificultad_coef,
                       COEF_VEL["L"][self.dificultad], "Normal"))
             light_friends -= followers
     while medium_friends > 0:  # Genero grupos de followers medios
         followers = min(medium_friends,
                         random.randint(int(
                             PARTITION_PLAYER[self.dificultad] *
                             GROUP_MAX_SIZE[self.dificultad]),
                             GROUP_MAX_SIZE[self.dificultad]))
         if followers > 0:
             self.players.append(
                 group("FM", followers,
                       self.player.getMaxLife() * COEF_VIDA[
                           "M"] * self.dificultad_coef,
                       self.player.getAttack() *
                       COEF_ATK["M"] * self.dificultad_coef,
                       self.player.getDefensa() *
                       COEF_DEF["M"] * self.dificultad_coef,
                       self.player.getMediumImageFriend(), False,
                       self.player.getTarget() *
                       COEF_TAR["M"] * self.dificultad_coef,
                       COEF_VEL["M"][self.dificultad], "Normal"))
             medium_friends -= followers
     while strong_friends > 0:  # Genero grupos de followers pesados
         followers = min(strong_friends,
                         random.randint(int(
                             PARTITION_PLAYER[self.dificultad] *
                             GROUP_MAX_SIZE[self.dificultad]),
                             GROUP_MAX_SIZE[self.dificultad]))
         if followers > 0:
             self.players.append(
                 group("FS", followers,
                       self.player.getMaxLife() * COEF_VIDA[
                           "S"] * self.dificultad_coef,
                       self.player.getAttack() *
                       COEF_ATK["S"] * self.dificultad_coef,
                       self.player.getDefensa() *
                       COEF_DEF["S"] * self.dificultad_coef,
                       self.player.getStrongImageFriend(), False,
                       self.player.getTarget() *
                       COEF_TAR["S"] * self.dificultad_coef,
                       COEF_VEL["S"][self.dificultad], "Normal"))
             strong_friends -= followers