SimpleBlackboard.Net 2.1.0.1

dotnet add package SimpleBlackboard.Net --version 2.1.0.1
                    
NuGet\Install-Package SimpleBlackboard.Net -Version 2.1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleBlackboard.Net" Version="2.1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleBlackboard.Net" Version="2.1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="SimpleBlackboard.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimpleBlackboard.Net --version 2.1.0.1
                    
#r "nuget: SimpleBlackboard.Net, 2.1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimpleBlackboard.Net@2.1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimpleBlackboard.Net&version=2.1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=SimpleBlackboard.Net&version=2.1.0.1
                    
Install as a Cake Tool

SimpleBlackboard.Net

Logo

A simple package containing a basic Blackboard data structure.

Installation

Nuget

NuGet version (SimpleBlackboard.Net)

The recommended installation approach is to use the available nuget package: SimpleBlackboard.Net

Clone

Alternatively, you can clone this repo and reference the SimpleBlackboard.Net project in your project.

Features

  • A Blackboard interface that can be extended to create custom blackboards (IBlackboard).
  • A standard Blackboard class that can be used out-of-the-box (Blackboard)

What is a Blackboard?

A Blackboard is a data structure designed to act as a structured global memory containing objects from the solution space. For more information, see:

Usage

Built-in Blackboard

The built-in Blackboard class provides a ready-to-use very simplified implementation that can be used out-of-the-box . This version relies on an internal dictionary to store the data and is agnostic about implementation details that may be important for your specific implementation.

Example Usage:
using SimpleBlackboard.Net;

public class Program
{
    public static void Main()
    {
        // Create a new blackboard (optionally with thread-safe concurrent dictionary)
        var blackboard = new Blackboard(useConcurrentDictionary: true);

        // Store different types of data
        blackboard.SetValue("PlayerName", "John");
        blackboard.SetValue("PlayerHealth", 100);
        blackboard.SetValue("IsAlive", true);
        blackboard.SetValue("Position", new Vector3(10.5f, 0, 3.2f));

        // Retrieve data in a type-safe manner
        string name = blackboard.GetValue<string>("PlayerName");
        int health = blackboard.GetValue<int>("PlayerHealth");

        // Check if a value exists
        if (blackboard.HasValue<bool>("IsAlive"))
        {
            Console.WriteLine($"Player {name} is alive: {blackboard.GetValue<bool>("IsAlive")}");
        }

        // Try to get a value safely
        if (blackboard.TryGetValue("Position", out Vector3? position))
        {
            Console.WriteLine($"Player position: {position}");
        }

        // Remove a value and get it at the same time
        int oldHealth = blackboard.RemoveValue<int>("PlayerHealth") ?? 0;

        // Try to remove a value safely
        if (blackboard.TryRemoveValue("IsAlive", out bool isAlive))
        {
            Console.WriteLine($"Removed 'IsAlive' flag: {isAlive}");
        }

        // Clear all data from the blackboard
        blackboard.ClearBlackboard();
    }
}

Custom Blackboard

Below is a simple blackboard implementation. However, besides implementing the standard fields, you have full control as to the structure of the Blackboard and it would be highly recommended to have and use structured fields/properties additionally to the built-in methods.

Example Usage:

using SimpleBlackboard.Net;

public class MyBlackboard : IBlackboard
{
    private readonly Dictionary<string, object?> _data = new();
    
    public bool SetValue<T>(string key, T value)
    {
        _data[key] = value;
        return true;
    }
    
    public T? GetValue<T>(string key)
    {
        if (_data.TryGetValue(key, out var value) && value is T typedValue)
        {
            return typedValue;
        }

        return default;
    }
    
    public bool TryGetValue<T>(string key, out T? value)
    {
        if (_data.TryGetValue(key, out var typedValue) && typedValue is T typedValueT)
        {
            value = typedValueT;
            return true;
        }

        value = default;
        return false;
    }
    
    public bool HasValue<T>(string key)
    {
        return this._data.ContainsKey(key);
    }
    
    public void ClearBlackboard()
    {
        _data.Clear();
    }
    
    public T? RemoveValue<T>(string key)
    {
        if (TryGetValue(key, out T? value))
        {
            _data.Remove(key);
            return value;
        }

        return default;
    }
    
    public bool TryRemoveValue<T>(string key, out T? value)
    {
        if (_data.TryGetValue(key, out var typedValue) && typedValue is T typedValueT)
        {
            value = typedValueT;
            return _data.Remove(key);
        }

        value = default;
        return false;
    }
}

public class Program
{
    public static void Main()
    {
        var blackboard = new MyBlackboard();
        
        // Set a value
        blackboard.SetValue("Score", 100);
        
        // Get a value
        int score = blackboard.GetValue<int>("Score");
        Console.WriteLine($"Score: {score}");
        
        // Check if a value exists
        bool hasScore = blackboard.HasValue<int>("Score");
        Console.WriteLine($"Has Score: {hasScore}");
        
        // Clear the blackboard
        blackboard.ClearBlackboard();
    }
}

Development

  1. Clone or fork the repo
  2. Create a new branch
  3. Code!
  4. Push your changes and open a PR
  5. Once approved, they'll be merged in
  6. Profit!

Future Plans

See list of issues under the Milestones: https://github.com/vonderborch/SimpleBlackboard.Net/milestones

Product 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 is compatible.  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 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.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
2.1.0.1 131 6/25/2025
2.0.0.4 134 6/24/2025
1.0.0.3 114 6/8/2025