• 15 апреля стартует «Курс «SQL-injection Master» ©» от команды The Codeby

    За 3 месяца вы пройдете путь от начальных навыков работы с SQL-запросами к базам данных до продвинутых техник. Научитесь находить уязвимости связанные с базами данных, и внедрять произвольный SQL-код в уязвимые приложения.

    На последнюю неделю приходится экзамен, где нужно будет показать свои навыки, взломав ряд уязвимых учебных сайтов, и добыть флаги. Успешно сдавшие экзамен получат сертификат.

    Запись на курс до 25 апреля. Получить промодоступ ...

Pascal игра

  • Автор темы aud
  • Дата начала
A

aud

Добрый день, нужна помощь с исходником(скачаным) крестиков ноликов

Код:
<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">тут</div></div><div class="sp-body"><div class="sp-content">
Код:
program X_and_O;
uses crt;
var f : array[0..2,0..2] of integer;
game,pcalc,ccalc : word;
wv : integer;
p1,c1,xcur,ycur,sv,sv2,sv3,int,m,snd : byte;
com,p2,c2 : char;
move : boolean;
label start,plr_play,com_play,cp2,newgame,ng2,win,endgame;
begin
int:=1;
snd:=1;
p1:=10;
p2:='X';
c1:=14;
c2:='O';
randomize;
textbackground(2);
goto newgame;
{Na4alo igri}
start:
clrscr;
f[0,0]:=0;
f[0,1]:=0;
f[0,2]:=0;
f[1,0]:=0;
f[1,1]:=0;
f[1,2]:=0;
f[2,0]:=0;
f[2,1]:=0;
f[2,2]:=0;
textbackground(2);
clrscr;
textcolor(1);
gotoxy(3,4);
write('Igrok: 0  Komputer(');
case int of
0 : write('prof');
1 : write('norma');
2 : write('kretin');
end;
write('): 0');
gotoxy(3,5);
write('€Ја : 1');
textbackground(7);
textcolor(8);
gotoxy(1,1);
clreol;
write(#24#25#26#27,' >> dvizenije kursora  SPACE >> hod	1 >> novaja igra  2 >> ўл室	 ');
textbackground(2);
if move then goto plr_play else goto com_play;
{Hod igroka}

plr_play:
if (game=100) or (game=200) or (game=300) then goto endgame;
textcolor(1);
gotoxy(10,4);
write(pcalc);
gotoxy(24,4);
case int of
0 : write('prof');
1 : write('norma');
2 : write('kretin');
end;
write('): ');
write(ccalc);
gotoxy(9,5);
case game of
0..100 : wv:=100-game;
101..200 : wv:=200-game;
else wv:=300-game;
end;
write(game,'(do konca turinra ostalosj ',wv,' igr)');
gotoxy(35,10);
write('ЪДДДВДДДВДДДї');
gotoxy(35,11);
write('і  і  і  і');
gotoxy(35,12);
write('ГДДДЕДДДЕДДДґ');
gotoxy(35,13);
write('і  і  і  і');
gotoxy(35,14);
write('ГДДДЕДДДЕДДДґ');
gotoxy(35,15);
write('і  і  і  і');
gotoxy(35,16);
write('АДДДБДДДБДДДЩ');

sv:=0;
repeat
sv2:=f[trunc(sv/3),sv mod 3];
if sv2<>0 then
begin
gotoxy(trunc(sv/3)*4+37,(sv mod 3)*2+11);
if sv2=1 then begin textcolor(p1); write(p2); end else begin textcolor(c1); write(c2); end;
end;
sv:=sv+1;
until sv=9;
textcolor(5);
gotoxy(xcur*4+38,ycur*2+11);
write('');
sv:=0;
repeat
wv:=f[sv,0]+f[sv,1]+f[sv,2];
if (wv=3) or (wv=-3) then goto win;
wv:=f[0,sv]+f[1,sv]+f[2,sv];
if (wv=3) or (wv=-3) then goto win;
sv:=sv+1;
until sv=3;
wv:=f[0,0]+f[1,1]+f[2,2];
if (wv=3) or (wv=-3) then goto win;
wv:=f[2,0]+f[1,1]+f[0,2];
if (wv=3) or (wv=-3) then goto win;
if (f[0,0]<>0) and (f[0,1]<>0) and (f[0,2]<>0) and (f[1,0]<>0) and (f[1,1]<>0) and (f[1,2]<>0) and (f[2,0]<>0) and (f[2,1]<>0)
and (f[2,2]<>0) then
begin
sound(snd*1000);
f[0,0]:=0;
f[0,1]:=0;
f[0,2]:=0;
f[1,0]:=0;
f[1,1]:=0;
f[1,2]:=0;
f[2,0]:=0;
f[2,1]:=0;
f[2,2]:=0;
delay(snd*2000);
nosound;
gotoxy(8,8);
textcolor(14);
write('ЌЁзмп.	  ');
game:=game+1;
if move then move:=false else move:=true;
readkey;
gotoxy(8,8);
write('			 ');
if move then goto plr_play else goto com_play;
end;
com:=readkey;
case com of
'1' : goto newgame;
'2' : exit;
' ' : if f[xcur,ycur]=0 then begin f[xcur,ycur]:=1; goto com_play; end
else begin sound(snd*100); delay(snd*300); nosound; end;
#27 : exit;
#0 :
begin
com:=readkey;
case com of
#72 : if ycur>0 then ycur:=ycur-1;
#75 : if xcur>0 then xcur:=xcur-1;
#77 : if xcur<2 then xcur:=xcur+1;
#80 : if ycur<2 then ycur:=ycur+1;
end;
end;
end;
goto plr_play;
{Hod kompjutera}

com_play:
if (game=100) or (game=200) or (game=300) then goto endgame;
sv:=0;
repeat
sv2:=f[trunc(sv/3),sv mod 3];
if sv2<>0 then
begin
gotoxy(trunc(sv/3)*4+37,(sv mod 3)*2+11);
if sv2=1 then begin textcolor(p1); write(p2); end else begin textcolor(c1); write(c2); end;
end;
sv:=sv+1;
until sv=9;
sv:=0;
repeat
wv:=f[sv,0]+f[sv,1]+f[sv,2];
if (wv=3) or (wv=-3) then goto win;
wv:=f[0,sv]+f[1,sv]+f[2,sv];
if (wv=3) or (wv=-3) then goto win;
sv:=sv+1;
until sv=3;
wv:=f[0,0]+f[1,1]+f[2,2];
if (wv=3) or (wv=-3) then goto win;
wv:=f[2,0]+f[1,1]+f[0,2];
if (wv=3) or (wv=-3) then goto win;
if (f[0,0]<>0) and (f[0,1]<>0) and (f[0,2]<>0) and (f[1,0]<>0) and (f[1,1]<>0) and (f[1,2]<>0) and (f[2,0]<>0) and (f[2,1]<>0)
and (f[2,2]<>0) then goto plr_play;
if int=2 then goto cp2;
sv:=random(int+2);
if (sv=2) and (int<>0) then goto cp2;
if (f[1,1]=0) and (random(3)<>2) then begin f[1,1]:=-1; goto plr_play; end;
sv:=0;
repeat
if (f[sv,0]+f[sv,1]+f[sv,2]=2) or (f[sv,0]+f[sv,1]+f[sv,2]=-2) then
begin
sv2:=0;
repeat
if f[sv,sv2]=0 then f[sv,sv2]:=-1;
sv2:=sv2+1;
until sv2=3;
goto plr_play;
end;
if (f[0,sv]+f[1,sv]+f[2,sv]=2) or (f[0,sv]+f[1,sv]+f[2,sv]=-2) then
begin
sv2:=0;
repeat
if f[sv2,sv]=0 then f[sv2,sv]:=-1;
sv2:=sv2+1;
until sv2=3;
goto plr_play;
end;
sv:=sv+1;
until sv=3;
if (f[0,0]+f[1,1]+f[2,2]=2) or (f[0,0]+f[1,1]+f[2,2]=-2) then
begin
if f[0,0]=0 then f[0,0]:=-1;
if f[1,1]=0 then f[1,1]:=-1;
if f[2,2]=0 then f[2,2]:=-1;
goto plr_play;
end;
if (f[2,0]+f[1,1]+f[0,2]=2) or (f[2,0]+f[1,1]+f[0,2]=-2) then
begin
if f[2,0]=0 then f[2,0]:=-1;
if f[1,1]=0 then f[1,1]:=-1;
if f[0,2]=0 then f[0,2]:=-1;
goto plr_play;
end;
cp2:
repeat
sv:=random(10);
if f[trunc(sv/3),sv mod 3]=0 then begin f[trunc(sv/3),sv mod 3]:=-1; goto plr_play; end;
until sv=11;
goto plr_play;
{Nastrojki igri}
newgame:
clrscr;
textcolor(1);
write('  Nastrojki novoi igri');
gotoxy(4,7);
write('1 >> Intelekt komputera: ');
gotoxy(4,8);
write('2 >> Vi budete hotitj ');
gotoxy(4,11);
write('5 >> Pervij Hod');
gotoxy(4,12);
write('6 >> Zvuk');
gotoxy(4,16);
textcolor(1);
write('SPACE >> na4atj igru  esc >> vihod');
ng2:
textcolor(14);
gotoxy(31,7);
case int of
0 : write('profeccional');
1 : write('normalnij  ');
2 : write('kretin	 ');
end;
gotoxy(26,8);
if p2='X' then write('krestikom') else write('nolikom ');
gotoxy(20,11);
case m of
0 : write('slu4ajno ');
1 : write('vash	 ');
2 : write('komputera ');
end;
gotoxy(14,12);
if snd=1 then write('vklu4en ') else write('vikly4en');
gotoxy(4,9);
textcolor(p1);
write('3 >> Cvet vasej viski');
gotoxy(4,10);
textcolor(c1);
write('4 >> Cvet viski kompjutera');
com:=readkey;
case com of
'1' : if int>0 then dec(int) else int:=2;
'2' : if p2='X' then begin p2:='O'; c2:='X'; end else begin p2:='X'; c2:='O'; end;
'3' : begin if p1<15 then p1:=p1+1 else p1:=0; if p1=2 then p1:=3; end;
'4' : begin if c1<15 then c1:=c1+1 else c1:=0; if c1=2 then c1:=3; end;
'5' : if m<2 then m:=m+1 else m:=0;
'6' : if snd=1 then snd:=0 else snd:=1;
#27 : exit;
' ' :
begin
sv:=random(2);
case m of
0 : if sv<1 then move:=true else move:=false;
1 : move:=true;
2 : move:=false;
end;
game:=1;
pcalc:=0;
ccalc:=0;
goto start;
end;
end;
goto ng2;
{Pobeda}
win:
gotoxy(8,8);
clreol;
if wv=3 then begin pcalc:=pcalc+1; textcolor(4); write('Vi vijgrali!'); end
else begin textcolor(8); write('Vi proigrali.'); ccalc:=ccalc+1; end;
game:=game+1;
f[0,0]:=0;
f[0,1]:=0;
f[0,2]:=0;
f[1,0]:=0;
f[1,1]:=0;
f[1,2]:=0;
f[2,0]:=0;
f[2,1]:=0;
f[2,2]:=0;
sound(snd*500);
delay(snd*2000);
nosound;
delay(snd*1000);
sound(snd*500);
delay(snd*2000);
nosound;
readkey;
gotoxy(1,8);
clreol;
if move then move:=false else move:=true;
if move then goto plr_play else goto com_play;
{Okon4anije tornura}
endgame:
delay(6400);
while keypressed do readkey;
clrscr;
textcolor(7);
gotoxy(35,3);
if game<300 then write('’га­Ёа ®Є®­зҐ­.') else write('€Ја  ®Є®­зҐ­ .');
textcolor(5);
if pcalc>ccalc then begin gotoxy(15,6); write('‚л ўлЁЈа «Ё г Є®¬ЇмовҐа  б® бзс⮬ ',pcalc,':',ccalc,' Џ®§¤а ў«по!'); end;
if pcalc=ccalc then begin gotoxy(36,6); write('ЌЁзмп. ',pcalc,':',ccalc); end;
if pcalc<ccalc then begin gotoxy(15,6); write('‘®¦ «Ґо, ўл Їа®ЁЈа «Ё Є®¬ЇмовҐаг б® бзс⮬ ',pcalc,':',ccalc); end;
window(5,10,80,25);
textcolor(14);
write('”а®ўҐ­м Ё­вҐ««ҐЄв  Є®¬ЇмовҐа : ');
case int of
0 : writeln('Їа®дҐббЁ®­ «.');
1 : writeln('­®а¬ «м­л© ЁЈа®Є.');
2 : writeln('ЄаҐвЁ­.');
end;
writeln;
writeln('  ЋжҐ­Є  ў иЁе бЇ®б®Ў­®б⥩:');
writeln('ўлЁЈал襩: ',round(pcalc/game*100),'%');
writeln('Їа®ЁЈал襩: ',round(ccalc/game*100),'%');
writeln('ЁЈа ­  ­Ёзмо: ',100-round(pcalc/game*100)-round(ccalc/game*100),'%');
writeln;
writeln('‚ЇҐз в«Ґ­Ёп Є®¬ЇмовҐа  ® ў б Ё ®Ў ЁЈаҐ б ў ¬Ё:');
textcolor(4);
wv:=round(pcalc/game*100);
case int of
1 : dec(wv,-5);
2 : dec(wv,-10);
end;
case wv of
-10..-6 : write('"Ќг Ё в®а¬®§!"');
-5..0 : write('"‚®®ЎйҐ ­Ґ 㬥Ґв ЁЈа вм."');
1..10 : write('"ЌҐг¦Ґ«Ё Єв®-в® ЁЈа Ґв Ґйс е㦥?"');
11..20 : write('"’ҐЎҐ ­г¦­® е®а®иҐ­мЄ® Ї®в७Ёа®ў вмбп!"');
21..30 : write('"”ЁЈ®ў® ЁЈа Ґим."');
31..40 : write('"ЊпЈЄ® Ј®ў®ап, ­Ґ ®зҐ­м."');
41..50 : write('"ЌҐЇ«®е®, ­ҐЇ«®е®, ­® ¬®¦­® ­ ¬­®Ј® «гзиҐ."');
51..60 : write('"ЌҐЇ«®е®© १г«мв в. •®вп, Є®­Ґз­®, ¬®¦­® Ё Ї®«гзиҐ...');
61..70 : write('"•®а®и® ЁЈа Ґим!"');
71..80 : write('"Љ«сў® ЁЈа Ґим! ” ⥡п бЄ®«мЄ® ¬ҐЈ Ў ©в®ў Ї ¬пвЁ?"');
81..90 : write('"•®а®иЁ© १г«мв в! ќе, ¬­Ґ Ўл в Є..."');
91..97 : write('"Ћв«Ёз­ п ЁЈа !!!"');
98..100 : begin textcolor(6); write('"’л зв®, бгЇҐаЄ®¬ЇмовҐа?!"'); end;
end;
writeln;
writeln;
writeln;
textcolor(1);
if game<300 then write('Џа®ЎҐ« >> Їа®¤®«¦Ёвм ЁЈаг	esc >> ўл室') else write('Ќ ¦¬ЁвҐ «оЎго Є« ўЁиг ¤«п ўл室 .');
window(1,1,80,25);
if game<300 then
repeat
com:=readkey;
case com of
' ' : begin inc(game); if move then move:=false else move:=true; goto start; end;
#27 : exit;
end;
until com=#27
else
begin
readkey;
exit;
end;
window(1,1,80,25);
goto start;
end.

(целый код )

Проблема: когда ходит комп. или человек то сразуже вылетает эррор:
link removed
или
link removed
 
I

isqoff

может проще написать свой и не мучиться? :)
 
N

niello

Код, который ты написал ,я запустил, првада на VPascal, так как TurboPascal не было. Все работает, правда пришлось закоментировать sound и nosound так как я не знаю где они в VPascal.
 
G

Guest

<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">"Код"</div></div><div class="sp-body"><div class="sp-content">procedure TForm1.Panel1Click(Sender: TObject);
begin
if panel1.Caption='' then begin
panel1.Caption:='X';
button1.Click;
i:=0;
end;
end;

procedure TForm1.Panel2Click(Sender: TObject);
begin
if panel2.Caption='' then begin
panel2.Caption:='X';
button1.Click;
i:=0;
end;
end;

procedure TForm1.Panel3Click(Sender: TObject);
begin
if panel3.Caption='' then begin
panel3.Caption:='X';
button1.Click;
i:=0;
end;
end;

procedure TForm1.Panel4Click(Sender: TObject);
begin
if panel4.Caption='' then begin
panel4.Caption:='X';
button1.Click;
i:=0;
end;
end;

procedure TForm1.Panel5Click(Sender: TObject);
begin
if panel5.Caption='' then begin
panel5.Caption:='X';
button1.Click;
i:=0;
end;
end;

procedure TForm1.Panel6Click(Sender: TObject);
begin
if panel6.Caption='' then begin
panel6.Caption:='X';
button1.Click;
i:=0;
end;
end;

procedure TForm1.Panel7Click(Sender: TObject);
begin
if panel7.Caption='' then begin
panel7.Caption:='X';
button1.Click;
i:=0;
end;
end;

procedure TForm1.Panel8Click(Sender: TObject);
begin
if panel8.Caption='' then begin
panel8.Caption:='X';
button1.Click;
i:=0;
end;
end;

procedure TForm1.Panel9Click(Sender: TObject);
begin
if panel9.Caption='' then begin
panel9.Caption:='X';
button1.Click;
i:=0;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if i=0 then
repeat
/////////Блок определения выигрыша
if panel1.Caption='X' then
if panel2.Caption='X' then
if panel3.Caption='X' then begin
showmessage('Win');
b:=b+1;
button3.Click;
I:=1;
end;
if panel4.Caption='X' then
if panel5.Caption='X' then
if panel6.Caption='X' then begin
showmessage('Win');
b:=b+1;
button3.Click;
I:=1;
end;
if panel7.Caption='X' then
if panel8.Caption='X' then
if panel9.Caption='X' then begin
showmessage('Win');
b:=b+1;
button3.Click;
I:=1;
end;
if panel1.Caption='X' then
if panel5.Caption='X' then
if panel9.Caption='X' then begin
showmessage('Win');
b:=b+1;
button3.Click;
I:=1;
end;
if panel3.Caption='X' then
if panel5.Caption='X' then
if panel7.Caption='X' then begin
showmessage('Win');
b:=b+1;
button3.Click;
I:=1;
end;
if panel1.Caption='X' then
if panel4.Caption='X' then
if panel7.Caption='X' then begin
showmessage('Win');
b:=b+1;
button3.Click;
I:=1;
end;
if panel2.Caption='X' then
if panel5.Caption='X' then
if panel8.Caption='X' then begin
showmessage('Win');
b:=b+1;
button3.Click;
I:=1;
end;
if panel3.Caption='X' then
if panel6.Caption='X' then
if panel9.Caption='X' then begin
showmessage('Win');
b:=b+1;
button3.Click;
I:=1;
end;
//Strategy
////Dopolnit mod
if i=0 then
if panel1.Caption='X' then
if panel2.Caption='X' then
if panel3.Caption='' then begin
panel3.Caption:='O';
i:=1;
end;
if i=0 then
if panel1.Caption='X' then
if panel2.Caption='' then
if panel3.Caption='X' then begin
panel2.Caption:='O';
i:=1;
end;
if i=0 then
if panel1.Caption='' then
if panel2.Caption='X' then
if panel3.Caption='X' then begin
panel1.Caption:='O';
i:=1;
end;
if i=0 then
if panel4.Caption='X' then
if panel5.Caption='X' then
if panel6.Caption='' then begin
panel6.Caption:='O';
i:=1;
end;
if i=0 then
if panel4.Caption='X' then
if panel5.Caption='' then
if panel6.Caption='X' then begin
panel5.Caption:='O';
i:=1;
end;
if i=0 then
if panel4.Caption='' then
if panel5.Caption='X' then
if panel6.Caption='X' then begin
panel4.Caption:='O';
i:=1;
end;
if i=0 then
if panel7.Caption='X' then
if panel8.Caption='X' then
if panel9.Caption='' then begin
panel9.Caption:='O';
i:=1;
end;
if i=0 then
if panel7.Caption='X' then
if panel8.Caption='' then
if panel9.Caption='X' then begin
panel8.Caption:='O';
i:=1;
end;
if i=0 then
if panel7.Caption='' then
if panel8.Caption='X' then
if panel9.Caption='X' then begin
panel7.Caption:='O';
i:=1;
end;
if i=0 then
if panel1.Caption='X' then
if panel4.Caption='X' then
if panel7.Caption='' then begin
panel7.Caption:='O';
i:=1;
end;
if i=0 then
if panel1.Caption='X' then
if panel4.Caption='' then
if panel7.Caption='X' then begin
panel4.Caption:='O';
i:=1;
end;
if i=0 then
if panel1.Caption='' then
if panel4.Caption='X' then
if panel7.Caption='X' then begin
panel1.Caption:='O';
i:=1;
end;
if i=0 then
if panel2.Caption='X' then
if panel5.Caption='X' then
if panel8.Caption='' then begin
panel8.Caption:='O';
i:=1;
end;
if i=0 then
if panel2.Caption='X' then
if panel5.Caption='' then
if panel8.Caption='X' then begin
panel5.Caption:='O';
i:=1;
end;
if i=0 then
if panel2.Caption='' then
if panel5.Caption='X' then
if panel8.Caption='X' then begin
panel2.Caption:='O';
i:=1;
end;
if i=0 then
if panel3.Caption='X' then
if panel6.Caption='X' then
if panel9.Caption='' then begin
panel9.Caption:='O';
i:=1;
end;
if i=0 then
if panel3.Caption='X' then
if panel6.Caption='' then
if panel9.Caption='X' then begin
panel6.Caption:='O';
i:=1;
end;
if i=0 then
if panel3.Caption='' then
if panel6.Caption='X' then
if panel9.Caption='X' then begin
panel3.Caption:='O';
i:=1;
end;
if i=0 then
if panel1.Caption='X' then
if panel5.Caption='X' then
if panel9.Caption='' then begin
panel9.Caption:='O';
i:=1;
end;
if i=0 then
if panel1.Caption='X' then
if panel5.Caption='' then
if panel9.Caption='X' then begin
panel5.Caption:='O';
i:=1;
end;
if i=0 then
if panel1.Caption='' then
if panel5.Caption='X' then
if panel9.Caption='X' then begin
panel1.Caption:='O';
i:=1;
end;
if i=0 then
if panel3.Caption='X' then
if panel5.Caption='X' then
if panel7.Caption='' then begin
panel7.Caption:='O';
i:=1;
end;
if i=0 then
if panel3.Caption='X' then
if panel5.Caption='' then
if panel7.Caption='X' then begin
panel5.Caption:='O';
i:=1;
end;
if i=0 then
if panel3.Caption='' then
if panel5.Caption='X' then
if panel7.Caption='X' then begin
panel3.Caption:='O';
i:=1;
end;
/////////End mod



