Skip to content

cybersurferllc/AdaptiveBPM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adaptive Intensity System with Hyperate Integration

Welcome to our Adaptive Intensity System with real-time integration to the Hyperate API. This system is designed to adjust game or simulation intensity based on real-time heart rate data, providing an immersive experience for the user.

Prerequisites

AdaptiveBPM.ML and AdaptiveBPM.Unity Projects

We have two different projects:

1. AdaptiveBPM.ML:

This project generates machine learning models and tests them in isolation. It focuses on data analysis and model training.

Key Aspects:

  • Model Generation: Responsible for generating machine learning models using historical heart rate data.
  • Model Testing: Provides a controlled environment to test the accuracy of these models.

2. AdaptiveBPM.Unity:

The Unity project that writes data to the data file and uses the new model for the next prediction of intensity. It's the front-end that integrates with Hyperate and adapts game intensity based on real-time heart rate data.

Key Aspects:

  • Integration with Hyperate: Establishes a WebSocket connection with Hyperate to receive real-time heart rate data.
  • Intensity Adjustment: Uses the machine learning models generated by AdaptiveBPM.ML to adjust game intensity in real-time.
  • Hyperate Data Logging: Writes heart rate data to a file for future use in AdaptiveBPM.ML.

Getting Started

Running the ML Project

  • Ensure you have Microsoft.ML installed as a nuget package.
  • Run the project. It will generate a new model from csv data and save it to the Models folder.
void RunModel()
{
    // Create a reference to the model
    AdaptiveBpmMLModel mlModel = new AdaptiveBpmMLModel();
    // transfrom and classify the data, save the model
    mlModel.LoadModel();
    // make a prediction
    mlModel.Predict();
}

Running the Unity Simulation and Adding Data

  • Ensure you have a WebSocket token from Hyperate and plug it into the hyperateSocket component.
  • Attach the AdaptiveBPM script to a GameObject. This object will handle the intensity adjustments.
  • Attach the hyperateSocket script to a separate GameObject and reference the AdaptiveBPM object.
  • Configure parameters like max/min BPM, history length, etc., according to your requirements.
  • Run the simulation or game. Heart rate updates will be received from Hyperate, and intensity adjustments will be made accordingly.
  • Add data to the model for prediction refinement
void AddDataToModel()
{
    // Game captured BPM data
    var gameCaptureBPMData = new AdaptiveBpmMLTrainingModel.ModelSerialized { Intensity = 1, BPM = 99, TargetBPM = 110, BPMDifference = 10, Label = 1 };
    // Create a reference to the model
    AdaptiveBpmMLModel model = new AdaptiveBpmMLModel();
    // Append the data to the CSV file
    model.AppendDataToCSV(gameCaptureBPMData);
}

Authors

About

Dynamic Game Difficulty based on Player Heart Rate

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors