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
BELHACHEMI Mehdi
FirefighterStarter
Commits
24dffc76
Commit
24dffc76
authored
7 months ago
by
BELHACHEMI Mehdi
Browse files
Options
Downloads
Patches
Plain Diff
mmehdi : finished FirefighterBoard.java
parent
588fdea1
No related branches found
No related tags found
No related merge requests found
Pipeline
#38189
failed
7 months ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/model/FirefighterBoard.java
+10
-6
10 additions, 6 deletions
src/main/java/model/FirefighterBoard.java
src/main/java/util/TargetStrategy.java
+1
-1
1 addition, 1 deletion
src/main/java/util/TargetStrategy.java
with
11 additions
and
7 deletions
src/main/java/model/FirefighterBoard.java
+
10
−
6
View file @
24dffc76
...
@@ -115,14 +115,18 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
...
@@ -115,14 +115,18 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
private
List
<
Position
>
updateFirefighters
()
{
private
List
<
Position
>
updateFirefighters
()
{
List
<
Position
>
modifiedPosition
=
new
ArrayList
<>();
List
<
Position
>
modifiedPosition
=
new
ArrayList
<>();
List
<
Position
>
firefighterNewPositions
=
new
ArrayList
<>();
List
<
FireFighter
>
firefighters
=
new
ArrayList
<>();
for
(
FireFighter
firefighterPosition
:
firefighter
)
{
List
<
Position
>
firePositions
=
new
ArrayList
<>();
for
(
Fire
fire:
fire
){
firePositions
.
add
(
fire
.
getFirePosition
());
}
for
(
FireFighter
firefighter:
firefighter
)
{
Position
newFirefighterPosition
=
Position
newFirefighterPosition
=
targetStrategy
.
neighborClosestToFire
(
firefighterPosition
,
targetStrategy
.
neighborClosestToFire
(
firefighter
.
getFireFighter
Position
()
,
firePositions
,
neighbors
);
firePositions
,
neighbors
);
firefighter
NewPosition
s
.
add
(
newF
irefighter
Position
);
firefighters
.
add
(
f
irefighter
);
extinguish
(
newFirefighterPosition
);
extinguish
(
newFirefighterPosition
);
modifiedPosition
.
add
(
firefighter
Position
.
getFireFighterPosition
());
modifiedPosition
.
add
(
firefighter
.
getFireFighterPosition
());
modifiedPosition
.
add
(
newFirefighterPosition
);
modifiedPosition
.
add
(
newFirefighterPosition
);
List
<
Position
>
neighborFirePositions
=
neighbors
.
get
(
newFirefighterPosition
).
stream
()
List
<
Position
>
neighborFirePositions
=
neighbors
.
get
(
newFirefighterPosition
).
stream
()
.
filter
(
firePositions:
:
contains
).
toList
();
.
filter
(
firePositions:
:
contains
).
toList
();
...
@@ -130,7 +134,7 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
...
@@ -130,7 +134,7 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
extinguish
(
firePosition
);
extinguish
(
firePosition
);
modifiedPosition
.
addAll
(
neighborFirePositions
);
modifiedPosition
.
addAll
(
neighborFirePositions
);
}
}
firefighter
Positions
=
firefighter
NewPosition
s
;
firefighter
=
firefighters
;
return
modifiedPosition
;
return
modifiedPosition
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/util/TargetStrategy.java
+
1
−
1
View file @
24dffc76
...
@@ -12,7 +12,7 @@ public class TargetStrategy {
...
@@ -12,7 +12,7 @@ public class TargetStrategy {
* @param targets positions that are targeted.
* @param targets positions that are targeted.
* @return the position next to the current position that is on the path to the closest target.
* @return the position next to the current position that is on the path to the closest target.
*/
*/
Position
neighborClosestToFire
(
Position
position
,
Collection
<
Position
>
targets
,
public
Position
neighborClosestToFire
(
Position
position
,
Collection
<
Position
>
targets
,
Map
<
Position
,
List
<
Position
>>
neighbors
)
{
Map
<
Position
,
List
<
Position
>>
neighbors
)
{
Set
<
Position
>
seen
=
new
HashSet
<
Position
>();
Set
<
Position
>
seen
=
new
HashSet
<
Position
>();
HashMap
<
Position
,
Position
>
firstMove
=
new
HashMap
<
Position
,
Position
>();
HashMap
<
Position
,
Position
>
firstMove
=
new
HashMap
<
Position
,
Position
>();
...
...
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