Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet IA04 - Vivarium
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zhenyang Xu
Projet IA04 - Vivarium
Commits
d2e47bf7
Commit
d2e47bf7
authored
1 year ago
by
ZhenyangXU
Browse files
Options
Downloads
Patches
Plain Diff
UML version 1.4 (m-à-j Terrain)
parent
e22e9bef
Branches
main
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
agents/animaux.go
+102
-10
102 additions, 10 deletions
agents/animaux.go
vivarium_uml.puml
+10
-4
10 additions, 4 deletions
vivarium_uml.puml
with
112 additions
and
14 deletions
agents/animaux.go
+
102
−
10
View file @
d2e47bf7
...
...
@@ -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
*
animal
1
.
E
nergie
+
0.5
*
animal1
.
Hié
rarchie
+
0.5
*
animal
1
.
Â
ge
+
0.5
*
rand
.
Float64
()
score2
:=
0.5
*
animal2
.
E
nergie
+
0.5
*
animal2
.
Hié
rarchie
+
0.5
*
animal2
.
Â
ge
+
0.5
*
rand
.
Float64
()
score1
:=
0.5
*
insecte
1
.
e
nergie
+
0.5
*
insecte1
.
hie
rarchie
+
0.5
*
insecte
1
.
a
ge
+
0.5
*
rand
.
Int
()
score2
:=
0.5
*
insecte1
.
e
nergie
+
0.5
*
insecte1
.
hie
rarchie
+
0.5
*
insecte1
.
a
ge
+
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
{
E
nergie
:
100
,
Hié
rarchie
:
3
,
Â
ge
:
5
}
animal2
:=
Animal
{
E
nergie
:
90
,
Hié
rarchie
:
2
,
Â
ge
:
3
}
insecte1
:=
Insecte
{
e
nergie
:
100
,
hie
rarchie
:
3
,
a
ge
:
5
}
insecte2
:=
Insecte
{
e
nergie
:
90
,
hie
rarchie
:
2
,
a
ge
:
3
}
result
:=
combat
(
animal1
,
animal
2
)
result
:=
combat
(
insecte1
,
insecte
2
)
fmt
.
Println
(
result
)
}
This diff is collapsed.
Click to expand it.
vivarium_uml.puml
+
10
−
4
View file @
d2e47bf7
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment