Possible stackoverflow inlining fix
This commit is contained in:
+2
-30
@@ -177,6 +177,8 @@ public sealed class MCTS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
|
[SkipLocalsInit]
|
||||||
private (Node ExpandedNode, float Score) ExpandAndRollout(Random random, Simulator simulator, Node initialNode)
|
private (Node ExpandedNode, float Score) ExpandAndRollout(Random random, Simulator simulator, Node initialNode)
|
||||||
{
|
{
|
||||||
ref var initialState = ref initialNode.State;
|
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()
|
private bool AllNodesComplete()
|
||||||
{
|
{
|
||||||
static bool NodesIncomplete(Node node, Stack<Node> path)
|
static bool NodesIncomplete(Node node, Stack<Node> path)
|
||||||
@@ -301,13 +283,9 @@ public sealed class MCTS
|
|||||||
{
|
{
|
||||||
staleCounter = 0;
|
staleCounter = 0;
|
||||||
if (AllNodesComplete())
|
if (AllNodesComplete())
|
||||||
{
|
|
||||||
//Console.WriteLine("All nodes solved for. Can't find a valid solution.");
|
|
||||||
//ShowAllNodes();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
staleCounter = 0;
|
staleCounter = 0;
|
||||||
}
|
}
|
||||||
@@ -334,12 +312,6 @@ public sealed class MCTS
|
|||||||
actions.Add(node.State.Action.Value);
|
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);
|
return new(actions, node.State.State);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Craftimizer.Simulator.Actions;
|
|
||||||
|
|
||||||
namespace Craftimizer.Test.Simulator;
|
namespace Craftimizer.Test.Simulator;
|
||||||
|
|
||||||
[TestClass]
|
[TestClass]
|
||||||
@@ -34,7 +32,6 @@ public class SimulatorTests
|
|||||||
ProgressDivider = 130
|
ProgressDivider = 130
|
||||||
});
|
});
|
||||||
|
|
||||||
// Conflicting Info:
|
|
||||||
// https://craftingway.app/rotation/sandy-fafnir-doVCs
|
// https://craftingway.app/rotation/sandy-fafnir-doVCs
|
||||||
// Classical Longsword
|
// Classical Longsword
|
||||||
private static SimulationInput Input2 { get; } =
|
private static SimulationInput Input2 { get; } =
|
||||||
@@ -222,10 +219,8 @@ public class SimulatorTests
|
|||||||
ActionType.GreatStrides,
|
ActionType.GreatStrides,
|
||||||
ActionType.ByregotsBlessing
|
ActionType.ByregotsBlessing
|
||||||
},
|
},
|
||||||
// Conflicting Info:
|
|
||||||
// TC https://ffxivteamcraft.com/simulator/35020/34800/4PTlwTV6w1aGCUdO2BRl
|
// TC https://ffxivteamcraft.com/simulator/35020/34800/4PTlwTV6w1aGCUdO2BRl
|
||||||
3549, 10932, 5, 7);
|
|
||||||
// Craftingway https://craftingway.app/rotation/sandy-fafnir-doVCs
|
// Craftingway https://craftingway.app/rotation/sandy-fafnir-doVCs
|
||||||
//3548, 10931, 5, 7);
|
3549, 10932, 5, 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user