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
CHERCHEM Sarah
FirefighterStarter
Commits
8e3df2a2
Commit
8e3df2a2
authored
7 months ago
by
Sarah CHERCHEM
Browse files
Options
Downloads
Patches
Plain Diff
Create the class MotorizedStrategy
parent
4e463e33
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#40178
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/util/MotorizedStrategy.java
+22
-0
22 additions, 0 deletions
src/main/java/util/MotorizedStrategy.java
src/main/java/util/TargetStrategy.java
+2
-2
2 additions, 2 deletions
src/main/java/util/TargetStrategy.java
with
24 additions
and
2 deletions
src/main/java/util/MotorizedStrategy.java
0 → 100644
+
22
−
0
View file @
8e3df2a2
package
util
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
public
class
MotorizedStrategy
implements
Strategy
{
@Override
public
Position
neighborClosestToTarget
(
Position
position
,
Collection
<
Position
>
targets
,
Map
<
Position
,
List
<
Position
>>
neighbors
)
{
TargetStrategy
normalStrategy
=
new
TargetStrategy
();
Position
firstMove
=
normalStrategy
.
neighborClosestToTarget
(
position
,
targets
,
neighbors
);
// Si un premier mouvement est trouvé, on simule un second déplacement
if
(
firstMove
!=
null
&&
neighbors
.
containsKey
(
firstMove
))
{
return
normalStrategy
.
neighborClosestToTarget
(
firstMove
,
targets
,
neighbors
);
}
return
position
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/util/TargetStrategy.java
+
2
−
2
View file @
8e3df2a2
...
...
@@ -4,7 +4,7 @@ import util.Position;
import
java.util.*
;
public
class
TargetStrategy
{
public
class
TargetStrategy
implements
Strategy
{
/**
...
...
@@ -12,7 +12,7 @@ public class TargetStrategy {
* @param targets positions that are targeted.
* @return the position next to the current position that is on the path to the closest target.
*/
public
Position
neighborClosestTo
Fire
(
Position
position
,
Collection
<
Position
>
targets
,
public
Position
neighborClosestTo
Target
(
Position
position
,
Collection
<
Position
>
targets
,
Map
<
Position
,
List
<
Position
>>
neighbors
)
{
Set
<
Position
>
seen
=
new
HashSet
<
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