-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using CatanLib.Enums; | ||
using HexagonLib; | ||
|
||
namespace CatanLib.Interfaces | ||
{ | ||
public interface ISettlement : IVectorizable | ||
{ | ||
VertexCoordinate Vertex { get; set; } | ||
bool IsSettlement { get; } | ||
bool IsCity { get; } | ||
PlayerNumber? Belongs { get; } | ||
} | ||
} |
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,40 @@ | ||
using CatanLib.Enums; | ||
using CatanLib.Interfaces; | ||
using HexagonLib; | ||
|
||
namespace CatanLib.Parts | ||
{ | ||
public class Settlement : ISettlement | ||
{ | ||
private VertexCoordinate? vertex; | ||
public VertexCoordinate Vertex | ||
{ | ||
get => vertex ?? throw new NullReferenceException(); | ||
set => vertex ??= value; | ||
} | ||
|
||
public bool IsSettlement { get; private set; } | ||
|
||
public bool IsCity { get; private set; } | ||
|
||
public PlayerNumber? Belongs { get; private set; } | ||
|
||
public IEnumerable<float> ToVector() | ||
{ | ||
|
||
float[] playerEncoding = new float[Enum.GetValues<PlayerNumber>().Length]; | ||
if (Belongs != null) | ||
{ | ||
playerEncoding[(int)Belongs] = 1; | ||
} | ||
|
||
float[] buildingEncoding = new float[] { IsSettlement ? 1 : 0, IsCity ? 1 : 0 }; | ||
return Enumerable.Concat(playerEncoding, buildingEncoding); | ||
} | ||
|
||
public IEnumerable<string> ToExplainedVector() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |