Tic tac toe in pascal by me
Iseng-iseng ga ada kerjaan, gimana cara nambahin pemain komputer ya?
program CaturJawa2player2009gilang;
uses
wincrt;
var
i:integer;
Papan:array [1..9] of char;
x:integer;
y:integer;
z:integer;
label
balik,balik1,balik2;
(*prosedur-prosedur*)
procedure kosong;
begin
for i:=1 to 9 do
papan[i]:=’_’;
end;
procedure cetak;
begin
for i:= 1 to 3 do
write(papan[i]);
writeln;
for i:= 4 to 6 do
write(papan[i]);
writeln;
for i:=7 to 9 do
write(papan[i]);
end;
procedure tulisx (x:integer);
begin
papan[X]:=’X’;
end;
procedure tulisy(y:integer);
begin
papan[y]:=’O’;
end;
begin
writeln(‘program tic-tac-toe’);
writeln(‘2009 by gilang’);
writeln(‘versi 0.1’);
kosong;
cetak;
z:= 0;
balik:
if odd(z) then
begin
writeln;
writeln(‘giliran anda, O!’);
balik2:
writeln(‘masukan nomor kotak’);
read(y);
tulisy(y);
cetak;
z:=z+1;
goto balik;
end
else
begin
writeln;
writeln(‘giliran anda,X!’);
balik1:
writeln(‘silahkan masukan nomor kotak’);
read(x);
tulisx(x);
cetak;
z:=z+1;
goto balik;
end;
end.