if i=0 then
if panel1.Caption='' then begin
a:=random(3);
if a=1 then begin
panel1.Caption:='O';
i:=1;
end;
/////////////////////////////////
end;
if i=0 then
if panel2.Caption='' then begin
a:=random(3);
if a=1 then begin
panel2.Caption:='O';
i:=1;
end;
end;
///////////////////////////////////
if i=0 then
if panel3.Caption='' then begin
a:=random(3);
if a=1 then begin
panel3.Caption:='O';
i:=1;
end;
end;
/////////////////////////////////////
if i=0 then
if panel4.Caption='' then begin
a:=random(3);
if a=1 then begin
panel4.Caption:='O';
i:=1;
end;
end;
///////////////////////////
if i=0 then
if panel5.Caption='' then begin
a:=random(3);
if a=1 then begin
panel5.Caption:='O';
i:=1;
end;
end;
///////////////////////////
if i=0 then
if panel6.Caption='' then begin
a:=random(3);
if a=1 then begin
panel6.Caption:='O';
i:=1;
end;
end;
////////////////////////////////
if i=0 then
if panel7.Caption='' then begin
a:=random(3);
if a=1 then begin
panel7.Caption:='O';
i:=1;
end;
end;
/////////////////////////////////
if i=0 then
if panel8.Caption='' then begin
a:=random(3);
if a=1 then begin
panel8.Caption:='O';
i:=1;
end;
end;
////////////////////////////////////
if i=0 then
if panel9.Caption='' then begin
a:=random(3);
if a=1 then begin
panel9.Caption:='O';
i:=1;
end;
end;

