Code Monkey home page Code Monkey logo

4d's Issues

Problem 13

Riga 433
class QueenAnt(ScubaThrower):

Riga 438
food_cost = 7
implemented = True
queen_number = 0 #contatore per sapere se quella inserita è la regina vera o una falsa

Riga 445
self.queen_number += 1
if self.queen_number == 1:
self.true_queen = True #se è presente una sola regina è quella vera
else:
self.true_queen = False #se sono presenti già delle regine quella inserita è quella falsa

Riga 455
if self.true_queen = True:
ScubaThrower.action(self, colony) #compie l'azione di una scuba thrower
now_place = self.place.exit #considero il place posteriore alla posizione della regina
while now_place is not None: #continua a funzionare fino al raggiungimento della fine del tunnel
if now_place.ant is not None: #se nel now_place è presente una formica ne raddoppia i danni
ant.damage = ant.damage*2
now_place = now_place.exit #il now_place viene spostato un passo indietro
else:
now_place = now_place.exit
#fine del while (si ritorna all'if true_queen)
else: #se la regina è falsa viene rimossa
self.armor = 0
self.place.remove_insect(self)

Riga 463
self.armor -= amount
if true_queen.armor <= 0: #se la regina vera muore le api vincono
bees_win( ) #vittoria delle api

PROBLEMA 12

class ScubaThrower(ThrowerAnt):
"""ScubaThrower is a ThrowerAnt which is watersafe."""

name = 'Scuba'  
food_cost = 6
armor = 1 
is_watersafe = True #caratteristica di questa formica è che può sopravvivere in acqua
implemented = True  #viene settato il valore true ( così da poterlo usare nel gioco )

Problema 4

Riga 241:

    food_cost = 2
    min_range = 0
    max_range = 3

