Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FirefighterStarter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
NDIAYE Ousseynou
FirefighterStarter
Commits
01c34783
Commit
01c34783
authored
5 months ago
by
ousseyn01
Browse files
Options
Downloads
Patches
Plain Diff
Modification of Cloud because fire could delete Cloud
parent
b40b3c19
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/model/Cloud.java
+11
-16
11 additions, 16 deletions
src/main/java/model/Cloud.java
src/main/java/model/FirefighterBoard.java
+3
-1
3 additions, 1 deletion
src/main/java/model/FirefighterBoard.java
with
14 additions
and
17 deletions
src/main/java/model/Cloud.java
+
11
−
16
View file @
01c34783
...
...
@@ -14,32 +14,27 @@ public class Cloud {
this
.
neighbors
=
neighbors
;
}
// Déplacement du nuage d'une case aléatoire parmi ses voisins
public
void
move
(
Fire
fire
,
Set
<
Position
>
mountains
)
{
List
<
Position
>
validNeighbors
=
neighbors
.
get
(
position
).
stream
()
.
filter
(
neighbor
->
!
mountains
.
contains
(
neighbor
))
// Exclure les montagnes
.
toList
();
// Déplacement aléatoire du nuage
public
void
move
()
{
List
<
Position
>
validNeighbors
=
neighbors
.
get
(
position
);
if
(!
validNeighbors
.
isEmpty
())
{
this
.
position
=
validNeighbors
.
get
(
randomGenerator
.
nextInt
(
validNeighbors
.
size
()));
}
// Éteindre les feux après déplacement
extinguishFires
(
fire
);
}
// Éteint les feux sur la position du nuage et ses voisins
private
void
extinguishFires
(
Fire
fire
)
{
// Éteindre le feu à la position actuelle
fire
.
extinguishFire
(
position
);
// Éteindre les feux voisins
// Éteindre les feux dans les cases adjacentes
public
void
extinguishSurroundingFires
(
Fire
fire
)
{
for
(
Position
neighbor
:
neighbors
.
get
(
position
))
{
fire
.
extinguishFire
(
neighbor
);
fire
.
extinguishFire
(
neighbor
);
// Éteint les feux adjacents
}
}
public
Position
getPosition
()
{
return
position
;
}
// Les nuages ne peuvent pas être supprimés par le feu
public
void
protectFromFire
(
Fire
fire
)
{
fire
.
getFirePositions
().
remove
(
position
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/model/FirefighterBoard.java
+
3
−
1
View file @
01c34783
...
...
@@ -127,7 +127,9 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
for
(
Cloud
cloud
:
clouds
)
{
//cloud.moveAndExtinguishFire(fire);
//cloud.extinguishFireCloud(fire);
cloud
.
move
(
fire
,
getMountainPositions
());
cloud
.
move
();
cloud
.
protectFromFire
(
fire
);
cloud
.
extinguishSurroundingFires
(
fire
);
}
step
++;
...
...
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