choose-your-bed
1769.166.238.927
dotnet add package choose-your-bed --version 1769.166.238.927
NuGet\Install-Package choose-your-bed -Version 1769.166.238.927
<PackageReference Include="choose-your-bed" Version="1769.166.238.927" />
<PackageVersion Include="choose-your-bed" Version="1769.166.238.927" />
<PackageReference Include="choose-your-bed" />
paket add choose-your-bed --version 1769.166.238.927
#r "nuget: choose-your-bed, 1769.166.238.927"
#:package choose-your-bed@1769.166.238.927
#addin nuget:?package=choose-your-bed&version=1769.166.238.927
#tool nuget:?package=choose-your-bed&version=1769.166.238.927
ChooseYourBed
A streamlined .NET library for generating "Choose Your Bed" style decision trees, simplifying the creation of branching narratives and interactive content. This package provides a fluent API for defining decision paths and handling user choices.
Installation
To install the ChooseYourBed package, use the following command in your .NET project: bash dotnet add package ChooseYourBed
Usage Examples
Here are a few examples demonstrating how to use the ChooseYourBed library:
Example 1: Simple Decision Tree csharp using ChooseYourBed;
// Create a basic decision tree. var tree = new DecisionTreeBuilder() .WithRoot("You wake up. Do you stay in bed or get up?") .AddChoice("Stay in bed", "You fall back asleep. The end.") .AddChoice("Get up", "You start your day. The end.") .Build();
// Simulate a user choosing "Get up" string result = tree.Choose("Get up"); Console.WriteLine(result); // Output: You start your day. The end.
Example 2: Multi-Level Decision Tree csharp using ChooseYourBed;
// Create a more complex decision tree with nested choices. var tree = new DecisionTreeBuilder() .WithRoot("You are at a crossroads. Which path do you take?") .AddChoice("Left Path", "You encounter a friendly village.") .AddChoice("Help the villagers", "The villagers reward you with gold. You win!") .AddChoice("Ignore the villagers", "You continue on your journey.") .AddChoice("Right Path", "You enter a dark forest.") .AddChoice("Brave the forest", "You find a hidden treasure. You win!") .AddChoice("Turn back", "You return to the crossroads.") .Build();
// Simulate a user choosing "Left Path" then "Help the villagers" string firstChoiceResult = tree.Choose("Left Path"); var subTree = new DecisionTreeBuilder().WithRoot(firstChoiceResult) .AddChoice("Help the villagers", "The villagers reward you with gold. You win!") .AddChoice("Ignore the villagers", "You continue on your journey.") .Build();
string finalResult = subTree.Choose("Help the villagers"); Console.WriteLine(finalResult); // Output: The villagers reward you with gold. You win!
Example 3: Handling Invalid Choices csharp using ChooseYourBed;
// Create a decision tree. var tree = new DecisionTreeBuilder() .WithRoot("Do you choose A or B?") .AddChoice("A", "You chose A.") .AddChoice("B", "You chose B.") .Build();
// Attempt to choose an invalid option. try { string result = tree.Choose("C"); Console.WriteLine(result); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); // Output: Invalid choice: C }
Example 4: Using with Data Models csharp using ChooseYourBed;
public class GameState { public int Health { get; set; } = 100; public int Gold { get; set; } = 0; }
// Create a decision tree with data-dependent outcomes. GameState gameState = new GameState(); var tree = new DecisionTreeBuilder() .WithRoot("You encounter a monster. Fight or run?") .AddChoice("Fight", () ⇒ { gameState.Health -= 20; return $"You fight the monster and lose 20 health. Health: {gameState.Health}"; }) .AddChoice("Run", () ⇒ { gameState.Gold -= 10; return $"You run away and lose 10 gold. Gold: {gameState.Gold}"; }) .Build();
// Simulate a user choosing "Fight" string result = tree.Choose("Fight"); Console.WriteLine(result); // Output: You fight the monster and lose 20 health. Health: 80
Feature Summary
- Fluent API: Easily construct decision trees with a readable and intuitive syntax.
- Branching Logic: Create complex narratives with multiple levels of choices.
- Error Handling: Robustly handles invalid user choices.
- Custom Actions: Integrate custom logic and data manipulation for dynamic outcomes.
- Simple Integration: Easily integrates into existing .NET projects.
License
MIT License
This package is part of the choose-your-bed ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/blog/how-to-make-the-viral-choose-your-bed-videos-with-ai/
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1769.166.238.927 | 148 | 1/23/2026 |