Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Game of life Template
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
BALME Maxence
Game of life Template
Commits
da01de06
Commit
da01de06
authored
Oct 23, 2023
by
Guyslain
Browse files
Options
Downloads
Patches
Plain Diff
section 8 NextGenerationInitializer non-testé
parent
eee4b96f
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/NextGenerationInitializer.java
+12
-8
12 additions, 8 deletions
src/main/java/model/NextGenerationInitializer.java
with
12 additions
and
8 deletions
src/main/java/model/NextGenerationInitializer.java
+
12
−
8
View file @
da01de06
...
...
@@ -15,7 +15,7 @@ import java.util.List;
*/
public
class
NextGenerationInitializer
<
S
extends
State
<
S
>>
implements
MatrixInitializer
<
S
>
{
//TODO: ajouter les propriétés nécessaires
private
final
CellularAutomatonSimulation
<
S
>
simulation
;
/** Create a {@link MatrixInitializer} to compute the next generation in
* a 2D cellular automaton.
...
...
@@ -23,13 +23,17 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit
* @param simulation the {@link Simulation} representing the cellular automaton.
*/
public
NextGenerationInitializer
(
CellularAutomatonSimulation
<
S
>
simulation
)
{
//TODO: à compléter
this
.
simulation
=
simulation
;
}
@Override
public
S
initialValueAt
(
Coordinate
coordinate
)
{
//TODO: à compléter
return
null
;
List
<
Coordinate
>
neighbours
=
coordinate
.
orthodiagonalNeighbours
();
List
<
S
>
states
=
new
ArrayList
<>();
for
(
Coordinate
neighbour
:
neighbours
)
{
states
.
add
(
this
.
simulation
.
at
(
wrap
(
neighbour
)).
get
());
}
return
this
.
simulation
.
at
(
coordinate
).
get
().
update
(
states
);
}
/** Computes the grid {@link Coordinate} for an arbitrary {@link Coordinate}, even outside
...
...
@@ -41,10 +45,10 @@ public class NextGenerationInitializer<S extends State<S>> implements MatrixInit
* @return a corresponding {@link Coordinate}, that is inside the grid.
*/
Coordinate
wrap
(
Coordinate
coordinate
)
{
//TODO: à complé
te
r
//Il faut recalculer les coordonnées x et y modulo les dimensions de la grille.
//Pour le modulo, utiliser la fonction ci-dessous, qui s'assure que le résultat est positif.
return
null
;
return
new
Coordina
te
(
modulo
(
coordinate
.
x
(),
this
.
simulation
.
numberOfColumns
()),
modulo
(
coordinate
.
y
(),
this
.
simulation
.
numberOfRows
())
)
;
}
/** The non-negative remainder of n divided by d.
...
...
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