| Crates.io | farc3 |
| lib.rs | farc3 |
| version | 0.2.0 |
| created_at | 2025-06-21 20:50:52.672749+00 |
| updated_at | 2025-06-23 22:38:20.662761+00 |
| description | ARC3 solving for Constraint Satisfaction Problems |
| homepage | https://github.com/Just-Helpful/Farc3 |
| repository | https://github.com/Just-Helpful/Farc3 |
| max_upload_size | |
| id | 1721093 |
| size | 83,833 |
A semi-generic approach to solving Constraint Satisfaction Problems,
with the possibility to optimise based on the specific implementation of Constraints.
The primary exports of this crate are:
System for generic constraint solvingAssignment trait for assigning values to variablesConstraint trait for constraining the values variables can takeHeuristic trait for deciding search order for constraint solvingThere's also some common variants of constraints:
DiscreteConstraint that covers most forms of discrete constraintsMineConstraint that can be used for minesweeper mine solvinguse farc3::prelude::*;
// Construct the two mine constraints:
// 1. 2 mines among tiles 0, 1 and 2
// 2. 1 mine among tiles 1 and 2
let constraint_0 = MineConstraint::new([0, 1, 2], 2);
let constraint_1 = MineConstraint::new([1, 2], 1);
// Construct the constraint system from these 2 constraints
let mut sys = System::from([
constraint_0,
constraint_1
]);
// Find all solutions to the system
let sltns: HashSet<_> = sys.solve().collect();
// All solutions should mark tile 0 as a mine
// as only one of 1 and 2 can be a mine
assert_eq!(
sltns,
HashSet::from([
MineAssignment::new(/*safe*/ [1], /*mines*/ [2, 0]),
MineAssignment::new(/*safe*/ [2], /*mines*/ [1, 0]),
])
);