Possible stackoverflow inlining fix

This commit is contained in:
Asriel Camora
2024-03-14 00:50:46 -07:00
parent 44ae3791f1
commit 7aa76846c6
2 changed files with 4 additions and 37 deletions
+2 -30
View File
@@ -177,6 +177,8 @@ public sealed class MCTS
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
[SkipLocalsInit]
private (Node ExpandedNode, float Score) ExpandAndRollout(Random random, Simulator simulator, Node initialNode)
{
ref var initialState = ref initialNode.State;
@@ -235,26 +237,6 @@ public sealed class MCTS
}
}
private void ShowAllNodes()
{
static void ShowNodes(StringBuilder b, Node node, Stack<Node> path)
{
path.Push(node);
b.AppendLine($"{new string(' ', path.Count)}{node.State.Action}");
{
for (var i = 0; i < node.Children.Count; ++i)
{
var n = node.ChildAt((i >> 3, i & 7))!;
ShowNodes(b, n, path);
}
path.Pop();
}
}
var b = new StringBuilder();
ShowNodes(b, rootNode, new());
Console.WriteLine(b.ToString());
}
private bool AllNodesComplete()
{
static bool NodesIncomplete(Node node, Stack<Node> path)
@@ -301,13 +283,9 @@ public sealed class MCTS
{
staleCounter = 0;
if (AllNodesComplete())
{
//Console.WriteLine("All nodes solved for. Can't find a valid solution.");
//ShowAllNodes();
return;
}
}
}
else
staleCounter = 0;
}
@@ -334,12 +312,6 @@ public sealed class MCTS
actions.Add(node.State.Action.Value);
}
//var at = node.ChildIdx;
//ref var sum = ref node.ParentScores!.Value.Data[at.arrayIdx].ScoreSum.Span[at.subIdx];
//ref var max = ref node.ParentScores!.Value.Data[at.arrayIdx].MaxScore.Span[at.subIdx];
//ref var visits = ref node.ParentScores!.Value.Data[at.arrayIdx].Visits.Span[at.subIdx];
//Console.WriteLine($"{sum} {max} {visits}");
return new(actions, node.State.State);
}
}
+1 -6
View File
@@ -1,5 +1,3 @@
using Craftimizer.Simulator.Actions;
namespace Craftimizer.Test.Simulator;
[TestClass]
@@ -34,7 +32,6 @@ public class SimulatorTests
ProgressDivider = 130
});
// Conflicting Info:
// https://craftingway.app/rotation/sandy-fafnir-doVCs
// Classical Longsword
private static SimulationInput Input2 { get; } =
@@ -222,10 +219,8 @@ public class SimulatorTests
ActionType.GreatStrides,
ActionType.ByregotsBlessing
},
// Conflicting Info:
// TC https://ffxivteamcraft.com/simulator/35020/34800/4PTlwTV6w1aGCUdO2BRl
3549, 10932, 5, 7);
// Craftingway https://craftingway.app/rotation/sandy-fafnir-doVCs
//3548, 10931, 5, 7);
3549, 10932, 5, 7);
}
}