namespace Chessistics.Engine.Model; public class BoardSnapshot { public int Width { get; } public int Height { get; } public CellType[,] Grid { get; } public IReadOnlyList Productions { get; } public IReadOnlyList Demands { get; } public IReadOnlyList Pieces { get; } public SimPhase Phase { get; } public int TurnNumber { get; } public IReadOnlyDictionary RemainingStock { get; } public BoardSnapshot(BoardState state) { Width = state.Width; Height = state.Height; Phase = state.Phase; TurnNumber = state.TurnNumber; // Deep copy grid Grid = new CellType[Width, Height]; Array.Copy(state.Grid, Grid, state.Grid.Length); Productions = state.Productions.Values .Select(p => new ProductionSnapshot(p.Position, p.Name, p.Cargo, p.Interval, state.ProductionBuffers[p.Position])) .ToList(); Demands = state.Demands.Values .Select(d => new DemandSnapshot(d.Position, d.Name, d.Cargo, d.Required, d.Deadline, d.ReceivedCount, d.IsSatisfied)) .ToList(); Pieces = state.Pieces .Select(p => new PieceSnapshot(p.Id, p.Kind, p.StartCell, p.EndCell, p.CurrentCell, p.Cargo, p.CargoFilter, p.SocialStatus)) .ToList(); RemainingStock = new Dictionary(state.RemainingStock); } } public record ProductionSnapshot(Coords Position, string Name, CargoType Cargo, int Interval, CargoType? Buffer); public record DemandSnapshot(Coords Position, string Name, CargoType Cargo, int Required, int Deadline, int ReceivedCount, bool IsSatisfied); public record PieceSnapshot(int Id, PieceKind Kind, Coords StartCell, Coords EndCell, Coords CurrentCell, CargoType? Cargo, CargoType? CargoFilter, int SocialStatus);