Skip to content
Snippets Groups Projects
Commit d2e47bf7 authored by ZhenyangXU's avatar ZhenyangXU
Browse files

UML version 1.4 (m-à-j Terrain)

parent e22e9bef
Branches main
No related tags found
No related merge requests found
......@@ -7,17 +7,109 @@ import (
"time"
)
type Animal struct {
Energie float64
Hiérarchie float64
Âge float64
// Enums
type Sexe int
const (
Male Sexe = iota
Femelle
)
type Nourriture int
const (
PetiteHerbe Nourriture = iota
GrandeHerbe
Champignon
// autres types...
)
type ModeReproduction int
const (
Graines ModeReproduction = iota
Spores
// autres modes...
)
type Meteo int
const (
Pluie Meteo = iota
Brouillard
SaisonSeche
Incendie
Tonnerre
// autres conditions météorologiques...
)
// Organisme
//type Organisme struct {
// nom string
// age int
// positionX int
// positionY int
// rayon int
//}
// Insecte
type Insecte struct {
nom string
age int
positionX int
positionY int
rayon int
sexe Sexe
vitesse int
sourceNourriture Nourriture
energie int
capaciteReproduction int
niveauFaim int
periodReproduire float64
envieReproduire bool
listePourManger_Insecte []*Insecte
listePourManger_Plante []*Plante
hierarchie int
}
// Plante
type Plante struct {
nom string
age int
positionX int
positionY int
rayon int
vitesseDeCroissance int
etatSante int
modeReproduction ModeReproduction
adaptabilite int
}
// Climat
type Climat struct {
luminaire int
temperature int
humidite float64
co2 float64
o2 float64
}
// Environment
type Environment struct {
climat *Climat
qualiteSol int
width int
height int
nbPierre int
organismes_insecte []*Insecte
organismes_plante []*Plante
}
func combat(animal1, animal2 Animal) string {
func combat(insecte1, insecte2 Insecte) string {
rand.Seed(time.Now().UnixNano())
score1 := 0.5*animal1.Energie + 0.5*animal1.Hiérarchie + 0.5*animal1.Âge + 0.5*rand.Float64()
score2 := 0.5*animal2.Energie + 0.5*animal2.Hiérarchie + 0.5*animal2.Âge + 0.5*rand.Float64()
score1 := 0.5*insecte1.energie + 0.5*insecte1.hierarchie + 0.5*insecte1.age + 0.5*rand.Int()
score2 := 0.5*insecte1.energie + 0.5*insecte1.hierarchie + 0.5*insecte1.age + 0.5*rand.Int()
if score1 > score2 {
return "Le premier animal a gagné le combat!"
......@@ -28,9 +120,9 @@ func combat(animal1, animal2 Animal) string {
}
func main() {
animal1 := Animal{Energie: 100, Hiérarchie: 3, Âge: 5}
animal2 := Animal{Energie: 90, Hiérarchie: 2, Âge: 3}
insecte1 := Insecte{energie: 100, hierarchie: 3, age: 5}
insecte2 := Insecte{energie: 90, hierarchie: 2, age: 3}
result := combat(animal1, animal2)
result := combat(insecte1, insecte2)
fmt.Println(result)
}
......@@ -12,6 +12,7 @@ abstract class Organisme {
}
class Insecte extends Organisme {
- organismeID: Int
- sexe: Sexe
- vitesse: Int
- sourceNourriture: Nourriture
......@@ -93,10 +94,15 @@ enum Meteo {
// autres conditions météorologiques...
}
Insecte "1" -- "n" Plante : mange
Plante "1" -- "n" Insecte : nourrit / abrite
Dieu o- "n" Organisme : contrôle
class Terrain {
position_organisme: [][]:liste(organismeId)
}
Insecte "1" -- "*" Plante : mange
Plante "1" -- "*" Insecte : nourrit / abrite
Dieu o- "*" Organisme : contrôle
Environment o- Climat : contient
Environment o-- "n" Organisme : contient
Environment o-- "*" Organisme : contient
Terrain o-- "0..*" Organisme
@enduml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment