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
6 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
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
+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;
...
@@ -3,7 +3,6 @@ package model;
import
util.Position
;
import
util.Position
;
import
java.util.*
;
import
java.util.*
;
import
java.util.Map
;
public
class
Cloud
{
public
class
Cloud
{
private
Position
position
;
private
Position
position
;
...
@@ -15,32 +14,32 @@ public class Cloud {
...
@@ -15,32 +14,32 @@ public class Cloud {
this
.
neighbors
=
neighbors
;
this
.
neighbors
=
neighbors
;
}
}
public
void
moveAndExtinguishFire
(
Fire
fire
)
{
// Déplacement du nuage d'une case aléatoire parmi ses voisins
Position
newPosition
=
moveToNewPosition
();
public
void
move
(
Fire
fire
,
Set
<
Position
>
mountains
)
{
this
.
position
=
newPosition
;
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
()
{
// Éteindre les feux après déplacement
List
<
Position
>
neighborsList
=
neighbors
.
get
(
position
);
extinguishFires
(
fire
);
return
neighborsList
.
get
((
int
)
(
Math
.
random
()
*
neighborsList
.
size
()));
}
}
private
void
extinguishNeighboringFires
(
Fire
fire
)
{
// Éteint les feux sur la position du nuage et ses voisins
List
<
Position
>
neighboringPositions
=
neighbors
.
get
(
position
);
private
void
extinguishFires
(
Fire
fire
)
{
for
(
Position
neighbor
:
neighboringPositions
)
{
// Éteindre le feu à la position actuelle
if
(
fire
.
getFirePositions
().
contains
(
neighbor
))
{
fire
.
extinguishFire
(
position
);
// Éteindre les feux voisins
for
(
Position
neighbor
:
neighbors
.
get
(
position
))
{
fire
.
extinguishFire
(
neighbor
);
fire
.
extinguishFire
(
neighbor
);
}
}
}
}
}
public
Position
getPosition
()
{
public
Position
getPosition
()
{
return
position
;
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>> {
...
@@ -125,8 +125,9 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
}
}
// Déplacer les nuages et éteindre les feux
// Déplacer les nuages et éteindre les feux
for
(
Cloud
cloud
:
clouds
)
{
for
(
Cloud
cloud
:
clouds
)
{
cloud
.
moveAndExtinguishFire
(
fire
);
//cloud.moveAndExtinguishFire(fire);
cloud
.
extinguishFireCloud
(
fire
);
//cloud.extinguishFireCloud(fire);
cloud
.
move
(
fire
,
getMountainPositions
());
}
}
step
++;
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