![]() CATEGORIES: BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism |
Randomize(sqr(sqr(dim)-1)-2);for i:=1 to dim do for j:=1 to dim do Case random(dim) mod 3 of 0: begin stars[i,j]:=true; M_Put(i,j,15,0,'*'); end; 1: M_Put(i,j,2,0,'+'); 2: M_Put(i,j,2,0,'x'); End; for k:=1 to dim*sqr(dim) do begin r:=random(dim*dim); i1:=i;j1:=j; i:=1 + r mod dim; j:=1 + r div dim; col:=(col+1) mod 11 ; if (random(10)<3) and stars[i,j] and not stars[i1,j1] then begin M_Put(i1,j1,color(col+1),33,'*'); if odd(random(10)) then key:='+' else key:='x'; M_Put(i,j,2,28-dim,key); End; if stars[i,j] then begin M_Put(i,j,color(col+1),20-dim,'*'); end; End; gotoxy(1,2*dim+9); End; Procedure NeoCherepashka; var i:byte; begin {yaksho projdemo Entire-riven...} if wrabbit then gotoxy(1,2*x+7) else gotoxy (1,x+4); TextBackGround(magenta); TextColor(white); M_Print_Z('" Iteracia - ot 4eloveka. '); delay(500); M_Print('Rekursia - ot Boga!!! "'); writeln; delay(2000); TextBackGround(black);TextColor(white); write(':-? '); j:=wherey; for i:=1 to 4 do begin Delay(400); gotoxy(1,j); If odd(i) then textcolor(black) else textcolor(white); write(':'); end;{for} Delay(2000); HideCursor; gotoxy(5,j); TextBackGround(white); textcolor(black); write(' Lo! You are Neo, indeed ? '); TextBackGround(black);delay(1000); Neo_Final; TextBackground(black);TextColor(black);ShowCursor; Delay(2000); gotoxy(70,j-1); CopyRight; Delay(3000);readkey; halt; End; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {obrannya shlahu 4erepashkou} Procedure FindingPath; Begin Repeat if wrabbit then iter:=iter-1;{wrabbit - pokazana tablyca, iter - kilkist sprob} i:=1;j:=1;sum:=a[1,1];textcolor(col); {---prohid matrici---} Repeat gotoxy(2*j,i+1);write(a[i,j]); case upcase(readkey) of {zbilshuemo sumu} 'R': if j<x then begin inc(j);inc(sum,a[i,j]) end; 'D': if i<x then begin inc(i);inc(sum,a[i,j]) end; End; gotoxy(1,x+2); writeln('Suma=',sum,' '); {vidslidkovuem sumu} until (i=x) and (j=x); {poky v kincevu tochku ne prypovzem} {write(chr(7));} gotoxy(2*x,x+1);write(a[x,x]); {------------------} WriteRezult; {efektyvnist` shlahu} {if col=3 then max:=limit; test final ***} if max=limit then begin {jaksho dosagaemo najkraschogo rezultatu...} hidecursor;delay(800);textcolor(yellow);write(' *TRUE*'); delay(800); BlinkMatrix; {vypadkova animacia vidgadanogo shlahu v matryci} gotoxy(1,x+3);TextColor(15); M_Print('Well, 4erepashka!!! Matrix is reloading'+ '..................................................'+ '..................................................'+ '..................................................'+ '..................................................'); if x<dim then M_Print('>') else begin M_Print('.'); gotoxy(80,x+5);showcursor;delay(4000); end;{if1} raize:=true; exit {idemo z procedury v sliduuchiy vymir} end; {if} {jaksho max ne dosjag, zalyshaemsa} col:=col mod 13 +1; if col=7 then inc(col); {zacikluem kolory, bez black=0, white=15, yellow=14; propuskaem i lightgray=7} TextColor(col); gotoxy(1,x+2); If not wrabbit then begin writeln; write('>>');delay(400); M_Print(' Try aGain?(y/n)'); yn:=readkey; {yaksho 4erepashka vtomleno kazhe 'No', vysylaem na dopomogu Bilogo Krolika z tablyceu najkraschih rezultativ} if upcase(yn)='N' then Begin wrabbit:=true; {*} Writeln; TextColor(yellow); M_Print('Matrix miss for you, 4erepashka.'); delay(100); M_Print(' Follow the ways of White Rabbit ');delay(300); TextColor(white); write('=:)'); readln; writeln; ShowMatrix(B,r); end; {if1} end;{if} TextColor(col); if wrabbit and (iter>0) then begin {krolik pokazav tablycu, i she e sproby} gotoxy(1,x+3); write('>>');delay(1000); M_Print(' Try ' + inttostr(iter)+' times ') End; until iter<=0; End; Procedure FindingPathBack; Begin i:=x;j:=x;sum:=a[x,x];textcolor(14); {---prohid matrici---} while (i>1) or (j>1) do Begin gotoxy(2*j,i+1);write(a[i,j]); Case upcase(readkey) of 'R','L': if j>1 then begin dec(j); inc(sum,a[i,j]) end; 'D','U': if i>1 then begin dec(i); inc(sum,a[i,j]) end; end; {case} gotoxy(1,x+2); writeln('Suma=',sum,' '); end;{while} gotoxy(2*j,i+1);write(a[i,j]); {--------------} WriteRezult; if max=limit then begin delay(1000); BlinkMatrix; gotoxy(1,x+3);TextColor(15); M_Print('Well, 4erepashka!!! Matrix is reloading'+ '..................................................'+ '..................................................'+ '..................................................'+ '..................................................'); if x<dim then M_Print('>') else begin M_Print('.'); gotoxy(80,x+5);showcursor;delay(4000) end; {if} raize:=true; {ostannja sproba: abo perehodym abo "Gamover"} End; End; {=============================================================================} Begin x:=2; {vymirnist} {1st time} clrscr; delay(3000); TextColor(yellow); M_Print('Cherepashka: find thy way thru Matrix >> ');delay(100); M_Print(' entry dimension (2..'+inttostr(dim-1)+'):'); TextColor(white); readln(x); {chytaemo pochatkovy vymir} delay(1000); if keypressed and (readkey=#13) then goto go1; Writeln; {-pravila igry-} M_Print_Light('~ Rekursyvna zadacha dynamichnogo programuvannja ~',3); M_Print_Light('Dana Matryca z cyframy',4); M_Print_Light('4erepashka povze z verhnogo livogo kuta v pravy nyzhnij (Right/Down),',5); M_Print_Light(' zbyrauchi bonusy/sumu projdenyh cyfr/ na shlahu.',6); M_Print_Light('Ji zadacha - zibraty MAXIMUM bonusiv. -> Ce perevodyt jj v nastupny vymir',7); M_Print_Light('Jaksho ne znahodytsa shlah, mozhe skorystatys dopomogou Bilogo Krolika',8); M_Print_Light('Vin obbigae Matrycu duzhe shvydko, i pamjatae najkrashu sumu kozhnoi klitinky',9); M_Print_Light('4erepashka tak ne zumie: vymir(+1) ->> dorig(*4)',10); M_Print_Light('Ale zi svojm 4erep-om i WR-matrix vona mozhe 100% znajty shlah',11); Writeln; {~pechenje sud`by)~} Repeat Date: 2015-12-24; view: 1031
|