%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	Animated bubblesort by Atsushi Nakano.
%	Uses the library 'graphic' and works
% only with LMNtal Java.
% To terminate, kill the process.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

graphic.use.
go:-{window,position(0,0),size(500,500),name("window"),timer(50).

% the single rule for sorting
{name(_IN),size(_IS,10),$p},{name(_IN2),size(_IS2,10),$q} :-
	 _IN = _IN2 - 1  ,_IS > _IS2 | {name(_IN),size(_IS2,10),$p},{name(_IN2),size(_IS,10),$q}.

% elements
{name(0),position(0,0),size(290,10),draw,getpic("fillrect")},
{name(1),position(0,10),size(90,10),draw,getpic("fillrect")},
{name(2),position(0,20),size(120,10),draw,getpic("fillrect")},
{name(3),position(0,30),size(80,10),draw,getpic("fillrect")},
{name(4),position(0,40),size(160,10),draw,getpic("fillrect")},
{name(5),position(0,50),size(410,10),draw,getpic("fillrect")},
{name(6),position(0,60),size(70,10),draw,getpic("fillrect")},
{name(7),position(0,70),size(440,10),draw,getpic("fillrect")},
{name(8),position(0,80),size(190,10),draw,getpic("fillrect")},
{name(9),position(0,90),size(210,10),draw,getpic("fillrect")},
{name(10),position(0,100),size(400,10),draw,getpic("fillrect")},
{name(11),position(0,110),size(300,10),draw,getpic("fillrect")},
{name(12),position(0,120),size(420,10),draw,getpic("fillrect")},
{name(13),position(0,130),size(110,10),draw,getpic("fillrect")},
{name(14),position(0,140),size(170,10),draw,getpic("fillrect")},
{name(15),position(0,150),size(30,10),draw,getpic("fillrect")},
{name(16),position(0,160),size(250,10),draw,getpic("fillrect")},
{name(17),position(0,170),size(330,10),draw,getpic("fillrect")},
{name(18),position(0,180),size(430,10),draw,getpic("fillrect")},
{name(19),position(0,190),size(310,10),draw,getpic("fillrect")},
{name(20),position(0,200),size(380,10),draw,getpic("fillrect")},
{name(21),position(0,210),size(260,10),draw,getpic("fillrect")},
{name(22),position(0,220),size(100,10),draw,getpic("fillrect")},
{name(23),position(0,230),size(450,10),draw,getpic("fillrect")},
{name(24),position(0,240),size(340,10),draw,getpic("fillrect")},
{name(25),position(0,250),size(140,10),draw,getpic("fillrect")},
{name(26),position(0,260),size(220,10),draw,getpic("fillrect")},
{name(27),position(0,270),size(230,10),draw,getpic("fillrect")},
{name(28),position(0,280),size(60,10),draw,getpic("fillrect")},
{name(29),position(0,290),size(240,10),draw,getpic("fillrect")},
{name(30),position(0,300),size(20,10),draw,getpic("fillrect")},
{name(31),position(0,310),size(200,10),draw,getpic("fillrect")},
{name(32),position(0,320),size(40,10),draw,getpic("fillrect")},
{name(33),position(0,330),size(150,10),draw,getpic("fillrect")},
{name(34),position(0,340),size(320,10),draw,getpic("fillrect")},
{name(35),position(0,350),size(390,10),draw,getpic("fillrect")},
{name(36),position(0,360),size(50,10),draw,getpic("fillrect")},
{name(37),position(0,370),size(130,10),draw,getpic("fillrect")},
{name(38),position(0,380),size(180,10),draw,getpic("fillrect")},
{name(39),position(0,390),size(350,10),draw,getpic("fillrect")},
{name(40),position(0,400),size(280,10),draw,getpic("fillrect")},
{name(41),position(0,410),size(10,10),draw,getpic("fillrect")},
{name(42),position(0,420),size(270,10),draw,getpic("fillrect")},
{name(43),position(0,430),size(370,10),draw,getpic("fillrect")},
{name(44),position(0,440),size(360,10),draw,getpic("fillrect")}.

}.