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
b40b3c19
Commit
b40b3c19
authored
5 months ago
by
ousseyn01
Browse files
Options
Downloads
Patches
Plain Diff
Modification of Cloud because it not works correctly
We change methods and implements other methods
parent
cb4d18d9
Branches
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
src/main/java/model/Cloud.java
+18
-19
18 additions, 19 deletions
src/main/java/model/Cloud.java
src/main/java/model/FirefighterBoard.java
+3
-2
3 additions, 2 deletions
src/main/java/model/FirefighterBoard.java
with
21 additions
and
21 deletions
src/main/java/model/Cloud.java
+
18
−
19
View file @
b40b3c19
...
...
@@ -3,7 +3,6 @@ package model;
import
util.Position
;
import
java.util.*
;
import
java.util.Map
;
public
class
Cloud
{
private
Position
position
;
...
...
@@ -15,32 +14,32 @@ public class Cloud {
this
.
neighbors
=
neighbors
;
}
public
void
moveAndExtinguishFire
(
Fire
fire
)
{
Position
newPosition
=
moveToNewPosition
();
this
.
position
=
newPosition
;
// 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
();
extinguishNeighboringFires
(
fire
);
}
if
(!
validNeighbors
.
isEmpty
())
{
this
.
position
=
validNeighbors
.
get
(
randomGenerator
.
nextInt
(
validNeighbors
.
size
()));
}
private
Position
moveToNewPosition
()
{
List
<
Position
>
neighborsList
=
neighbors
.
get
(
position
);
return
neighborsList
.
get
((
int
)
(
Math
.
random
()
*
neighborsList
.
size
()));
// Éteindre les feux après déplacement
extinguishFires
(
fire
);
}
private
void
extinguishNeighboringFires
(
Fire
fire
)
{
List
<
Position
>
neighboringPositions
=
neighbors
.
get
(
position
);
for
(
Position
neighbor
:
neighboringPositions
)
{
if
(
fire
.
getFirePositions
().
contains
(
neighbor
))
{
fire
.
extinguishFire
(
neighbor
);
}
// É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
for
(
Position
neighbor
:
neighbors
.
get
(
position
))
{
fire
.
extinguishFire
(
neighbor
);
}
}
public
Position
getPosition
()
{
return
position
;
}
public
void
extinguishFireCloud
(
Fire
fire
)
{
fire
.
getFirePositions
().
remove
(
position
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/model/FirefighterBoard.java
+
3
−
2
View file @
b40b3c19
...
...
@@ -125,8 +125,9 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
}
// Déplacer les nuages et éteindre les feux
for
(
Cloud
cloud
:
clouds
)
{
cloud
.
moveAndExtinguishFire
(
fire
);
cloud
.
extinguishFireCloud
(
fire
);
//cloud.moveAndExtinguishFire(fire);
//cloud.extinguishFireCloud(fire);
cloud
.
move
(
fire
,
getMountainPositions
());
}
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