///////////Блок определения
//////////////выигрыша Comp
if panel1.Caption='O' then
if panel2.Caption='O' then
if panel3.Caption='O' then begin
showmessage('You Lost!');
c:=c+1;
button3.Click;
I:=1;
end;
if panel4.Caption='O' then
if panel5.Caption='O' then
if panel6.Caption='O' then begin
showmessage('You Lost!');
c:=c+1;
button3.Click;
I:=1;
end;
if panel7.Caption='O' then
if panel8.Caption='O' then
if panel9.Caption='O' then begin
showmessage('You Lost!');
c:=c+1;
button3.Click;
I:=1;
end;
if panel1.Caption='O' then
if panel5.Caption='O' then
if panel9.Caption='O' then begin
showmessage('You Lost!');
c:=c+1;
button3.Click;
I:=1;
end;
if panel3.Caption='O' then
if panel5.Caption='O' then
if panel7.Caption='O' then begin
showmessage('You Lost!');
c:=c+1;
button3.Click;
I:=1;
end;
if panel1.Caption='O' then
if panel4.Caption='O' then
if panel7.Caption='O' then begin
showmessage('You Lost!');
c:=c+1;
button3.Click;
I:=1;
end;
if panel2.Caption='O' then
if panel5.Caption='O' then
if panel8.Caption='O' then begin
showmessage('You Lost!');
c:=c+1;
button3.Click;
I:=1;
end;
if panel3.Caption='O' then
if panel6.Caption='O' then
if panel9.Caption='O' then begin
showmessage('You Lost!');
c:=c+1;
button3.Click;
I:=1;
end;

