Diff logs in new release

Hi folks,

I wrote my own visualizer to help me with my testing. I made some tweaks to it to use the diff logs created in the latest release, an uncovered a potential issue with the logging.

It seems the diff logs get “confused” when changes happen that remove trails or territory. Specifically, if my bot completes a trail, if seems that all those trail entries are logged as updates, with a value of zero.

"Trails": [
			"Key": {
				"X": 12,
				"Y": 2,
				"$type": "CellCoordinate"
			"Value": 0,
			"$type": "KeyValuePair`2"

This is exactly the same type of logging that happens when bot 1 creates a trail - i.e. bot 1 creating a trail looks exactly the same when any bot completes a trail and it’s removed. I suspect the code below (from 2024-Sproutopia/Sproutopia/Models/DiffLog.cs at e2457dde2ac19c9d464f33c2d7bb591e2999a889 · EntelectChallenge/2024-Sproutopia · GitHub) causes it - the default value of 0 for integers has specific meaning in the context of Sproutopia.

            // Iterate over the keys in the original dictionary
            foreach (var key in original.Keys)
                // Check if the key exists in the updated dictionary
                if (updated.TryGetValue(key, out TValue? value))
                    // If the values are different, add the change to the result dictionary
                    if (!EqualityComparer<TValue>.Default.Equals(original[key], value))
                        changes[key] = value;
                    // If the key does not exist in the updated dictionary, consider it as a removal
                    changes[key] = default(TValue);  //<==== HERE

Maybe a lot to ask - but any chance we can give the game engine a flag to either log diffs or to just write out the full Json state for each round? The latter will take up more space for logs, but make debugging so much easier.

Edit: On second thought, it’s easy enough to tweak the logging myself if I need to, since we have access to the engine code anyway. It is probably still worth double-checking that the diff log is behaving correctly though.


Thanks for this @rfnel. As we were adding functionality to the visualizer to load and visualize game logs, we discovered this as well. We have a change being reviewed right now that fixes this. Once the new change it shipped, you will also have an example in the visualizer to see how stacks of DiffLog entries can be reduced to a single GameStateDto.

I’m not sure when we will be shipping that change but I do hope it can go out in the next release.

1 Like