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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NDIAYE Ousseynou
FirefighterStarter
Commits
ddc52714
Commit
ddc52714
authored
7 months ago
by
ousseyn01
Browse files
Options
Downloads
Patches
Plain Diff
Modify FirefighterBoard for Cloud fonctionnallity
parent
ce4d0dbc
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/model/FirefighterBoard.java
+23
-1
23 additions, 1 deletion
src/main/java/model/FirefighterBoard.java
with
23 additions
and
1 deletion
src/main/java/model/FirefighterBoard.java
+
23
−
1
View file @
ddc52714
...
...
@@ -9,15 +9,17 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
private
final
int
rowCount
;
private
final
int
initialFireCount
;
private
final
int
initialFirefighterCount
;
private
final
int
initialCloudCount
;
private
final
model
.
TargetStrategy
targetStrategy
=
new
model
.
TargetStrategy
();
private
List
<
Firefighter
>
firefighters
;
private
Fire
fire
;
private
final
Map
<
Position
,
List
<
Position
>>
neighbors
=
new
HashMap
<>();
private
List
<
Cloud
>
clouds
;
private
final
Position
[][]
positions
;
private
int
step
=
0
;
private
final
Random
randomGenerator
=
new
Random
();
public
FirefighterBoard
(
int
columnCount
,
int
rowCount
,
int
initialFireCount
,
int
initialFirefighterCount
)
{
public
FirefighterBoard
(
int
columnCount
,
int
rowCount
,
int
initialFireCount
,
int
initialFirefighterCount
,
int
initialCloudCount
)
{
this
.
columnCount
=
columnCount
;
this
.
rowCount
=
rowCount
;
this
.
positions
=
new
Position
[
rowCount
][
columnCount
];
...
...
@@ -35,17 +37,25 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
}
this
.
initialFireCount
=
initialFireCount
;
this
.
initialFirefighterCount
=
initialFirefighterCount
;
this
.
initialCloudCount
=
initialCloudCount
;
initializeElements
();
}
public
void
initializeElements
()
{
firefighters
=
new
ArrayList
<>();
clouds
=
new
ArrayList
<>();
Set
<
Position
>
firePositions
=
new
HashSet
<>();
for
(
int
index
=
0
;
index
<
initialCloudCount
;
index
++)
{
clouds
.
add
(
new
Cloud
(
randomPosition
(),
neighbors
));
}
for
(
int
index
=
0
;
index
<
initialFireCount
;
index
++)
firePositions
.
add
(
randomPosition
());
fire
=
new
Fire
(
firePositions
,
neighbors
);
for
(
int
index
=
0
;
index
<
initialFirefighterCount
;
index
++)
firefighters
.
add
(
new
Firefighter
(
randomPosition
()));
for
(
int
index
=
0
;
index
<
initialCloudCount
;
index
++)
{
clouds
.
add
(
new
Cloud
(
randomPosition
(),
neighbors
));
}
}
private
Position
randomPosition
()
{
...
...
@@ -58,6 +68,11 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
for
(
Firefighter
firefighter
:
firefighters
)
if
(
firefighter
.
getPosition
().
equals
(
position
))
result
.
add
(
ModelElement
.
FIREFIGHTER
);
for
(
Cloud
cloud
:
clouds
)
{
if
(
cloud
.
getPosition
().
equals
(
position
))
{
result
.
add
(
ModelElement
.
CLOUD
);
}
}
if
(
fire
.
getFirePositions
().
contains
(
position
))
result
.
add
(
ModelElement
.
FIRE
);
return
result
;
...
...
@@ -78,6 +93,11 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
if
(
step
%
2
==
0
){
modifiedPositions
.
addAll
(
fire
.
spreadFire
());
}
// Déplacer les nuages et éteindre les feux
for
(
Cloud
cloud
:
clouds
)
{
cloud
.
moveRandomly
();
cloud
.
extinguishFire
(
fire
);
}
step
++;
return
modifiedPositions
;
...
...
@@ -128,6 +148,8 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
switch
(
element
)
{
case
FIRE
->
fire
.
getFirePositions
().
add
(
position
);
case
FIREFIGHTER
->
firefighters
.
add
(
new
Firefighter
(
position
));
case
CLOUD
->
clouds
.
add
(
new
Cloud
(
position
,
neighbors
));
}
}
}
...
...
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