{ Springerproblem im Schach               }
{ Autor: Dipl.-Ing. Thomas Speiser        }
{ Source from: http://Codes.TurboTools.de }

program Springer;
uses Crt;

const n = 8;

type  koor = record
      x,y: integer;
end;

var schach: array[1..n,1..n] of 0..1;
    old: array[1..n] of koor;
    x,y,xA,yA,i: integer;

procedure schach_brett_aufstellen;

procedure Jump(x1,y1: integer);
begin
inc(i);
gotoxy(x1,y1);write('X');
old[i].x:=x1; old[i].y:=y1;
end;

begin
i:=0;
for xA:=1 to n do
for yA:=1 to n do begin
TextColor(white);
if (x = xA) and (y = yA) then begin schach[x,y]:=1;
TextColor(yellow); end else schach[x,y]:=0;
gotoxy(xA,yA);write(schach[xA,yA]);
end;

TextColor(red);
{NORD-WEST-SPRUNG}
if (x-1 >= 1) and (y-2 >= 1) then jump(x-1,y-2);
{NORD-OST-SPRUNG}
if (x+1 <= n) and (y-2 >= 1) then jump(x+1,y-2);
{OST-NORD-SPRUNG}
if (x+2 <= n) and (y-1 >= 1) then jump(x+2,y-1);
{OST-SD-SPRUNG}
if (x+2 <= n) and (y+1 <= n) then jump(x+2,y+1);
{SD-OST-SPRUNG}
if (x+1 <= n) and (y+2 <= n) then jump(x+1,y+2);
{SD-WEST-SPRUNG}
if (x-1 >= 1) and (y+2 <= n) then jump(x-1,y+2);
{WEST-NORD-SPRUNG}
if (x-2 >= 1) and (y-1 >= 1) then jump(x-2,y-1);
{WEST-SD-SPRUNG}
if (x-2 >= 1) and (y+1 <= n) then jump(x-2,y+1);
randomize;
x:=old[random(i-1)+1].x; y:=old[random(i-1)+1].y;
gotoxy(x,y);write(i);
delay(1000);
end;

begin
ClrScr;
randomize;
x:=random(7)+1;
y:=random(7)+1;
repeat
schach_brett_aufstellen;
until keypressed;
end.