StateRecorderViewModel

class StateRecorderViewModel : ObservableObject

An observable class that handles state recording for machine learning.

  • The list of entries to include.

    Declaration

    Swift

    @Published
    var entries: [AIStateRecordable] { get set }
  • The current assessment the model is viewing.

    Declaration

    Swift

    @Published
    var currentAssessment: AIAbstractGameState.Assessement { get set }
  • The current action as a result of this assessment.

    When this value is changed, onReceiveAction will be executed with the current assessment and action. This assessment-action pair will automatically be added to the entries list.

    Declaration

    Swift

    @Published
    var currentAction: String { get set }
  • A closure that executes when the current action is changed.

    Declaration

    Swift

    var onReceiveAction: (AIAbstractGameState.Assessement, String) -> Void
  • Instantiate the assessment model.

    Declaration

    Swift

    public init(
        from assessment: AIAbstractGameState.Assessement,
        onReceiveAction: @escaping (AIAbstractGameState.Assessement, String) -> Void
    )

    Parameters

    assessment

    The starting assessment to work with.

  • Add an entry to the list of entries.

    Declaration

    Swift

    func add(_ entry: AIStateRecordable)

    Parameters

    entry

    The entry to include in the new

  • Add an assessment and action to the list of entries as a new entry.

    Declaration

    Swift

    func addEntry(from assessment: AIAbstractGameState.Assessement, with action: String)
  • Export the list of entries to a CSV file.

    Declaration

    Swift

    func export(to csvPath: URL)

    Parameters

    csvPath

    The URL to save the data to.