/////Блок определения
////Ничьиx
if panel1.Caption<>'' then
if panel2.Caption<>'' then
if panel3.Caption<>'' then
if panel4.Caption<>'' then
if panel5.Caption<>'' then
if panel6.Caption<>'' then
if panel7.Caption<>'' then
if panel8.Caption<>'' then
if panel9.Caption<>'' then begin
showmessage('Ничья!');
i:=1;
button3.Click;
end;
until i=1;

end;


procedure TForm1.Button3Click(Sender: TObject);
var x:integer;
begin
panel1.Caption:='';
panel2.Caption:='';
panel3.Caption:='';
panel4.Caption:='';
panel5.Caption:='';
panel6.Caption:='';
panel7.Caption:='';
panel8.Caption:='';
panel9.Caption:='';
label1.Caption:=inttostr:)D+' : '+inttostr©;
A:=random(2);
if a=1 then begin
x:=random(10);
if x=1 then
panel1.Caption:='O';
if x=2 then
panel2.Caption:='O';
if x=3 then
panel3.Caption:='O';
if x=4 then
panel4.Caption:='O';
if x=5 then
panel5.Caption:='O';
if x=6 then
panel6.Caption:='O';
if x=7 then
panel7.Caption:='O';
if x=8 then
panel8.Caption:='O';
if x=9 then
panel9.Caption:='O';
end;
end;Для образца нашел себе код в- озникли вопросы, если несложно - может кто нить посмотреть код и ответить мне на них ? дело в том что все стратегии (выигрыша/проигрыша/ничьи) ясны, но вот почему они хранятся в кнопке пока не ясно... и что значит
button3.Click;
I:=1;
 
N

niello

button3.Click; — это вроде как новая игра (все обнуляется рандомом заполняются поля). Это создано в виде события для кнопки наверно для того чтобы пользователь мог нажать кнопку и все начать сначала не ожидая конца.
А I — это переменная, что то типа ключа, по коду посмотрел вроде для того чтоб определить кто перед этим ходил.
 
G

Guest

Перед тем как комп ставит 0 нужно сделать задержку с помощью таймера, примерно секунда или 2, подскажите пожайлуста как )))
 
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!