Installation
Get started with CCF
CCF is available as a Rust crate on crates.io. It compiles to no_std targets including embedded ARM and WASM appliance tiles.
Cargo install
Cargo.toml
[dependencies]
ccf-core = "0.1"Or via the CLI: cargo add ccf-core
Feature flags
Cargo.toml — with serde
[dependencies]
ccf-core = { version = "0.1", features = ["serde"] }Quick start
src/main.rs
use ccf_core::{
accumulator::CoherenceField,
phase::Personality,
vocabulary::{ContextKey, SensorVocabulary},
};
// 1. Define your sensor vocabulary
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
struct MySensors { proximity: u8, light: u8 }
impl SensorVocabulary<2> for MySensors {
fn to_feature_vec(&self) -> [f32; 2] {
[self.proximity as f32 / 3.0, self.light as f32 / 2.0]
}
}
fn main() {
let mut field = CoherenceField::new();
let personality = Personality::default();
// 2. Observe an interaction
let sensors = MySensors { proximity: 2, light: 1 };
let key = ContextKey::<MySensors, 2>::new(sensors);
for tick in 0..20u64 {
field.positive_interaction(&key, &personality, tick, false);
}
// 3. Read the social phase
let coherence = field.context_coherence(&key);
println!("Coherence: {:.3}", coherence); // e.g. 0.847
}Reference implementation
mBot2 — the $50 robot
The canonical CCF demo runs on an mBot2 connected via Bluetooth LE. Eight sensor dimensions drive a CCF brain — the robot develops measurably different social phases per context with no training data.
Cargo.toml — mBot2 target
[dependencies]
ccf-core = { version = "0.1", features = ["serde"] }
# Optional: BLE transport
btleplug = "0.11"Source: github.com/Hulupeep/CCF — see crates/mbot-companion
Python FFI
Use CCF from Python
The python-ffi feature exposes CCF via PyO3. Build with maturin, install as a local wheel, and drive the coherence field from Python.
Build & install
pip install maturin
maturin develop --features python-ffiPython usage
import ccf_core
field = ccf_core.CoherenceField()
personality = ccf_core.Personality()
# Drive positive interactions
for tick in range(20):
field.positive_interaction([0.67, 0.5], personality, tick, False)
coherence = field.context_coherence([0.67, 0.5])
print(f"Coherence: {coherence:.3f}")