Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cybersurferllc/AdaptiveBPM
Dynamic Game Difficulty based on Player Heart Rate
https://github.com/cybersurferllc/AdaptiveBPM
bpm game-development heart-rate hyperate machine-learning ml mlnet unity
Last synced: 11 days ago
JSON representation
Dynamic Game Difficulty based on Player Heart Rate
- Host: GitHub
- URL: https://github.com/cybersurferllc/AdaptiveBPM
- Owner: cybersurferllc
- License: mit
- Created: 2023-11-02T15:09:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-12T23:30:52.000Z (about 2 months ago)
- Last Synced: 2024-09-13T15:38:32.220Z (about 2 months ago)
- Topics: bpm, game-development, heart-rate, hyperate, machine-learning, ml, mlnet, unity
- Language: C#
- Homepage:
- Size: 2.8 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
- [Unity 2019.4.18f1](https://unity.com/releases/editor/archive) or higher.
- [Microsoft.ML](https://dotnet.microsoft.com/en-us/apps/machinelearning-ai/ml-dotnet) 1.5.5 or higher.
- Hyperate WebSocket Token. [Get it here](https://www.hyperate.io/api).## `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.
```csharp
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
```csharp
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
- [Caleb Vaccaro](https://www.github.com/calebvaccaro)