From 0f732d5e968027ede249bfea8862d6b0ea591300 Mon Sep 17 00:00:00 2001
From: Michael Leuschel <leuschel@uni-duesseldorf.de>
Date: Tue, 29 Jun 2021 14:00:07 +0200
Subject: [PATCH] compute possible values

---
 Sudoku/SudokuEvent.mch | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Sudoku/SudokuEvent.mch b/Sudoku/SudokuEvent.mch
index 1ee706d..b8aa63b 100644
--- a/Sudoku/SudokuEvent.mch
+++ b/Sudoku/SudokuEvent.mch
@@ -42,7 +42,7 @@ PUZZLE == (
   );
 
   UnassignedPosition(x,y) == x:DOM & y:DOM & not(y:dom(Board(x)));
-
+  PossibleVals(cx,cy) == DOM \ ran({x,y,r| x|->y : conflict_pos(cx,cy) & y:dom(Board(x)) & r=Board(x)(y)})
 CONSTANTS
   get_square /*@desc "Subsquare (1,2,3) for a coordinate 1..9" */,
   conflict_pos /*@desc "set of positions that are in conflict with a given position" */,
@@ -85,6 +85,9 @@ OPERATIONS
   ClearCurPos = BEGIN
      Board(curx) := {cury} <<| Board(curx)  // clear the value at the current position
   END;
+  res <-- GetPossibleVals = BEGIN
+     res := PossibleVals(curx,cury)
+  END;
 
   Solve(SBoard) = PRE
     SBoard : DOM --> (DOM --> RAN)   /*@desc "The solution must be complete" */ &
-- 
GitLab