d5a8288439
- Breaks backwards compat solver code with last version. Concurrent broke backwards compat because of race conditions with rng, but single is now broken too, despite it being 2x faster (!!!!) - Literally twice as fast as Rust now in single thread - Concurrent doesn't work yet, deadlocks somewhere..?
26 lines
551 B
C#
26 lines
551 B
C#
using System.Runtime.InteropServices;
|
|
|
|
namespace Craftimizer.Solver.Crafty;
|
|
|
|
[StructLayout(LayoutKind.Auto)]
|
|
public struct NodeScores
|
|
{
|
|
public float ScoreSum;
|
|
public float MaxScore;
|
|
public int Visits;
|
|
|
|
public void VisitConcurrent(float score)
|
|
{
|
|
Intrinsics.CASAdd(ref ScoreSum, score);
|
|
Intrinsics.CASMax(ref MaxScore, score);
|
|
Interlocked.Increment(ref Visits);
|
|
}
|
|
|
|
public void Visit(float score)
|
|
{
|
|
ScoreSum += score;
|
|
MaxScore = Math.Max(MaxScore, score);
|
|
Visits++;
|
|
}
|
|
}
|