From 91677ca70845075174e92dfe5da0620e41c2e2a8 Mon Sep 17 00:00:00 2001 From: hheik <4469778+hheik@users.noreply.github.com> Date: Fri, 8 May 2026 13:43:13 +0300 Subject: [PATCH] Updated Ruleset documentation --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 5b69801..9e77169 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -118,9 +118,18 @@ pub trait GraphLike { } pub trait Ruleset { + /// Calculate the "entropy" of a node, based on the current state of the graph. Should return + /// None if the node is impossible, and Some(entropy) if it is possible. The exact meaning of + /// entropy is up to the implementation, but it should be a value that can be compared between + /// nodes to determine which one is more "constrained". For example, it could be the number of + /// possible values that the node can take, or the number of empty neighbours it has. + /// + /// By default the WFC algorithm chooses the node with the lowest entropy to "collapse" fn entropy(&self, graph: &impl GraphLike, id: NodeId) -> Option where NodeId: Copy; + /// Choose a node to "collapse" to, based on the current state of the graph. Should return None + /// if the node is impossible. fn choose( &self, graph: &impl GraphLike,