Re: [eclipse-clp-users] looking for examples based on 'visualisation tools manual'

From: Joachim Schimpf <jschimpf_at_...127...>
Date: Mon, 24 Nov 2008 12:09:48 +1100
George Thomas wrote:
> Hi -
>  
> Are there some examples showing how visualzation can be seen on ECLiPSe 6.0?

You just need to add one line to your code, a call to viewable_create/2,3,4.
Here is a sudoku example:


% - Compile this code in tkeclipse.
% - Open "Visualisation Client" from the tools-menu.
% - Enter and run query solve(X).
% - Select "Text Table" viewer (should display the matrix with starting values).
% - Click "resume" (displays value propagation and final solution).
%
% To see propagation steps one-by-one:
% - Right-click for background menu
% - "Select all viewlets"
% - "Hold on updates"
% Rerun the problem, and keep clicking "resume".

:- lib(ic).

solve(Board) :-
	problem(Board),
	sudoku(3, Board).

sudoku(N, Board) :-
	N2 is N*N,
	dim(Board, [N2,N2]),
	Board[1..N2,1..N2] :: 1..N2,
	viewable:viewable_create(sudoku, Board),	%%% ADD THIS LINE %%%
	( for(I,1,N2), param(Board,N2) do
	    ic_global:alldifferent(Board[I,1..N2]),
	    ic_global:alldifferent(Board[1..N2,I])
	),
	( multifor([I,J],1,N2,N), param(Board,N) do
	    ic_global:alldifferent(flatten(Board[I..I+N-1,J..J+N-1]))
	),
	labeling(flatten(Board)).

problem([](
     [](_, 9, 8, _, _, _, _, _, _),
     [](_, _, _, _, 7, _, _, _, _),
     [](_, _, _, _, 1, 5, _, _, _),
     [](1, _, _, _, _, _, _, _, _),
     [](_, _, _, 2, _, _, _, _, 9),
     [](_, _, _, 9, _, 6, _, 8, 2),
     [](_, _, _, _, _, _, _, 3, _),
     [](5, _, 1, _, _, _, _, _, _),
     [](_, _, _, 4, _, _, _, 2, _))).


-- Joachim
Received on Mon Nov 24 2008 - 01:10:04 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 22 2024 - 18:13:20 CET