-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from maslankam/dev
Dev
- Loading branch information
Showing
45 changed files
with
1,229 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using System; | ||
|
||
namespace Model{ | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.Text; | ||
using Model.Transition; | ||
|
||
namespace Model | ||
{ | ||
public class CurvatureExecutor : ISimulationExecutor | ||
{ | ||
public string Name | ||
{ | ||
get { return ToString(); } | ||
set { } | ||
} | ||
|
||
|
||
public int Step { get; private set; } | ||
|
||
public CurvatureExecutor() | ||
{ | ||
} | ||
|
||
public CurvatureExecutor(int step) | ||
{ | ||
if (step < 0) throw new ArgumentException(); | ||
Step = step; | ||
} | ||
|
||
public int ReturnStep() | ||
{ | ||
return Step; | ||
} | ||
|
||
public void NextState(CelluralSpace space, CelluralSpace lastSpace, ITransitionRule transition, INeighbourhood neighbourhood) | ||
{ | ||
for (int i = 0; i < space.GetXLength(); i++) | ||
{ | ||
for (int j = 0; j < space.GetYLength(); j++) | ||
{ | ||
// TODO: refactor, injected arguments are not used !! | ||
IBoundaryCondition boun = new AbsorbingBoundary(); | ||
INeighbourhood nei = new MooreNeighbourhood(new AbsorbingBoundary()); | ||
ITransitionRule rule = new RuleOne(); | ||
Cell[] neighbours = nei.GetNeighbours(lastSpace, i, j); | ||
var element = rule.NextState(space.GetCell(i, j), neighbours); | ||
|
||
if (element != null) | ||
{ | ||
space.SetCellMembership(element, i, j); | ||
continue; | ||
} | ||
|
||
nei = new VonNeumanNeighbourhood(new AbsorbingBoundary()); | ||
rule = new RuleTwo(); | ||
neighbours = nei.GetNeighbours(lastSpace, i, j); | ||
element = rule.NextState(space.GetCell(i, j), neighbours); | ||
|
||
if (element != null) | ||
{ | ||
space.SetCellMembership(element, i, j); | ||
continue; | ||
} | ||
|
||
nei = new FurtherMooreNeighbourhood(new AbsorbingBoundary()); | ||
rule = new RuleTwo(); | ||
neighbours = nei.GetNeighbours(lastSpace, i, j); | ||
element = rule.NextState(space.GetCell(i, j), neighbours); | ||
|
||
if (element != null) | ||
{ | ||
space.SetCellMembership(element, i, j); | ||
continue; | ||
} | ||
|
||
nei = new FurtherMooreNeighbourhood(new AbsorbingBoundary()); | ||
rule = new RuleFour(); | ||
neighbours = nei.GetNeighbours(lastSpace, i, j); | ||
element = rule.NextState(space.GetCell(i, j), neighbours); | ||
space.SetCellMembership(element, i, j); | ||
|
||
} | ||
} | ||
Step++; | ||
} | ||
|
||
public void Reset() | ||
{ | ||
Step = 0; | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return "CurvatureExecutor"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
|
||
namespace Model | ||
{ | ||
public interface ISimulationExecutor | ||
{ | ||
|
||
void NextState(CelluralSpace space, CelluralSpace lastSpace, ITransitionRule transition, INeighbourhood neighbourhood); | ||
int ReturnStep(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Model.Transition; | ||
|
||
namespace Model | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Model{ | ||
/// Further Moore checks NE, SE, SW, NW neighbours and return as Cell[] | ||
/// |X|_|X| | ||
/// |_|c|_| | ||
/// |X|_|X| | ||
|
||
public class FurtherMooreNeighbourhood : INeighbourhood | ||
{ | ||
private IBoundaryCondition _boundary; | ||
|
||
|
||
public string Name | ||
{ | ||
get { return this.ToString(); } | ||
} | ||
|
||
|
||
public FurtherMooreNeighbourhood(IBoundaryCondition boundary){ | ||
this._boundary = boundary; | ||
} | ||
|
||
|
||
public Cell[] GetNeighbours(CelluralSpace space, int x, int y){ | ||
Cell[] result = new Cell[4]; | ||
|
||
//Check NE | ||
if ( x - 1 >= 0 && y + 1 < space.GetYLength()) | ||
{ | ||
result[0] = space.GetCell(x - 1, y + 1); | ||
} | ||
else | ||
{ | ||
result[0] = _boundary.GetBoundaryNeighbour(space, x, y, BoundaryDirection.NE); | ||
} | ||
|
||
//Check SE neighbour | ||
if ( x + 1 < space.GetXLength() && y + 1 < space.GetYLength()) | ||
{ | ||
result[1] = space.GetCell(x + 1, y + 1); | ||
} | ||
else | ||
{ | ||
result[1] = _boundary.GetBoundaryNeighbour(space, x, y, BoundaryDirection.SE); | ||
} | ||
|
||
//Check SW neighbour | ||
if (x + 1 < space.GetXLength() && y - 1 >= 0) | ||
{ | ||
result[2] = space.GetCell(x + 1, y - 1); | ||
} | ||
else | ||
{ | ||
result[2] = _boundary.GetBoundaryNeighbour(space, x, y, BoundaryDirection.SW); | ||
} | ||
|
||
//Check NW neighbour | ||
if (x - 1 >= 0 && y - 1 >= 0) | ||
{ | ||
result[3] = space.GetCell(x - 1, y - 1); | ||
} | ||
else | ||
{ | ||
result[3] = _boundary.GetBoundaryNeighbour(space, x, y, BoundaryDirection.NW); | ||
} | ||
|
||
return result; | ||
|
||
} | ||
public override string ToString() | ||
{ | ||
return "FurtherMooreNeighbourhood"; | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.