Open
Conversation
…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.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.