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
OUALAN Yanis
FirefighterStarter
Commits
dca57913
Commit
dca57913
authored
7 months ago
by
melizzzz
Browse files
Options
Downloads
Patches
Plain Diff
Cloud (petits soucis)
parent
e545624c
No related branches found
No related tags found
No related merge requests found
Pipeline
#39629
passed
7 months ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/java/app/SimulatorApplication.java
+2
-2
2 additions, 2 deletions
src/main/java/app/SimulatorApplication.java
src/main/java/model/Cloud.java
+9
-4
9 additions, 4 deletions
src/main/java/model/Cloud.java
src/main/java/model/Fire.java
+1
-1
1 addition, 1 deletion
src/main/java/model/Fire.java
with
12 additions
and
7 deletions
src/main/java/app/SimulatorApplication.java
+
2
−
2
View file @
dca57913
...
...
@@ -13,8 +13,8 @@ import javafx.stage.Stage;
public
class
SimulatorApplication
extends
javafx
.
application
.
Application
{
private
static
final
String
VIEW_RESOURCE_PATH
=
"/view/view.fxml"
;
private
static
final
String
APP_NAME
=
"Firefighter simulator"
;
private
static
final
int
ROW_COUNT
=
2
0
;
private
static
final
int
COLUMN_COUNT
=
2
0
;
private
static
final
int
ROW_COUNT
=
2
2
;
private
static
final
int
COLUMN_COUNT
=
2
2
;
private
static
final
int
BOX_WIDTH
=
25
;
private
static
final
int
BOX_HEIGHT
=
25
;
public
static
final
int
INITIAL_FIRE_COUNT
=
3
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/model/Cloud.java
+
9
−
4
View file @
dca57913
...
...
@@ -31,22 +31,27 @@ public class Cloud implements Entity{
@Override
public
List
<
Position
>
nextTurn
(
Board
<
Square
>
b
)
{
List
<
Position
>
adjacentPositions
=
PositionUtil
.
generateAdjacentPositions
(
position
,
b
);
Position
next_position
=
adjacentPositions
.
get
(
new
Random
().
nextInt
(
adjacentPositions
.
size
()));
// Filtrer pour obtenir uniquement les positions qui ne contiennent pas de pompier
adjacentPositions
.
removeIf
(
p
->
b
.
doesSquareContainEntity
(
p
,
FireFighter
.
class
));
// Choisir une position aléatoire parmi les mouvements possibles
Position
next_position
=
adjacentPositions
.
get
(
new
Random
().
nextInt
(
adjacentPositions
.
size
()));
// Si la nouvelle position contient un feu, éteindre le feu
if
(
b
.
getStates
(
next_position
).
getEntities
().
stream
().
anyMatch
(
element
->
element
instanceof
Fire
)
){
extinguish
(
next_position
,
b
);
}
Position
old_position
=
this
.
position
;
this
.
position
=
next_position
;
b
.
addEntityAtSquare
(
this
,
position
);
b
.
addEntityAtSquare
(
this
,
next_
position
);
b
.
clearCaseFrom
(
this
,
old_position
);
return
List
.
of
(
old_position
,
this
.
position
);
}
private
Position
extinguish
(
Position
p
,
Board
<
Square
>
b
)
{
b
.
getStates
(
p
).
getEntities
().
removeIf
(
element
->
element
instanceof
Fire
);
List
<
Entity
>
entities
=
b
.
getStates
(
p
).
getEntities
();
...
...
This diff is collapsed.
Click to expand it.
src/main/java/model/Fire.java
+
1
−
1
View file @
dca57913
...
...
@@ -32,7 +32,7 @@ public class Fire implements Entity {
return
new
ArrayList
<
Position
>();
List
<
Position
>
positions
=
PositionUtil
.
generateAdjacentPositions
(
position
,
board
);
for
(
Position
p
:
positions
)
{
if
(
b
.
getStates
(
p
).
isEmpty
())
{
if
(
b
.
getStates
(
p
).
isEmpty
()
&&
!
b
.
getStates
(
p
).
getEntities
().
contains
(
Cloud
.
class
)
)
{
if
(
b
.
getStates
(
p
).
getMaxAge
()
<
b
.
getStepNumber
()
&&
PositionUtil
.
getManhattanDistance
(
position
,
p
)
==
1
)
{
board
.
addEntityAtSquare
(
new
Fire
(
p
,
board
),
p
);
...
...
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