1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
| program testando;
uses wincrt,
wingraph;
const h=16; v=16;
type tableau=array[1..2*h,1..2*v] of boolean;
var i,r,s:integer;
L:tableau;
procedure initialisation (var L:tableau; h,v:integer);
var x,r,s:integer;
begin
{Toutes les cellules à false}
for r:=1 to 2*h do
for s:=1 to 2*v do
begin L[r,s]:=false
end;
{Détermination de l'entree SW}
L[2,1]:=true
{ for r:=1 to 2*h do
for s:=1 to 2*v do
begin x:=random(2);
L[r,s]:=false;
if x=1
then L[r,s]:=true
end; }
{Toutes les cellules exterieurs à false}
{ for r:=1 to 2*h do
begin
L[r,1]:=false ;
L[r,2*v]:=false ;
end;
for s:=1 to 2*v do
begin
L[1,s]:=false ;
L[2*h,s]:=false ;
end; }
end;
procedure creation_du_chemin (var L:tableau); {ne fonctionne pas, erreur de raisonnement}
var a,b,x,i1,j1,i2,j2,i3,j3:integer;
begin a:=1;
b:=1;
begin if (a=1) and (b<>1)
then
begin
x:=random(3) ;
if x=0 then L[2*a-1,2*b]:= true else
if x=1 then L[2*a,2*b-1]:=true else
if x=2 then L[2*a,2*b]:=true ;
end
else if (a=1) and (b=1)
then
begin
x:=random(2) ;
if x=0 then L[2*a-1,2*b]:= true else
if x=1 then L[2*a,2*b]:=true;
end
else if (a<>1) and (b=1)
then
begin
x:=random(2) ;
if x=0 then L[2*a-1,2*b]:= true else
if x=1 then L[2*a,2*b]:=true else
if x=2 then L[2*a-1,2*b-1]:=true ;
end
else if (a<>0) and (b<>0)
then
begin
x:=random(3);
if x=0 then L[2*a-1,2*b]:= true else
if x=1 then L[2*a,2*b-1]:=true else
if x=2 then L[2*a,2*b]:=true else L[2*a-1,2*b-1]:=true;
end;
end;
end;
procedure representation (L:tableau);
var a,b,i1,j1,i2,j2,i3,j3,i4,j4:integer;
begin for a:= 1 to h do {scan horizontal sur les colonnes paires, S}
for b:= 1 to v do
begin i1:=2*a; j1:=2*b-1 ;
if L[i1,j1]=false
then segment(2*a-2,2*b-2,2*a,2*b-2);
end;
for a:= 1 to h do { scan horizontal sur les colonnes impaires, W}
for b:= 1 to v do
begin i2:=2*a-1; j2:=2*b-1 ;
if L[i2,j2]=false
then segment(2*a-2,2*b-2,2*a-2,2*b);
end;
for b:= 1 to v do { scan vertical sur les lignes impaires, E}
for a:= 1 to h do
begin i3:=2*a; j3:=2*b ;
if L[i3,j3]=false
then segment(2*a,2*b,2*a,2*b-2);
end;
for b:= 1 to v do { scan vertical sur les lignes paires, N }
for a:= 1 to h do
begin i4:=2*a-1; j4:=2*b ;
if L[i4,j4]=false
then segment(2*a-2,2*b,2*a,2*b);
end;
end;
begin debutgraphe;
echelle(-1,34,-1,34);
deplace(0,0);
initialisation(L,h,v);
creation_du_chemin(L);
representation(L) ;
fingraphe;
end. |
Partager