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
9951d2c0
Commit
9951d2c0
authored
2 years ago
by
LABOUREL Arnaud
Browse files
Options
Downloads
Patches
Plain Diff
added gitignore
parent
184c51a2
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+3
-0
3 additions, 0 deletions
.gitignore
src/main/java/App.java
+5
-10
5 additions, 10 deletions
src/main/java/App.java
src/main/java/Grid.java
+8
-9
8 additions, 9 deletions
src/main/java/Grid.java
src/main/java/Model.java
+96
-96
96 additions, 96 deletions
src/main/java/Model.java
with
112 additions
and
115 deletions
.gitignore
0 → 100644
+
3
−
0
View file @
9951d2c0
/.gradle/
/build/
/.idea/
This diff is collapsed.
Click to expand it.
src/main/java/App.java
+
5
−
10
View file @
9951d2c0
...
@@ -9,8 +9,6 @@ import javafx.stage.Stage;
...
@@ -9,8 +9,6 @@ import javafx.stage.Stage;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
static
java
.
lang
.
Thread
.
sleep
;
public
class
App
extends
Application
{
public
class
App
extends
Application
{
...
@@ -21,7 +19,7 @@ public class App extends Application {
...
@@ -21,7 +19,7 @@ public class App extends Application {
}
}
@Override
@Override
public
void
start
(
Stage
primaryStage
)
throws
InterruptedException
{
public
void
start
(
Stage
primaryStage
)
{
Group
root
=
new
Group
();
Group
root
=
new
Group
();
Button
restart
=
new
Button
(
"Restart"
);
Button
restart
=
new
Button
(
"Restart"
);
Button
switchPause
=
new
Button
(
"Pause"
);
Button
switchPause
=
new
Button
(
"Pause"
);
...
@@ -41,14 +39,11 @@ public class App extends Application {
...
@@ -41,14 +39,11 @@ public class App extends Application {
grid
.
repaint
();
grid
.
repaint
();
ScheduledThreadPoolExecutor
threadPoolExecutor
=
new
ScheduledThreadPoolExecutor
(
1
);
ScheduledThreadPoolExecutor
threadPoolExecutor
=
new
ScheduledThreadPoolExecutor
(
1
);
threadPoolExecutor
.
scheduleWithFixedDelay
(
new
Runnable
()
{
threadPoolExecutor
.
scheduleAtFixedRate
(()
->
{
@Override
public
void
run
()
{
if
(!
isInPause
)
{
if
(!
isInPause
)
{
grid
.
model
.
activation
();
grid
.
model
.
activation
();
grid
.
repaint
();
grid
.
repaint
();
}
}
}
},
0
,
50
,
TimeUnit
.
MILLISECONDS
);
},
0
,
50
,
TimeUnit
.
MILLISECONDS
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/Grid.java
+
8
−
9
View file @
9951d2c0
import
javafx.scene.canvas.Canvas
;
import
javafx.scene.canvas.Canvas
;
import
javafx.scene.canvas.GraphicsContext
;
import
javafx.scene.input.MouseEvent
;
import
javafx.scene.input.MouseEvent
;
import
javafx.scene.paint.Color
;
import
javafx.scene.paint.Color
;
public
class
Grid
extends
Canvas
{
public
class
Grid
extends
Canvas
{
int
width
,
height
,
colCount
,
rowCount
;
double
width
;
double
height
;
double
colCount
;
double
rowCount
;
Model
model
;
Model
model
;
...
@@ -29,9 +31,6 @@ public class Grid extends Canvas{
...
@@ -29,9 +31,6 @@ public class Grid extends Canvas{
private
void
mousePressed
(
MouseEvent
mouseEvent
)
{
private
void
mousePressed
(
MouseEvent
mouseEvent
)
{
model
.
activation
();
model
.
activation
();
repaint
();
repaint
();
/*double x = mouseEvent.getX();
double y = mouseEvent.getY();
model.click((int)x*rowCount/height,(int)y*colCount/width);*/
}
}
void
repaint
(){
void
repaint
(){
...
@@ -49,7 +48,7 @@ public class Grid extends Canvas{
...
@@ -49,7 +48,7 @@ public class Grid extends Canvas{
public
void
paintFF
(
int
row
,
int
col
)
{
public
void
paintFF
(
int
row
,
int
col
)
{
getGraphicsContext2D
().
setFill
(
Color
.
BLUE
);
getGraphicsContext2D
().
setFill
(
Color
.
BLUE
);
getGraphicsContext2D
().
fill
Rect
(
row
*
height
/
rowCount
,
col
*
width
/
colCount
,
height
/
rowCount
,
width
/
colCount
);
getGraphicsContext2D
().
fill
Oval
(
row
*
height
/
rowCount
,
col
*
width
/
colCount
,
height
/
rowCount
,
width
/
colCount
);
}
}
public
void
paintFire
(
int
row
,
int
col
)
{
public
void
paintFire
(
int
row
,
int
col
)
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/Model.java
+
96
−
96
View file @
9951d2c0
...
@@ -3,7 +3,8 @@ import java.util.*;
...
@@ -3,7 +3,8 @@ import java.util.*;
public
class
Model
{
public
class
Model
{
Grid
grid
;
Grid
grid
;
int
colCount
,
rowCount
;
double
colCount
;
double
rowCount
;
List
<
Position
>
firefighters
=
new
ArrayList
<>();
List
<
Position
>
firefighters
=
new
ArrayList
<>();
Set
<
Position
>
fires
=
new
HashSet
<>();
Set
<
Position
>
fires
=
new
HashSet
<>();
List
<
Position
>
ffNewPositions
;
List
<
Position
>
ffNewPositions
;
...
@@ -44,8 +45,8 @@ public class Model {
...
@@ -44,8 +45,8 @@ public class Model {
}
}
for
(
Position
newFire
:
newFires
)
for
(
Position
newFire
:
newFires
)
grid
.
paintFire
(
newFire
.
row
,
newFire
.
col
);
grid
.
paintFire
(
newFire
.
row
,
newFire
.
col
);
fires
.
addAll
(
newFires
);
fires
.
addAll
(
newFires
);
}
}
step
++;
step
++;
}
}
...
@@ -55,10 +56,8 @@ public class Model {
...
@@ -55,10 +56,8 @@ public class Model {
}
}
private
Position
activateFirefighter
(
Position
position
)
{
private
Position
activateFirefighter
(
Position
position
)
{
Position
randomPosition
=
aStepTowardFire
(
position
);
Position
randomPosition
=
aStepTowardFire
(
position
);
//next(position).get((int) (Math.random()*next(position).size()));
List
<
Position
>
nextFires
=
next
(
randomPosition
).
stream
().
filter
(
fires:
:
contains
).
toList
();
List
<
Position
>
nextFires
=
next
(
randomPosition
).
stream
().
filter
(
fires:
:
contains
).
toList
();
extinguish
(
randomPosition
);
extinguish
(
randomPosition
);
for
(
Position
fire
:
nextFires
)
for
(
Position
fire
:
nextFires
)
...
@@ -101,5 +100,6 @@ public class Model {
...
@@ -101,5 +100,6 @@ public class Model {
return
position
;
return
position
;
}
}
public
record
Position
(
int
row
,
int
col
){}
public
record
Position
(
int
row
,
int
col
)
{
}
}
}
\ No newline at end of file
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