Skip to content

Conversation

@lloydsparkes
Copy link
Owner

No description provided.

…roject. The test harness is designed to help diagnose a bug where city metrics trend to zero.

The test harness consists of a new xUnit test project that:
1.  Initializes the Micropolis engine.
2.  Runs the simulation for 100 ticks.
3.  Captures the state of the engine at each tick, including the full map state and the simulation phase cycle.
4.  Serializes the history of captured states to a JSON file named `engine_history.json`.

This will allow you to analyze the state of the engine over time and identify the cause of the bug.

NOTE: I was unable to compile and run the tests to verify the changes. The code has been written based on my knowledge of the C# language and .NET ecosystem, following best practices.
…designed it to help you diagnose a bug where city metrics trend to zero.

The test harness consists of a new xUnit test project that:
1.  Initializes the Micropolis engine.
2.  Runs the simulation for 100 ticks.
3.  Captures the state of the engine at each tick, including the full map state, the simulation phase cycle, and the power grid map.
4.  Serializes the history of captured states to a JSON file named `engine_history.json`.

This will allow you to analyze the state of the engine over time and identify the cause of the bug.

NOTE: Due to limitations in my execution environment, I was unable to compile and run the tests to verify the changes. I have written the code based on best practices and my knowledge of the C# language and .NET ecosystem.
…roject. The test harness is designed to help diagnose a bug where city metrics trend to zero.

The test harness consists of a new xUnit test project that:
1.  Initializes the Micropolis engine.
2.  Runs the simulation for 100 ticks.
3.  Captures the state of the engine at each tick, including:
    -   Full map state
    -   Simulation phase cycle
    -   Power grid map
    -   An ASCII representation of the power grid map
4.  Serializes the history of captured states to a JSON file named `engine_history.json`.

This will allow you to analyze the state of the engine over time and identify the cause of the bug.

NOTE: I was unable to compile and run the tests to verify the changes. The code has been written based on best practices and knowledge of the C# language and .NET ecosystem.
…roject. The test harness is designed to help diagnose a bug where city metrics trend to zero.

The test harness consists of a new xUnit test project that:
1.  Loads the "kobe.cty" city file.
2.  Runs the simulation for 100 ticks.
3.  Captures the state of the engine at each tick, including:
    -   Full map state
    -   Simulation phase cycle
    -   Power grid map
    -   An ASCII representation of the power grid map
4.  Serializes the history of captured states to a JSON file named `engine_history.json`.

This will allow you to analyze the state of the engine over time and identify the cause of the bug.

NOTE: I was unable to compile and run the tests to verify the changes. However, I wrote the code based on best practices and my knowledge of the C# language and .NET ecosystem.
…e engine state. The default `System.Text.Json` serializer does not support two-dimensional arrays, which caused an error when trying to serialize the `Map` and `PowerGridMap` properties.

The fix involves converting the `ushort[,]` and `byte[,]` arrays to jagged arrays (`ushort[][]` and `byte[][]`) before serialization. This is done by adding helper methods to the `EngineTests` class.

This change allows the test harness to correctly serialize the full engine state, including map data, to the `engine_history.json` file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants