.net 8 syntax/perf changes
This commit is contained in:
+3
-11
@@ -2,24 +2,16 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
public sealed class ArenaNode<T> where T : struct
|
||||
public sealed class ArenaNode<T>(in T state, ArenaNode<T>? parent = null) where T : struct
|
||||
{
|
||||
public T State;
|
||||
public T State = state;
|
||||
public ArenaBuffer<T> Children;
|
||||
public NodeScoresBuffer ChildScores;
|
||||
public (int arrayIdx, int subIdx) ChildIdx;
|
||||
public readonly ArenaNode<T>? Parent;
|
||||
public readonly ArenaNode<T>? Parent = parent;
|
||||
|
||||
public NodeScoresBuffer? ParentScores => Parent?.ChildScores;
|
||||
|
||||
public ArenaNode(in T state, ArenaNode<T>? parent = null)
|
||||
{
|
||||
State = state;
|
||||
Children = new();
|
||||
ChildScores = new();
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
public ArenaNode<T>? ChildAt((int arrayIdx, int subIdx) at) =>
|
||||
Children.Data?[at.arrayIdx]?[at.subIdx];
|
||||
|
||||
|
||||
@@ -7,26 +7,18 @@ using System.Runtime.InteropServices;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public struct SimulationNode
|
||||
public struct SimulationNode(in SimulationState state, ActionType? action, CompletionState completionState, ActionSet actions)
|
||||
{
|
||||
public readonly SimulationState State;
|
||||
public readonly ActionType? Action;
|
||||
public readonly CompletionState SimulationCompletionState;
|
||||
public readonly SimulationState State = state;
|
||||
public readonly ActionType? Action = action;
|
||||
public readonly CompletionState SimulationCompletionState = completionState;
|
||||
|
||||
public ActionSet AvailableActions;
|
||||
public ActionSet AvailableActions = actions;
|
||||
|
||||
public readonly CompletionState CompletionState => GetCompletionState(SimulationCompletionState, AvailableActions);
|
||||
|
||||
public readonly bool IsComplete => CompletionState != CompletionState.Incomplete;
|
||||
|
||||
public SimulationNode(in SimulationState state, ActionType? action, CompletionState completionState, ActionSet actions)
|
||||
{
|
||||
State = state;
|
||||
Action = action;
|
||||
SimulationCompletionState = completionState;
|
||||
AvailableActions = actions;
|
||||
}
|
||||
|
||||
public static CompletionState GetCompletionState(CompletionState simCompletionState, ActionSet actions) =>
|
||||
actions.IsEmpty && simCompletionState == CompletionState.Incomplete ?
|
||||
CompletionState.NoMoreActions :
|
||||
|
||||
Reference in New Issue
Block a user