Dieci righe dopo:```

food_cost = 2
min_range = 5
max_range = 100
Altre dieci righe dopo:
food_cost = 6

E implementare il reducing armor

Su tutti:`
   implemented = True`

Problema 6 HungryAnt pt3 (fine)

riga 322:

 if self.digesting != 0: #controllo se la fromica sta mangiando
            self.digesting -= 1 #se sta mangiando le tolgo un turno
        else:
            bees = list(self.place.bees) #in caso contrario la faccio mangiare un'ape
            if bees !=0:  #può mangiare l'ape solo se si trova nei dintroni
                self.eat_bee(random.choice(bees) 
                self.digesting = self.time_to_digest # mangiata l'ape si aumentano il numero di turni da aspettare (di default è 3)

Problema 6 HungryAnt pt2

riga 312:
self.digesting = 0 #default a zero dal momento che la formica non ha mangiato niente
self.armor = armor #default armatura HungryAnt

riga 316:
bee.reduce_armor(bee.armor) #una volta mangiata l'ape, l'armatura di essa scende
self.digesting = self.time_to_digest #aumento dei turni da aspettare dato che la formica ha appena mangiato

Problem #7

Riga 332
blocks_path = False
food_cost = 5
implemented = True

Riga 337
for bee in self.place.bees:
bee.reduce_armor(self.damage)

Problem 10

Riga 388
implemented = True
food_cost = 6

Riga 394
def action(self, colony):
for bee in self.place.bees[:]:
bee.reduce_armor(self.damage) #riduce di uno la vita di tutte le api
if self.ant is not None: #se nella tank ant c'è una formica riprende la funzione presente
self.ant.action(colony) #nella bodyguard ant che compie l'azione della formica contenuta

PROBLEMA 11

Riga 96
is_watersafe = False
#inserire nella class insect(object) l'attributo che esprime l'incapacità di sopravvivenza nell'acqua
Riga 132
is_watersafe = True
#inserire nella classe Bee(insect) l'attributo che esprime la capacità di sopravvivenza delle api dall'acqua (dato che possono volare )
Riga 425
#inserire nella in def add_insect(self, insect): problema 11
Place.add_insect(self, insect) #l'insetto viene aggiunto nella posizione
if insect.is_watersafe is not True: #se l'insetto che viene inserito non sopravvive all'acqua muore, ovvero se is_watersafe= False
insect.reduce_armor(insect.armor) #viene ridotta l'armatura dell'insetto

VARIANTE RIGA 425
Place.add_insect(self, insect)
if insect.is_watersafe ==True:
insect.reduce_armor(insect.armor)

test

Test effettuato.

Ants VS Bees

Riga 208
min_range = 0
Riga 209
max_range = 100

Problem #3 and #4

place_to_throw = self.place #Lancio iniziale alla Place in cui si trova la formica stessa
places_looked = 0

    while place_to_throw is not hive: #Finché la formica non è arrivata all'alveare viene eseguito il ciclo
        if (places_looked >= self.min_range and
            places_looked <= self.max_range):
            bee = random_or_none(place_to_throw.bees) #Ritorna un'ape casuale
            if not bee:
                place_to_throw = place_to_throw.entrance
                places_looked +=1 #Incrementa di 1 il Place a cui guarda
            else:
                return bee #Ritorna un'ape
        else: 
            place_to_throw = place_to_throw.entrance
            places_looked +=1
    
    return None

Problem 13 (extra credit)

Riga 486

def slow_action(colony):
if colony.time % 2 == 0:
action(colony)
else:
return
return slow_action

Riga 495

def scare_action(colony):
if bee.scared_once == False:
bee.scared_once = True
bee.direction = 'backwards'
action(colony)
else:
return scare_action

Riga 501

original_action = bee.action
new_action = effect(bee.action)
duration_counter = 0
def function(b):
nonlocal duration_counter
if duration_counter > 0:
b.action = new_action
duration_counter -= 1
else:
b.action = original_action
return function(bee)

Riga 510
food_cost = 4
implemented = True

Riga 523
food_cost = 6
implemented = True

Riga 528

if target.scared_once == False:
target.currently_in_scare_1 = 2
target.scared_once = True
if target.currently_in_scare_1:
apply_effect(make_scare, target, target.currently_in_scare_1)
if target.scared_once and target.currently_in_scare_1 == 0:
return
else:
return
back away / (stay if at the back) + still for 2 turns

Questo è cio che ho fatto negli ultimi due giorni di sicuro ci sono degli errori però sono arrivato fin qua

problem 9

line 46 da sostituire con:

#gestione nella classe place della possibilità di un insetto che ne contenga un'altro

if self.ant is not None:
control= True
if self.ant.is_container(insect):
self.ant.contained_ant = insect
control= False
return
if insect.is_container(self.ant):
insect.ant.contained_ant= self.ant
self.ant.place= insect
control= False
return
if control:
assert self.ant is None, 'Two ants in {0}'.format(self)

line 175: # implementazione attributo possibilità di contenere
is_container= False

line 361 #implementazione attributi della classe bodyguard

implemented = True
food_cost = 4
is_container= True

line 368 a seguire: #modifica metodi della classe bodyguard

def init(self, armor=2):
Ant.init(self, armor)
self.contained_ant = None

def can_contain(self, other):
    # BEGIN Problem 9
     if self.contained_ant == None and other.is_container == False:
            return True
    # END Problem 9

def contain_ant(self, ant):
    # BEGIN Problem 9
    self.contained_ant = ant
    # END Problem 9

def action(self, colony):
    # BEGIN Problem 9
   if self.ant is not None:
        self.ant.place = self.place 
        self.ant.action(colony)

    # END Problem 9

Ants VS Bees

#Problem 2 if exit is not None: exit.entrance = self

Problem 5

Riga 280:
food_cost = 4 armor = 1 implemented = True
Riga 291:
if self.armor <= 0: #muore la Fire Ant
for bees in self.place.bees: #in ogni posto in cui ci sia un'ape l'armatura di quell'ape viene ridotta
bee.reduce_armor(self.damage) #del damage della Fire ant
else:
Insect.reduce_armor(self, amount) #se non muore la Fire ant allora si abbassa semplicemente la sua armatura

Problem 12

Riga 429
class ScubaThrower(ThrowerAnt): #è uguale alla ThrowerAnt se non che sopravvive in acqua
"""ScubaThrower ant can be placed in water"""
name = 'Scuba'
food_cost = 6
is_watersafe = True #può sopravvivere in acqua
implemented = True

Test

Test di username e repository effettuato

Problem 6 HungryAnt

riga 305:

implemented = True #la formica può essere utilizzata
food_cost = 4 #modifica del costo cibo
time_to_digest = 3 #tempo(turni) impiegato a digerire un'ape

Problem 11

Riga 96
is_watersafe = False #le formiche in acqua muoiono

Riga 132
is_watersafe = True #le api volano sopra l'acqua

Riga 425
Place.add_insect(self, insect) #viene aggiunto un insetto
if insect.is_watersafe is not True: #se l'insetto aggiunto non è watersafe viene ucciso
insect.reduce_armor(insect.armor)

problem #10

food_cost = 6 #costo del cibo
implemented = true #la formica può essere utilizzata
container = True

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.