small fixes
This commit is contained in:
@@ -26,7 +26,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
/// The average time to solve a specific puzzle.
|
||||
/// </summary>
|
||||
public static float AverageTime(PuzzleModuleDescription puzzle) =>
|
||||
PuzzleStorage.Instance.Load(puzzle).AverageTimeToSolve;
|
||||
PuzzleStorage.Instance.LoadOrNew(puzzle).AverageTimeToSolve;
|
||||
/// <summary>
|
||||
/// The average time to solve a group of puzzles.
|
||||
/// </summary>
|
||||
@@ -42,7 +42,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
/// Estimate the time a specific puzzle will take to be solved by the current player.
|
||||
/// </summary>
|
||||
public static float EstimateTime(PuzzleModuleDescription puzzle) =>
|
||||
PuzzleStorage.Instance.Load(puzzle).EstimateTimeToSolve(SessionPercentile());
|
||||
PuzzleStorage.Instance.LoadOrNew(puzzle).EstimateTimeToSolve(SessionPercentile());
|
||||
/// <summary>
|
||||
/// Estimate the time a group of puzzles will take to be solved by the current player.
|
||||
/// </summary>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
public PlanResult(float targetTime, float sectionPercentile, float timeEstimation)
|
||||
{
|
||||
TargetTime = targetTime;
|
||||
SectionPercentile = sectionPercentile;
|
||||
SectionPercentile = float.IsNaN(sectionPercentile) ? 0.5f : sectionPercentile;
|
||||
TimeEstimation = timeEstimation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
/// Create a new puzzle for a specific description and store it in the database.
|
||||
/// </summary>
|
||||
/// <remarks>This requires that the puzzle does not yet exist in the database.</remarks>
|
||||
private Puzzle New(PuzzleModuleDescription puzzle)
|
||||
public Puzzle New(PuzzleModuleDescription puzzle)
|
||||
{
|
||||
Puzzle created = null;
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
/// <summary>
|
||||
/// Load a specific puzzle from the database or create it if it wasn't found.
|
||||
/// </summary>
|
||||
private Puzzle LoadOrNew(PuzzleModuleDescription puzzle) => _realm.Find<Puzzle>(puzzle.Id) ?? New(puzzle);
|
||||
public Puzzle LoadOrNew(PuzzleModuleDescription puzzle) => _realm.Find<Puzzle>(puzzle.Id) ?? New(puzzle);
|
||||
|
||||
/// <summary>
|
||||
/// Load a specific puzzle from the database.
|
||||
@@ -136,9 +136,10 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
session.PuzzlesSolved.Add(found);
|
||||
|
||||
// add plan result to session
|
||||
var percentile = found.Distribution.Cumulative(measurement.Time);
|
||||
session.PlanResults.Add(new PlanResult(
|
||||
GameControl.Instance.TargetTime,
|
||||
found.Distribution.Cumulative(measurement.Time),
|
||||
percentile,
|
||||
GameControl.Instance.EstimatedTime));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
/// <summary>
|
||||
/// An abstract module state. Example implementations are <see cref="DoorState"/> and <see cref="PuzzleState"/>.
|
||||
/// </summary>
|
||||
[SelectionBase]
|
||||
public abstract class ModuleState : MonoBehaviour
|
||||
{
|
||||
[Tooltip("The size of this module in meters.")]
|
||||
|
||||
@@ -32,7 +32,6 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
/// <summary>
|
||||
/// The <see cref="ModuleState"/> of a <see cref="PuzzleModule"/>. Handles all events that can occur for a door.
|
||||
/// </summary>
|
||||
[SelectionBase]
|
||||
public class PuzzleState : ModuleState
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Utilities
|
||||
public NormalDistribution(float[] samples) : this()
|
||||
{
|
||||
μ = Probability.Mean(samples);
|
||||
σ = Probability.StandardDeviation(samples, μ);
|
||||
σ = samples.Length == 0 ? 1.0f : Probability.StandardDeviation(samples, μ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user