Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ia04-drones
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
Alexandre Borghi
ia04-drones
Merge requests
!3
Drone yasmine
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Drone yasmine
drone-yasmine
into
main
Overview
0
Commits
2
Pipelines
0
Changes
1
Merged
Quentin Aniere
requested to merge
drone-yasmine
into
main
1 month ago
Overview
0
Commits
2
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
dfb1f010
2 commits,
1 month ago
1 file
+
109
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
simulation/objet/agent/drone.go
+
109
−
0
Options
package
agent
import
(
"log"
"math/rand"
)
type
Action
int64
const
(
Aucune
Action
=
iota
Marquer
Recharger
)
type
Coordonnees
[
2
]
float64
type
Agent
interface
{
Start
()
Percept
(
*
Environnement
)
Deliberate
()
Act
(
*
Environnement
)
ID
()
IDAgent
}
type
IDAgent
string
type
AgentDrone
struct
{
id
IDAgent
position
Coordonnees
niveauBatterie
float64
rayonMax
float64
rayonPerception
float64
env
*
Environnement
syncChan
chan
int
}
func
NouvelAgentDrone
(
id
string
,
env
*
Environnement
,
syncChan
chan
int
)
*
AgentDrone
{
return
&
AgentDrone
{
id
:
IDAgent
(
id
),
position
:
Coordonnees
{
0
,
0
},
niveauBatterie
:
100.0
,
rayonMax
:
10.0
,
rayonPerception
:
5.0
,
env
:
env
,
syncChan
:
syncChan
,
}
}
func
(
ad
*
AgentDrone
)
ID
()
IDAgent
{
return
ad
.
id
}
func
(
ad
*
AgentDrone
)
Demarrer
()
{
log
.
Printf
(
"%s démarre...
\n
"
,
ad
.
id
)
go
func
()
{
env
:=
ad
.
env
var
etape
int
for
{
etape
=
<-
ad
.
syncChan
ad
.
Percept
(
env
)
ad
.
Deliberate
()
ad
.
Act
(
env
)
ad
.
syncChan
<-
etape
}
}()
}
func
(
ad
*
AgentDrone
)
Percept
(
env
*
Environnement
)
{
ad
.
rayonPerception
=
env
.
ObtenirRayonPerception
()
}
func
(
ad
*
AgentDrone
)
Deliberate
()
{
if
ad
.
niveauBatterie
<
20.0
{
ad
.
decision
=
Recharger
}
else
{
ad
.
decision
=
Marquer
}
// Si le drone est chargé et qu'il est déjà intégré à un réseau de drones il ne fait rien ?
}
func
(
ad
*
AgentDrone
)
Act
(
env
*
Environnement
)
{
switch
ad
.
decision
{
case
Aucune
:
env
.
Faire
(
Aucune
,
Coordonnees
{})
case
Recharger
:
station
:=
env
.
TrouverStationRecharge
(
ad
.
position
)
if
station
!=
nil
{
ad
.
position
=
*
station
ad
.
niveauBatterie
=
100.0
log
.
Printf
(
"%s recharge à %v
\n
"
,
ad
.
id
,
ad
.
position
)
}
else
{
log
.
Printf
(
"%s attend une recharge...
\n
"
,
ad
.
id
)
ad
.
position
=
Coordonnees
{
0
,
0
}
//Attendre plutot à coté d'une zone de recharge
// Ajouter le fait que le drone attends puis cherche à nouveau une station de recherche tant qu'il n'en a pas trouvé
}
case
Marquer
:
drones
:=
env
.
ObtenirDronesProches
(
ad
.
position
,
ad
.
rayonMax
)
if
len
(
drones
)
>
0
{
ad
.
position
=
drones
[
0
]
.
position
log
.
Printf
(
"%s rejoint un autre drone à %v
\n
"
,
ad
.
id
,
ad
.
position
)
}
else
{
log
.
Printf
(
"%s reste à la position actuelle: %v
\n
"
,
ad
.
id
,
ad
.
position
)
}
}
}
\ No newline at end of file
Loading