diff --git a/catan-lib/Parts/Player.cs b/catan-lib/Parts/Player.cs new file mode 100644 index 0000000..8a38bac --- /dev/null +++ b/catan-lib/Parts/Player.cs @@ -0,0 +1,42 @@ +using CatanLib.Enums; +using CatanLib.Interfaces.Components; + +namespace CatanLib.Parts +{ + public class Player : IPlayer + { + public PlayerNumber Number { get; set; } + + public Dictionary Resources { get; } = new() + { + { ResourceType.Sheep, 0 }, + { ResourceType.Wheat, 0 }, + { ResourceType.Ore, 0 }, + { ResourceType.Brick, 0 }, + { ResourceType.Wood, 0 } + }; + + public Dictionary Pieces { get; } = new() + { + { PieceType.Road, 15 }, + { PieceType.Settlement, 5 }, + { PieceType.City, 4 } + }; + + public IEnumerable ToVector(ICatan catan) + { + float[] pieceEncoding = new float[] + { + Pieces[PieceType.Road] / 15f, + Pieces[PieceType.Settlement] / 5f, + Pieces[PieceType.City] / 4f + }; + + IEnumerable resourceEncoding = Number == catan.CurrentPlayer.Number + ? Enum.GetValues().Select(resource => Resources[resource] / 19f) + : new float[] { Enum.GetValues().Select(resource => Resources[resource]).Sum() / 95f }; + + return resourceEncoding.Concat(pieceEncoding); + } + } +}