diff --git a/element.go b/element.go index 033ba85..c82d997 100644 --- a/element.go +++ b/element.go @@ -17,10 +17,10 @@ func (e Element) String() string { return fmt.Sprintf("", e.IsFood, e.Health, e.Age) } -func Costruttore(razza string, evoluzione int, costomov int, costosex int, premura int) *Element { +func Costruttore(razza string, evoluzione int, costomov int, costosex int, premura int, salute int) *Element { nuovo := new(Element) nuovo.IsFood=false - nuovo.Health=100 + nuovo.Health=salute nuovo.Age=0 nuovo.Razza=razza nuovo.Evoluzione=evoluzione diff --git a/main.go b/main.go index bdd682a..3603a99 100644 --- a/main.go +++ b/main.go @@ -119,13 +119,13 @@ func muovi(h int, w int) { //FUNZIONE MUOVI: aggiorna la posizione di tutti gli } if (elemento.Health-elemento.Premura)>elemento.CostoSex { //se ha energia a sufficienza per riprodursi - Matrix[h][w] = Costruttore(elemento.Razza, elemento.Evoluzione, elemento.CostoMov, elemento.CostoSex, elemento.Premura) + Matrix[h][w] = Costruttore(elemento.Razza, elemento.Evoluzione, elemento.CostoMov, elemento.CostoSex, elemento.Premura, SaluteIniziale) } } } -func stampaMatrice2() { +/*func stampaMatrice2() { for i := 0; i < Altezza; i++ { fmt.Printf("Riga %d:\n", i) for j := 0; j < Larghezza; j++ { @@ -139,17 +139,20 @@ func stampaMatrice2() { fmt.Printf(" Colonna %d: %s\n", j, stringa) } } -} +}*/ func stampaMatrice() { for i := 0; i < Altezza; i++ { for j := 0; j < Larghezza; j++ { - if Matrix[i][j]!=nil { - fmt.Printf("0 ") + if Matrix[i][j] == nil { + fmt.Printf("-- ") } else { - fmt.Printf("1 ") + if Matrix[i][j].IsFood { + fmt.Printf("CC ") + } else { + fmt.Printf("%d ", Matrix[i][j].Health) + } } - fmt.Printf(" Colonna %d: %s\n") } fmt.Printf("\n") }