Chắc suất Đại học top - Giữ chỗ ngay!! ĐĂNG BÀI NGAY để cùng trao đổi với các thành viên siêu nhiệt tình & dễ thương trên diễn đàn.
sau tổng cộng 68 ngày (tính cả phiên bản khác bị lỗi và đã bỏ, làm cái này trong 64 ngày) thì mình đã xong!
code:
(cái này bị lỗi)
làm rất lâu nên hi vọng không lỗi
(giờ mình lặn đây)
code:
Mã:
program cg2;
uses crt; //cot //hang
var qc, qcanmap: array [1..5] of array [1..5] of char;
qcvay2map, qcvay2map2: array [1..5] of array [1..5] of boolean;
c, h, cp, hp, cq, hq, cn, hn, cpx, hpx, cpd, hpd, dmd, i, j, l, s, e: byte;
ch: char;
hl, luotxanh, chonquan, thongso, doitrongtran, doishift, out, huongxanh, doip, autodoixanh: boolean;
vay1, an1: boolean;
procedure setting_reset;
begin
cpx:=3; hpx:=3; cpd:=3; hpd:=3; dmd:=12;
thongso:=false;
doitrongtran:=false;
doishift:=true;
doip:=true;
autodoixanh:= true;
out:=false;
vay1:= true;
an1:= true;
end;
procedure game_reset;
begin
cpx:=3; hpx:=3; cpd:=3; hpd:=3; dmd:=12;
luotxanh:=true;
huongxanh:=true;
qc[1][1]:='x'; qc[2][1]:='x'; qc[3][1]:='x'; qc[4][1]:='x'; qc[5][1]:='x';
qc[1][2]:='x'; qc[2][2]:=' '; qc[3][2]:=' '; qc[4][2]:=' '; qc[5][2]:='x';
qc[1][3]:='d'; qc[2][3]:=' '; qc[3][3]:=' '; qc[4][3]:=' '; qc[5][3]:='x';
qc[1][4]:='d'; qc[2][4]:=' '; qc[3][4]:=' '; qc[4][4]:=' '; qc[5][4]:='d';
qc[1][5]:='d'; qc[2][5]:='d'; qc[3][5]:='d'; qc[4][5]:='d'; qc[5][5]:='d';
end;
procedure TRUEreset;
begin
setting_reset;
game_reset;
end;
function lx: char;
begin
if luotxanh = true then lx:= 'x' else lx:= 'd'
end;
function nlx: char;
begin
if luotxanh = false then nlx:= 'x' else nlx:= 'd'
end;
procedure be_blk;
begin
textbackground(black);
end;
procedure be_yel;
begin
textbackground(yellow);
end;
procedure banco1;
begin
textcolor(white); be_blk;
clrscr;
for h := 1 to 21 do
for c := 1 to 21 do
begin
if ((c-1) mod 5 = 0) and ((h-1) mod 5 <> 0) then //
begin
gotoxy(c,h); //
write('|');
end; //
if ((h-1) mod 5 = 0) and ((c-1) mod 5 <> 0) then
begin //
gotoxy(c,h);
write('-'); //
end;
if (((c-2) mod 10 = 0) and ((h-2) mod 10 = 0)) or (((c-3) mod 10 = 0) and ((h-3) mod 10 = 0)) or //hien cac hinh ve tren ban co
(((c-4) mod 10 = 0) and ((h-4) mod 10 = 0)) or (((c-5) mod 10 = 0) and ((h-5) mod 10 = 0)) or
(((c-7) mod 10 = 0) and ((h-7) mod 10 = 0)) or (((c-8) mod 10 = 0) and ((h-8) mod 10 = 0)) or //
(((c-9) mod 10 = 0) and ((h-9) mod 10 = 0)) or ((c mod 10 = 0) and (h mod 10 = 0)) then
begin //
gotoxy(c,h);
write('\'); //
end;
if (((c-2) mod 10 = 0) and (h mod 10 = 0)) or (((c-3) mod 10 = 0) and ((h+1) mod 10 = 0)) or //
(((c-4) mod 10 = 0) and ((h+2) mod 10 = 0)) or (((c-5) mod 10 = 0) and ((h+3) mod 10 = 0)) or
(((c-7) mod 10 = 0) and ((h+5) mod 10 = 0)) or (((c-8) mod 10 = 0) and ((h+6) mod 10 = 0)) or //
(((c-9) mod 10 = 0) and ((h+7) mod 10 = 0)) or ((c mod 10 = 0) and ((h+8) mod 10 = 0)) then
begin //
gotoxy(c,h);
write('/'); //
end;
end;
end;
procedure banco2;
begin
for h:= 1 to 5 do
for c:= 1 to 5 do
begin
if huongxanh then
gotoxy(22-5*c+4,22-5*h+4)
else gotoxy(5*c-4,5*h-4);
if qc[c][h] = 'x' then textcolor(blue);
if qc[c][h] = 'd' then textcolor(red);
if qc[c][h] = ' ' then textcolor(white);
if ((c=cp) and (h=hp)) and ((c=cq) and (h=hq)) then textbackground(green);
if ((c=cp) and (h=hp)) and not((c=cq) and (h=hq)) then textbackground(yellow);
if not((c=cp) and (h=hp)) and ((c=cq) and (h=hq)) then textbackground(magenta);
if not((c=cp) and (h=hp)) and not((c=cq) and (h=hq)) then textbackground(black);
write('0');
end;
gotoxy(1,22);
textcolor(white);
be_blk;
if thongso then
writeln(cp, hp, '|',cq, hq, '|', cpx, hpx, '|', cpd, hpd, '|', lx, '|', dmd:3, '|', an1:5, '|', vay1:5, '|', doitrongtran:5, '|', doishift:5, '|', huongxanh:5, '|', doip:5, '|', autodoixanh:5)
else writeln(' ');
end;
procedure checkhl;
begin
hl:=true;
if (abs(cn-cq)>1) or (abs(hn-hq)>1) then hl:=false;
if (abs(cq-hq) mod 2 =1) and (abs(cn-hn) mod 2 =1) then hl:=false;
if hl = false then begin cn:=0; hn:=0; end;
end;
procedure anquan;
begin
for c:= 1 to 5 do
for h:= 1 to 5 do
qcanmap[c][h]:=' ';
if vay1 then
begin
if cn>2 then
if (qc[cn-2][hn]=lx) and (qc[cn-1][hn]=nlx) then qcanmap[cn-1][hn]:= '.'; //a
if cn<4 then
if (qc[cn+2][hn]=lx) and (qc[cn+1][hn]=nlx) then qcanmap[cn+1][hn]:= '.'; //d
if hn>2 then
if (qc[cn][hn-2]=lx) and (qc[cn][hn-1]=nlx) then qcanmap[cn][hn-1]:= '.'; //w //thang
if hn<4 then
if (qc[cn][hn+2]=lx) and (qc[cn][hn+1]=nlx) then qcanmap[cn][hn+1]:= '.'; //s
if abs(cn-hn) mod 2 = 0 then //cho vay cheo
begin //vay
if (cn>2) and (hn>2) then
if (qc[cn-2][hn-2]=lx) and (qc[cn-1][hn-1]=nlx) then qcanmap[cn-1][hn-1]:= '.'; //aw
if (cn>2) and (hn<4) then
if (qc[cn-2][hn+2]=lx) and (qc[cn-1][hn+1]=nlx) then qcanmap[cn-1][hn+1]:= '.'; //as
if (cn<4) and (hn>2) then //cheo
if (qc[cn+2][hn-2]=lx) and (qc[cn+1][hn-1]=nlx) then qcanmap[cn+1][hn-1]:= '.'; //dw
if (cn<4) and (hn<4) then
if (qc[cn+2][hn+2]=lx) and (qc[cn+1][hn+1]=nlx) then qcanmap[cn+1][hn+1]:= '.'; //ds
end;
end
else
begin
for c:= 1 to 5 do
for h:= 1 to 5 do
if qc[c][h] = ' ' then qcvay2map[c][h]:= true
else qcvay2map[c][h]:= false;
for j:= 1 to 25 do
begin;
{for c:= 1 to 4 do
for h:= 1 to 5 do
begin
if (qc[c][h] = lx) and (qc[c+1][h] = ' ') then qcvay2map[c][h]:= true;
if (qc[c+1][h] = lx) and (qc[c][h] = ' ') then qcvay2map[c+1][h]:= true;
end;
for c:= 1 to 5 do
for h:= 1 to 4 do
begin
if (qc[c][h] = lx) and (qc[c][h+1] = ' ') then qcvay2map[c][h]:= true;
if (qc[c][h+1] = lx) and (qc[c][h] = ' ') then qcvay2map[c][h+1]:= true;
end;
for i:= 1 to 4 do
begin
if (qc[i][i] = lx) and qcvay2map[i+1][i+1] then qcvay2map[i][i]:= true;
if (qc[i+1][i+1] = lx) and qcvay2map[i][i] then qcvay2map[i+1][i+1]:= true;
if (qc[6-i][i] = lx) and qcvay2map[5-i][i+1] then qcvay2map[6-i][i]:= true;
if (qc[5-i][i+1] = lx) and qcvay2map[6-i][i] then qcvay2map[5-i][i+1]:= true;
if (qc[i][(i+1) mod 4 + 1] = lx) and qcvay2map[i+1][(i+1) mod 4 + 2] then qcvay2map[i][(i+1) mod 4 + 1]:= true;
if (qc[i+1][(i+1) mod 4 + 2] = lx) and qcvay2map[i][(i+1) mod 4 + 1] then qcvay2map[i+1][(i+1) mod 4 + 2]:= true;
if (qc[i][5 - (i+1) mod 4] = lx) and qcvay2map[i+1][4 - (i+1) mod 4] then qcvay2map[i][5 - (i+1) mod 4]:= true;
if (qc[i+1][4 - (i+1) mod 4] = lx) and qcvay2map[i][5 - (i+1) mod 4] then qcvay2map[i+1][4 - (i+1) mod 4]:= true;
end;
for c:= 1 to 5 do
for h:= 1 to 5 do
begin
gotoxy(c+23,h);
if qcvay2map[c][h] then
write(0);
end;
readln;}
if (qc[1][1] = nlx) and qcvay2map[2][1] then qcvay2map[1][1]:= true;
if (qc[1][1] = nlx) and qcvay2map[1][2] then qcvay2map[1][1]:= true;
if (qc[1][1] = nlx) and qcvay2map[2][2] then qcvay2map[1][1]:= true;
if (qc[1][2] = nlx) and qcvay2map[2][2] then qcvay2map[1][2]:= true;
if (qc[1][2] = nlx) and qcvay2map[1][3] then qcvay2map[1][2]:= true;
if (qc[1][2] = nlx) and qcvay2map[1][1] then qcvay2map[1][2]:= true;
if (qc[1][3] = nlx) and qcvay2map[2][3] then qcvay2map[1][3]:= true;
if (qc[1][3] = nlx) and qcvay2map[1][4] then qcvay2map[1][3]:= true;
if (qc[1][3] = nlx) and qcvay2map[1][2] then qcvay2map[1][3]:= true;
if (qc[1][3] = nlx) and qcvay2map[2][4] then qcvay2map[1][3]:= true;
if (qc[1][3] = nlx) and qcvay2map[2][2] then qcvay2map[1][3]:= true;
if (qc[1][4] = nlx) and qcvay2map[2][4] then qcvay2map[1][4]:= true;
if (qc[1][4] = nlx) and qcvay2map[1][5] then qcvay2map[1][4]:= true;
if (qc[1][4] = nlx) and qcvay2map[1][3] then qcvay2map[1][4]:= true;
if (qc[1][5] = nlx) and qcvay2map[2][5] then qcvay2map[1][5]:= true;
if (qc[1][5] = nlx) and qcvay2map[1][4] then qcvay2map[1][5]:= true;
if (qc[1][5] = nlx) and qcvay2map[2][4] then qcvay2map[1][5]:= true;
if (qc[2][1] = nlx) and qcvay2map[3][1] then qcvay2map[2][1]:= true;
if (qc[2][1] = nlx) and qcvay2map[1][1] then qcvay2map[2][1]:= true;
if (qc[2][1] = nlx) and qcvay2map[2][2] then qcvay2map[2][1]:= true;
if (qc[2][2] = nlx) and qcvay2map[3][2] then qcvay2map[2][2]:= true;
if (qc[2][2] = nlx) and qcvay2map[1][2] then qcvay2map[2][2]:= true;
if (qc[2][2] = nlx) and qcvay2map[2][3] then qcvay2map[2][2]:= true;
if (qc[2][2] = nlx) and qcvay2map[2][1] then qcvay2map[2][2]:= true;
if (qc[2][2] = nlx) and qcvay2map[3][3] then qcvay2map[2][2]:= true;
if (qc[2][2] = nlx) and qcvay2map[1][3] then qcvay2map[2][2]:= true;
if (qc[2][2] = nlx) and qcvay2map[3][1] then qcvay2map[2][2]:= true;
if (qc[2][2] = nlx) and qcvay2map[1][1] then qcvay2map[2][2]:= true;
if (qc[2][3] = nlx) and qcvay2map[3][3] then qcvay2map[2][3]:= true;
if (qc[2][3] = nlx) and qcvay2map[1][3] then qcvay2map[2][3]:= true;
if (qc[2][3] = nlx) and qcvay2map[2][4] then qcvay2map[2][3]:= true;
if (qc[2][3] = nlx) and qcvay2map[2][2] then qcvay2map[2][3]:= true;
if (qc[2][4] = nlx) and qcvay2map[3][4] then qcvay2map[2][4]:= true;
if (qc[2][4] = nlx) and qcvay2map[1][4] then qcvay2map[2][4]:= true;
if (qc[2][4] = nlx) and qcvay2map[2][5] then qcvay2map[2][4]:= true;
if (qc[2][4] = nlx) and qcvay2map[2][3] then qcvay2map[2][4]:= true;
if (qc[2][4] = nlx) and qcvay2map[3][5] then qcvay2map[2][4]:= true;
if (qc[2][4] = nlx) and qcvay2map[1][5] then qcvay2map[2][4]:= true;
if (qc[2][4] = nlx) and qcvay2map[3][3] then qcvay2map[2][4]:= true;
if (qc[2][4] = nlx) and qcvay2map[1][3] then qcvay2map[2][4]:= true;
if (qc[2][5] = nlx) and qcvay2map[3][5] then qcvay2map[2][5]:= true;
if (qc[2][5] = nlx) and qcvay2map[1][5] then qcvay2map[2][5]:= true;
if (qc[2][5] = nlx) and qcvay2map[2][4] then qcvay2map[2][5]:= true;
if (qc[3][1] = nlx) and qcvay2map[4][1] then qcvay2map[3][1]:= true;
if (qc[3][1] = nlx) and qcvay2map[2][1] then qcvay2map[3][1]:= true;
if (qc[3][1] = nlx) and qcvay2map[3][2] then qcvay2map[3][1]:= true;
if (qc[3][1] = nlx) and qcvay2map[4][2] then qcvay2map[3][1]:= true;
if (qc[3][1] = nlx) and qcvay2map[2][2] then qcvay2map[3][1]:= true;
if (qc[3][2] = nlx) and qcvay2map[4][2] then qcvay2map[3][2]:= true;
if (qc[3][2] = nlx) and qcvay2map[2][2] then qcvay2map[3][2]:= true;
if (qc[3][2] = nlx) and qcvay2map[3][3] then qcvay2map[3][2]:= true;
if (qc[3][2] = nlx) and qcvay2map[3][1] then qcvay2map[3][2]:= true;
if (qc[3][3] = nlx) and qcvay2map[4][3] then qcvay2map[3][3]:= true;
if (qc[3][3] = nlx) and qcvay2map[2][3] then qcvay2map[3][3]:= true;
if (qc[3][3] = nlx) and qcvay2map[3][4] then qcvay2map[3][3]:= true;
if (qc[3][3] = nlx) and qcvay2map[3][2] then qcvay2map[3][3]:= true;
if (qc[3][3] = nlx) and qcvay2map[4][4] then qcvay2map[3][3]:= true;
if (qc[3][3] = nlx) and qcvay2map[2][4] then qcvay2map[3][3]:= true;
if (qc[3][3] = nlx) and qcvay2map[4][2] then qcvay2map[3][3]:= true;
if (qc[3][3] = nlx) and qcvay2map[2][2] then qcvay2map[3][3]:= true;
if (qc[3][4] = nlx) and qcvay2map[4][4] then qcvay2map[3][4]:= true;
if (qc[3][4] = nlx) and qcvay2map[2][4] then qcvay2map[3][4]:= true;
if (qc[3][4] = nlx) and qcvay2map[3][5] then qcvay2map[3][4]:= true;
if (qc[3][4] = nlx) and qcvay2map[3][3] then qcvay2map[3][4]:= true;
if (qc[3][5] = nlx) and qcvay2map[4][5] then qcvay2map[3][5]:= true;
if (qc[3][5] = nlx) and qcvay2map[2][5] then qcvay2map[3][5]:= true;
if (qc[3][5] = nlx) and qcvay2map[3][4] then qcvay2map[3][5]:= true;
if (qc[3][5] = nlx) and qcvay2map[4][4] then qcvay2map[3][5]:= true;
if (qc[3][5] = nlx) and qcvay2map[2][4] then qcvay2map[3][5]:= true;
if (qc[4][1] = nlx) and qcvay2map[5][1] then qcvay2map[4][1]:= true;
if (qc[4][1] = nlx) and qcvay2map[3][1] then qcvay2map[4][1]:= true;
if (qc[4][1] = nlx) and qcvay2map[4][2] then qcvay2map[4][1]:= true;
if (qc[4][2] = nlx) and qcvay2map[5][2] then qcvay2map[4][2]:= true;
if (qc[4][2] = nlx) and qcvay2map[3][2] then qcvay2map[4][2]:= true;
if (qc[4][2] = nlx) and qcvay2map[4][3] then qcvay2map[4][2]:= true;
if (qc[4][2] = nlx) and qcvay2map[4][1] then qcvay2map[4][2]:= true;
if (qc[4][2] = nlx) and qcvay2map[5][3] then qcvay2map[4][2]:= true;
if (qc[4][2] = nlx) and qcvay2map[3][3] then qcvay2map[4][2]:= true;
if (qc[4][2] = nlx) and qcvay2map[5][1] then qcvay2map[4][2]:= true;
if (qc[4][2] = nlx) and qcvay2map[3][1] then qcvay2map[4][2]:= true;
if (qc[4][3] = nlx) and qcvay2map[5][3] then qcvay2map[4][3]:= true;
if (qc[4][3] = nlx) and qcvay2map[3][3] then qcvay2map[4][3]:= true;
if (qc[4][3] = nlx) and qcvay2map[4][4] then qcvay2map[4][3]:= true;
if (qc[4][3] = nlx) and qcvay2map[4][2] then qcvay2map[4][3]:= true;
if (qc[4][4] = nlx) and qcvay2map[5][4] then qcvay2map[4][4]:= true;
if (qc[4][4] = nlx) and qcvay2map[3][4] then qcvay2map[4][4]:= true;
if (qc[4][4] = nlx) and qcvay2map[4][5] then qcvay2map[4][4]:= true;
if (qc[4][4] = nlx) and qcvay2map[4][3] then qcvay2map[4][4]:= true;
if (qc[4][4] = nlx) and qcvay2map[5][5] then qcvay2map[4][4]:= true;
if (qc[4][4] = nlx) and qcvay2map[3][5] then qcvay2map[4][4]:= true;
if (qc[4][4] = nlx) and qcvay2map[5][3] then qcvay2map[4][4]:= true;
if (qc[4][4] = nlx) and qcvay2map[3][3] then qcvay2map[4][4]:= true;
if (qc[4][5] = nlx) and qcvay2map[5][5] then qcvay2map[4][5]:= true;
if (qc[4][5] = nlx) and qcvay2map[3][5] then qcvay2map[4][5]:= true;
if (qc[4][5] = nlx) and qcvay2map[4][4] then qcvay2map[4][5]:= true;
if (qc[5][1] = nlx) and qcvay2map[4][1] then qcvay2map[5][1]:= true;
if (qc[5][1] = nlx) and qcvay2map[5][2] then qcvay2map[5][1]:= true;
if (qc[5][1] = nlx) and qcvay2map[4][2] then qcvay2map[5][1]:= true;
if (qc[5][2] = nlx) and qcvay2map[4][2] then qcvay2map[5][2]:= true;
if (qc[5][2] = nlx) and qcvay2map[5][3] then qcvay2map[5][2]:= true;
if (qc[5][2] = nlx) and qcvay2map[5][1] then qcvay2map[5][2]:= true;
if (qc[5][3] = nlx) and qcvay2map[4][3] then qcvay2map[5][3]:= true;
if (qc[5][3] = nlx) and qcvay2map[5][4] then qcvay2map[5][3]:= true;
if (qc[5][3] = nlx) and qcvay2map[5][2] then qcvay2map[5][3]:= true;
if (qc[5][3] = nlx) and qcvay2map[4][4] then qcvay2map[5][3]:= true;
if (qc[5][3] = nlx) and qcvay2map[4][2] then qcvay2map[5][3]:= true;
if (qc[5][4] = nlx) and qcvay2map[4][4] then qcvay2map[5][4]:= true;
if (qc[5][4] = nlx) and qcvay2map[5][5] then qcvay2map[5][4]:= true;
if (qc[5][4] = nlx) and qcvay2map[5][3] then qcvay2map[5][4]:= true;
if (qc[5][5] = nlx) and qcvay2map[4][5] then qcvay2map[5][5]:= true;
if (qc[5][5] = nlx) and qcvay2map[5][4] then qcvay2map[5][5]:= true;
if (qc[5][5] = nlx) and qcvay2map[4][4] then qcvay2map[5][5]:= true;
end; //liet ke cac o bi vay (1)
for c:= 1 to 5 do
for h:= 1 to 5 do
begin
if qc[c][h] <> lx then qcvay2map[c][h]:= not qcvay2map[c][h];
qcvay2map2[c][h]:=false;
end;
qcvay2map2[cn][hn]:=true;
for j:= 1 to 25 do
begin
if qcvay2map[1][1] and qcvay2map2[2][1] then qcvay2map2[1][1]:= true;
if qcvay2map[1][1] and qcvay2map2[1][2] then qcvay2map2[1][1]:= true;
if qcvay2map[1][1] and qcvay2map2[2][2] then qcvay2map2[1][1]:= true;
if qcvay2map[1][2] and qcvay2map2[2][2] then qcvay2map2[1][2]:= true;
if qcvay2map[1][2] and qcvay2map2[1][3] then qcvay2map2[1][2]:= true;
if qcvay2map[1][2] and qcvay2map2[1][1] then qcvay2map2[1][2]:= true;
if qcvay2map[1][3] and qcvay2map2[2][3] then qcvay2map2[1][3]:= true;
if qcvay2map[1][3] and qcvay2map2[1][4] then qcvay2map2[1][3]:= true;
if qcvay2map[1][3] and qcvay2map2[1][2] then qcvay2map2[1][3]:= true;
if qcvay2map[1][3] and qcvay2map2[2][4] then qcvay2map2[1][3]:= true;
if qcvay2map[1][3] and qcvay2map2[2][2] then qcvay2map2[1][3]:= true;
if qcvay2map[1][4] and qcvay2map2[2][4] then qcvay2map2[1][4]:= true;
if qcvay2map[1][4] and qcvay2map2[1][5] then qcvay2map2[1][4]:= true;
if qcvay2map[1][4] and qcvay2map2[1][3] then qcvay2map2[1][4]:= true;
if qcvay2map[1][5] and qcvay2map2[2][5] then qcvay2map2[1][5]:= true;
if qcvay2map[1][5] and qcvay2map2[1][4] then qcvay2map2[1][5]:= true;
if qcvay2map[1][5] and qcvay2map2[2][4] then qcvay2map2[1][5]:= true;
if qcvay2map[2][1] and qcvay2map2[3][1] then qcvay2map2[2][1]:= true;
if qcvay2map[2][1] and qcvay2map2[1][1] then qcvay2map2[2][1]:= true;
if qcvay2map[2][1] and qcvay2map2[2][2] then qcvay2map2[2][1]:= true;
if qcvay2map[2][2] and qcvay2map2[3][2] then qcvay2map2[2][2]:= true;
if qcvay2map[2][2] and qcvay2map2[1][2] then qcvay2map2[2][2]:= true;
if qcvay2map[2][2] and qcvay2map2[2][3] then qcvay2map2[2][2]:= true;
if qcvay2map[2][2] and qcvay2map2[2][1] then qcvay2map2[2][2]:= true;
if qcvay2map[2][2] and qcvay2map2[3][3] then qcvay2map2[2][2]:= true;
if qcvay2map[2][2] and qcvay2map2[1][3] then qcvay2map2[2][2]:= true;
if qcvay2map[2][2] and qcvay2map2[3][1] then qcvay2map2[2][2]:= true;
if qcvay2map[2][2] and qcvay2map2[1][1] then qcvay2map2[2][2]:= true;
if qcvay2map[2][3] and qcvay2map2[3][3] then qcvay2map2[2][3]:= true;
if qcvay2map[2][3] and qcvay2map2[1][3] then qcvay2map2[2][3]:= true;
if qcvay2map[2][3] and qcvay2map2[2][4] then qcvay2map2[2][3]:= true;
if qcvay2map[2][3] and qcvay2map2[2][2] then qcvay2map2[2][3]:= true;
if qcvay2map[2][4] and qcvay2map2[3][4] then qcvay2map2[2][4]:= true;
if qcvay2map[2][4] and qcvay2map2[1][4] then qcvay2map2[2][4]:= true;
if qcvay2map[2][4] and qcvay2map2[2][5] then qcvay2map2[2][4]:= true;
if qcvay2map[2][4] and qcvay2map2[2][3] then qcvay2map2[2][4]:= true;
if qcvay2map[2][4] and qcvay2map2[3][5] then qcvay2map2[2][4]:= true;
if qcvay2map[2][4] and qcvay2map2[1][5] then qcvay2map2[2][4]:= true;
if qcvay2map[2][4] and qcvay2map2[3][3] then qcvay2map2[2][4]:= true;
if qcvay2map[2][4] and qcvay2map2[1][3] then qcvay2map2[2][4]:= true;
if qcvay2map[2][5] and qcvay2map2[3][5] then qcvay2map2[2][5]:= true;
if qcvay2map[2][5] and qcvay2map2[1][5] then qcvay2map2[2][5]:= true;
if qcvay2map[2][5] and qcvay2map2[2][4] then qcvay2map2[2][5]:= true;
if qcvay2map[3][1] and qcvay2map2[4][1] then qcvay2map2[3][1]:= true;
if qcvay2map[3][1] and qcvay2map2[2][1] then qcvay2map2[3][1]:= true;
if qcvay2map[3][1] and qcvay2map2[3][2] then qcvay2map2[3][1]:= true;
if qcvay2map[3][1] and qcvay2map2[4][2] then qcvay2map2[3][1]:= true;
if qcvay2map[3][1] and qcvay2map2[2][2] then qcvay2map2[3][1]:= true;
if qcvay2map[3][2] and qcvay2map2[4][2] then qcvay2map2[3][2]:= true;
if qcvay2map[3][2] and qcvay2map2[2][2] then qcvay2map2[3][2]:= true;
if qcvay2map[3][2] and qcvay2map2[3][3] then qcvay2map2[3][2]:= true;
if qcvay2map[3][2] and qcvay2map2[3][1] then qcvay2map2[3][2]:= true;
if qcvay2map[3][3] and qcvay2map2[4][3] then qcvay2map2[3][3]:= true;
if qcvay2map[3][3] and qcvay2map2[2][3] then qcvay2map2[3][3]:= true;
if qcvay2map[3][3] and qcvay2map2[3][4] then qcvay2map2[3][3]:= true;
if qcvay2map[3][3] and qcvay2map2[3][2] then qcvay2map2[3][3]:= true;
if qcvay2map[3][3] and qcvay2map2[4][4] then qcvay2map2[3][3]:= true;
if qcvay2map[3][3] and qcvay2map2[2][4] then qcvay2map2[3][3]:= true;
if qcvay2map[3][3] and qcvay2map2[4][2] then qcvay2map2[3][3]:= true;
if qcvay2map[3][3] and qcvay2map2[2][2] then qcvay2map2[3][3]:= true;
if qcvay2map[3][4] and qcvay2map2[4][4] then qcvay2map2[3][4]:= true;
if qcvay2map[3][4] and qcvay2map2[2][4] then qcvay2map2[3][4]:= true;
if qcvay2map[3][4] and qcvay2map2[3][5] then qcvay2map2[3][4]:= true;
if qcvay2map[3][4] and qcvay2map2[3][3] then qcvay2map2[3][4]:= true;
if qcvay2map[3][5] and qcvay2map2[4][5] then qcvay2map2[3][5]:= true;
if qcvay2map[3][5] and qcvay2map2[2][5] then qcvay2map2[3][5]:= true;
if qcvay2map[3][5] and qcvay2map2[3][4] then qcvay2map2[3][5]:= true;
if qcvay2map[3][5] and qcvay2map2[4][4] then qcvay2map2[3][5]:= true;
if qcvay2map[3][5] and qcvay2map2[2][4] then qcvay2map2[3][5]:= true;
if qcvay2map[4][1] and qcvay2map2[5][1] then qcvay2map2[4][1]:= true;
if qcvay2map[4][1] and qcvay2map2[3][1] then qcvay2map2[4][1]:= true;
if qcvay2map[4][1] and qcvay2map2[4][2] then qcvay2map2[4][1]:= true;
if qcvay2map[4][2] and qcvay2map2[5][2] then qcvay2map2[4][2]:= true;
if qcvay2map[4][2] and qcvay2map2[3][2] then qcvay2map2[4][2]:= true;
if qcvay2map[4][2] and qcvay2map2[4][3] then qcvay2map2[4][2]:= true;
if qcvay2map[4][2] and qcvay2map2[4][1] then qcvay2map2[4][2]:= true;
if qcvay2map[4][2] and qcvay2map2[5][3] then qcvay2map2[4][2]:= true;
if qcvay2map[4][2] and qcvay2map2[3][3] then qcvay2map2[4][2]:= true;
if qcvay2map[4][2] and qcvay2map2[5][1] then qcvay2map2[4][2]:= true;
if qcvay2map[4][2] and qcvay2map2[3][1] then qcvay2map2[4][2]:= true;
if qcvay2map[4][3] and qcvay2map2[5][3] then qcvay2map2[4][3]:= true;
if qcvay2map[4][3] and qcvay2map2[3][3] then qcvay2map2[4][3]:= true;
if qcvay2map[4][3] and qcvay2map2[4][4] then qcvay2map2[4][3]:= true;
if qcvay2map[4][3] and qcvay2map2[4][2] then qcvay2map2[4][3]:= true;
if qcvay2map[4][4] and qcvay2map2[5][4] then qcvay2map2[4][4]:= true;
if qcvay2map[4][4] and qcvay2map2[3][4] then qcvay2map2[4][4]:= true;
if qcvay2map[4][4] and qcvay2map2[4][5] then qcvay2map2[4][4]:= true;
if qcvay2map[4][4] and qcvay2map2[4][3] then qcvay2map2[4][4]:= true;
if qcvay2map[4][4] and qcvay2map2[5][5] then qcvay2map2[4][4]:= true;
if qcvay2map[4][4] and qcvay2map2[3][5] then qcvay2map2[4][4]:= true;
if qcvay2map[4][4] and qcvay2map2[5][3] then qcvay2map2[4][4]:= true;
if qcvay2map[4][4] and qcvay2map2[3][3] then qcvay2map2[4][4]:= true;
if qcvay2map[4][5] and qcvay2map2[5][5] then qcvay2map2[4][5]:= true;
if qcvay2map[4][5] and qcvay2map2[3][5] then qcvay2map2[4][5]:= true;
if qcvay2map[4][5] and qcvay2map2[4][4] then qcvay2map2[4][5]:= true;
if qcvay2map[5][1] and qcvay2map2[4][1] then qcvay2map2[5][1]:= true;
if qcvay2map[5][1] and qcvay2map2[5][2] then qcvay2map2[5][1]:= true;
if qcvay2map[5][1] and qcvay2map2[4][2] then qcvay2map2[5][1]:= true;
if qcvay2map[5][2] and qcvay2map2[4][2] then qcvay2map2[5][2]:= true;
if qcvay2map[5][2] and qcvay2map2[5][3] then qcvay2map2[5][2]:= true;
if qcvay2map[5][2] and qcvay2map2[5][1] then qcvay2map2[5][2]:= true;
if qcvay2map[5][3] and qcvay2map2[4][3] then qcvay2map2[5][3]:= true;
if qcvay2map[5][3] and qcvay2map2[5][4] then qcvay2map2[5][3]:= true;
if qcvay2map[5][3] and qcvay2map2[5][2] then qcvay2map2[5][3]:= true;
if qcvay2map[5][3] and qcvay2map2[4][4] then qcvay2map2[5][3]:= true;
if qcvay2map[5][3] and qcvay2map2[4][2] then qcvay2map2[5][3]:= true;
if qcvay2map[5][4] and qcvay2map2[4][4] then qcvay2map2[5][4]:= true;
if qcvay2map[5][4] and qcvay2map2[5][5] then qcvay2map2[5][4]:= true;
if qcvay2map[5][4] and qcvay2map2[5][3] then qcvay2map2[5][4]:= true;
if qcvay2map[5][5] and qcvay2map2[4][5] then qcvay2map2[5][5]:= true;
if qcvay2map[5][5] and qcvay2map2[5][4] then qcvay2map2[5][5]:= true;
if qcvay2map[5][5] and qcvay2map2[4][4] then qcvay2map2[5][5]:= true;
end; //liet ke cac o bi vay 2
qcvay2map2[cn][hn]:=false;
for c:= 1 to 5 do
for h:= 1 to 5 do
if qcvay2map2[c][h] then qcanmap[c][h]:='.';
end;
if (cn<>1) and (cn<>5) then
if (qc[cn-1][hn]=nlx) and (qc[cn+1][hn]=nlx) then begin qcanmap[cn-1][hn]:='.'; qcanmap[cn+1][hn]:='.'; end; //ngang
if (hn<>1) and (hn<>5) then
if (qc[cn][hn-1]=nlx) and (qc[cn][hn+1]=nlx) then begin qcanmap[cn][hn-1]:='.'; qcanmap[cn][hn+1]:='.'; end; //doc
if (cn<>1) and (cn<>5) and (hn<>1) and (hn<>5) and (abs(cn-hn) mod 2 = 0) then
begin
if (qc[cn-1][hn-1]=nlx) and (qc[cn+1][hn+1]=nlx) then begin qcanmap[cn-1][hn-1]:='.'; qcanmap[cn+1][hn+1]:='.'; end;
if (qc[cn-1][hn+1]=nlx) and (qc[cn+1][hn-1]=nlx) then begin qcanmap[cn-1][hn+1]:='.'; qcanmap[cn+1][hn-1]:='.'; end;
end;
for c:= 1 to 5 do
for h:= 1 to 5 do
if qcanmap[c][h]='.' then
if an1 then qc[c][h]:=lx
else qc[c][h]:=' ';
end;
function check(_cp,_hp,_cn,_hn:byte): byte;
begin
if (qc[_cp][_hp] = lx) and (qc[_cn][_hn] = ' ') then check:= 1 else check:=0;
end;
procedure demncdi;
begin;
dmd:=0;
{for c:= 1 to 4 do
for h:= 1 to 5 do
begin
if (qc[c][h] = lx) and (qc[c+1][h] = ' ') then dmd:= dmd+1;
if (qc[c+1][h] = lx) and (qc[c][h] = ' ') then dmd:= dmd+1;
gotoxy(c+22, h);
write(0);
gotoxy(35, 1);
writeln(dmd:3);
readln;
end;
for c:= 1 to 5 do
for h:= 1 to 4 do
begin
if (qc[c][h] = lx) and (qc[c][h+1] = ' ') then dmd:= dmd+1; //bo
if (qc[c][h+1] = lx) and (qc[c][h] = ' ') then dmd:= dmd+1;
gotoxy(c+27, h);
write(1);
gotoxy(35, 1);
writeln(dmd:3);
readln;
end;
for i:= 1 to 4 do
begin
if (qc[i][i] = lx) and (qc[i+1][i+1] = ' ') then dmd:= dmd+1;
if (qc[i+1][i+1] = lx) and (qc[i][i] = ' ') then dmd:= dmd+1;
gotoxy(i+22, i+6);
write(0);
gotoxy(35, 1);
writeln(dmd:3);
readln;
if (qc[6-i][i] = lx) and (qc[5-i][i+1] = ' ') then dmd:= dmd+1;
if (qc[5-i][i+1] = lx) and (qc[6-i][i] = ' ') then dmd:= dmd+1;
gotoxy(6-i+22, i+6);
write(1);
gotoxy(35, 1);
writeln(dmd:3);
readln;
if (qc[i][(i+1) mod 4 + 1] = lx) and (qc[i+1][(i+1) mod 4 + 2] = ' ') then dmd:= dmd+1;
if (qc[i+1][(i+1) mod 4 + 2] = lx) and (qc[i][(i+1) mod 4 + 1] = ' ') then dmd:= dmd+1;
gotoxy(i+27, (i+1)mod 4 +1+6);
write(0);
gotoxy(35, 1);
writeln(dmd:3);
readln;
if (qc[i][5 - (i+1) mod 4] = lx) and (qc[i+1][4 - (i+1) mod 4] = ' ') then dmd:= dmd+1;
if (qc[i+1][4 - (i+1) mod 4] = lx) and (qc[i][5 - (i+1) mod 4] = ' ') then dmd:= dmd+1;
gotoxy(i+27, 5 - (i+1) mod 4+6);
write(1);
gotoxy(35, 1);
writeln(dmd:3);
readln;
end;}
dmd:=dmd+check(1, 1, 2, 1);
dmd:=dmd+check(1, 1, 1, 2);
dmd:=dmd+check(1, 1, 2, 2);
dmd:=dmd+check(1, 2, 2, 2);
dmd:=dmd+check(1, 2, 1, 3);
dmd:=dmd+check(1, 2, 1, 1);
dmd:=dmd+check(1, 3, 2, 3);
dmd:=dmd+check(1, 3, 1, 4);
dmd:=dmd+check(1, 3, 1, 2);
dmd:=dmd+check(1, 3, 2, 4);
dmd:=dmd+check(1, 3, 2, 2);
dmd:=dmd+check(1, 4, 2, 4);
dmd:=dmd+check(1, 4, 1, 5);
dmd:=dmd+check(1, 4, 1, 3);
dmd:=dmd+check(1, 5, 2, 5);
dmd:=dmd+check(1, 5, 1, 4);
dmd:=dmd+check(1, 5, 2, 4);
dmd:=dmd+check(2, 1, 3, 1);
dmd:=dmd+check(2, 1, 1, 1);
dmd:=dmd+check(2, 1, 2, 2);
dmd:=dmd+check(2, 2, 3, 2);
dmd:=dmd+check(2, 2, 1, 2);
dmd:=dmd+check(2, 2, 2, 3);
dmd:=dmd+check(2, 2, 2, 1);
dmd:=dmd+check(2, 2, 3, 3);
dmd:=dmd+check(2, 2, 1, 3);
dmd:=dmd+check(2, 2, 3, 1);
dmd:=dmd+check(2, 2, 1, 1);
dmd:=dmd+check(2, 3, 3, 3);
dmd:=dmd+check(2, 3, 1, 3);
dmd:=dmd+check(2, 3, 2, 4);
dmd:=dmd+check(2, 3, 2, 2);
dmd:=dmd+check(2, 4, 3, 4);
dmd:=dmd+check(2, 4, 1, 4);
dmd:=dmd+check(2, 4, 2, 5);
dmd:=dmd+check(2, 4, 2, 3);
dmd:=dmd+check(2, 4, 3, 5);
dmd:=dmd+check(2, 4, 1, 5);
dmd:=dmd+check(2, 4, 3, 3);
dmd:=dmd+check(2, 4, 1, 3);
dmd:=dmd+check(2, 5, 3, 5);
dmd:=dmd+check(2, 5, 1, 5);
dmd:=dmd+check(2, 5, 2, 4);
dmd:=dmd+check(3, 1, 4, 1);
dmd:=dmd+check(3, 1, 2, 1);
dmd:=dmd+check(3, 1, 3, 2);
dmd:=dmd+check(3, 1, 4, 2);
dmd:=dmd+check(3, 1, 2, 2);
dmd:=dmd+check(3, 2, 4, 2);
dmd:=dmd+check(3, 2, 2, 2);
dmd:=dmd+check(3, 2, 3, 3);
dmd:=dmd+check(3, 2, 3, 1);
dmd:=dmd+check(3, 3, 4, 3);
dmd:=dmd+check(3, 3, 2, 3);
dmd:=dmd+check(3, 3, 3, 4);
dmd:=dmd+check(3, 3, 3, 2);
dmd:=dmd+check(3, 3, 4, 4);
dmd:=dmd+check(3, 3, 2, 4);
dmd:=dmd+check(3, 3, 4, 2);
dmd:=dmd+check(3, 3, 2, 2);
dmd:=dmd+check(3, 4, 4, 4);
dmd:=dmd+check(3, 4, 2, 4);
dmd:=dmd+check(3, 4, 3, 5);
dmd:=dmd+check(3, 4, 3, 3);
dmd:=dmd+check(3, 5, 4, 5);
dmd:=dmd+check(3, 5, 2, 5);
dmd:=dmd+check(3, 5, 3, 4);
dmd:=dmd+check(3, 5, 4, 4);
dmd:=dmd+check(3, 5, 2, 4);
dmd:=dmd+check(4, 1, 5, 1);
dmd:=dmd+check(4, 1, 3, 1);
dmd:=dmd+check(4, 1, 4, 2);
dmd:=dmd+check(4, 2, 5, 2);
dmd:=dmd+check(4, 2, 3, 2);
dmd:=dmd+check(4, 2, 4, 3);
dmd:=dmd+check(4, 2, 4, 1);
dmd:=dmd+check(4, 2, 5, 3);
dmd:=dmd+check(4, 2, 3, 3);
dmd:=dmd+check(4, 2, 5, 1);
dmd:=dmd+check(4, 2, 3, 1);
dmd:=dmd+check(4, 3, 5, 3);
dmd:=dmd+check(4, 3, 3, 3);
dmd:=dmd+check(4, 3, 4, 4);
dmd:=dmd+check(4, 3, 4, 2);
dmd:=dmd+check(4, 4, 5, 4);
dmd:=dmd+check(4, 4, 3, 4);
dmd:=dmd+check(4, 4, 4, 5);
dmd:=dmd+check(4, 4, 4, 3);
dmd:=dmd+check(4, 4, 5, 5);
dmd:=dmd+check(4, 4, 3, 5);
dmd:=dmd+check(4, 4, 5, 3);
dmd:=dmd+check(4, 4, 3, 3);
dmd:=dmd+check(4, 5, 5, 5);
dmd:=dmd+check(4, 5, 3, 5);
dmd:=dmd+check(4, 5, 4, 4);
dmd:=dmd+check(5, 1, 4, 1);
dmd:=dmd+check(5, 1, 5, 2);
dmd:=dmd+check(5, 1, 4, 2);
dmd:=dmd+check(5, 2, 4, 2);
dmd:=dmd+check(5, 2, 5, 3);
dmd:=dmd+check(5, 2, 5, 1);
dmd:=dmd+check(5, 3, 4, 3);
dmd:=dmd+check(5, 3, 5, 4);
dmd:=dmd+check(5, 3, 5, 2);
dmd:=dmd+check(5, 3, 4, 4);
dmd:=dmd+check(5, 3, 4, 2);
dmd:=dmd+check(5, 4, 4, 4);
dmd:=dmd+check(5, 4, 5, 5);
dmd:=dmd+check(5, 4, 5, 3);
dmd:=dmd+check(5, 5, 4, 5);
dmd:=dmd+check(5, 5, 5, 4);
dmd:=dmd+check(5, 5, 4, 4);
end;
procedure choose;
begin
if qc[cp][hp]=lx then
begin
if (cq=cp) and (hq=hp) then
begin
cq:=0; hq:=0;
chonquan:=false;
end
else
begin
cq:=cp; hq:=hp;
chonquan:=true;
end
end;
if (qc[cp][hp]=' ') and chonquan then
begin
cn:=cp; hn:=hp;
end;
end;
procedure help;
begin
textcolor(red);
gotoxy(24,2); writeln('a/ phim trai / 4: qua trai');
gotoxy(24,3); writeln('s/ phim xuong/ 2: qua xuong');
gotoxy(24,4); writeln('d/ phim phai / 6: qua phai');
gotoxy(24,5); writeln('w/ phim tren / 8: di len');
gotoxy(24,6); writeln('q/ 7: len trai');
gotoxy(24,7); writeln('e/ 9: len phai');
gotoxy(24,8); writeln('c/ 3: xuong phai');
gotoxy(24,9); writeln('z/ 1: xuong trai');
gotoxy(24,11); writeln('enter/ cach/ 5/ s: chon');
gotoxy(24,12); writeln('tab: an/ hien thong so');
gotoxy(24,13); writeln('d + shift: doi ban co');
gotoxy(24,14); writeln('home: quay ve o trung tam');
gotoxy(24,15); writeln('h: hien tro giup');
gotoxy(24,16); writeln('esc: thoat');
end;
{procedure choose_stg;
begin
if stg=1 then thongso:= not thongso;
if stg=2 then stg:=0;
end;
procedure setting;
begin
stg:= 1;
while stg<>0 do
begin
gotoxy(5,2);
write('+-CAI DAT----------');
gotoxy(5,3);
write('|hien thong so: ');
if stg = 1 then textbackground(yellow) else be_blk;
if thongso then write('bat') else write('tat');
gotoxy(5,4);
textbackground(black);
write('| ');
if stg = 2 then textbackground(yellow) else textbackground(black);
write('thoat', stg);
textbackground(black);
write(' ');
textbackground(black);
gotoxy(5,5);
write('+-----------------');
readln;
repeat until keypressed;
case readkey of
'1': stg:=1;
'2': stg:=2;
#13: choose_stg;
' ': choose_stg;
end;
textbackground(black);
stg:=0;
end;
banco1;
banco2;
end;}
procedure play;
begin
hl:=false;
chonquan:=chonquan;
if luotxanh = true then begin cp:=cpx; hp:=hpx; end
else begin cp:=cpd; hp:=hpd; end;
cq:=0; hq:=0; cn:=0; hn:=0;
banco1;
while hl = false do
begin
banco2;
{repeat delay(1) until ((readkey = 'a') or (readkey = 's') or (readkey = 'd') or (readkey = 'w') or (readkey = chr(32)));}
repeat until keypressed;
case readkey of
'a':if huongxanh then begin if cp <> 5 then cp:= cp+1 end else if cp <> 1 then cp:= cp-1;
#75:if huongxanh then begin if cp <> 5 then cp:= cp+1 end else if cp <> 1 then cp:= cp-1; //trai
'4':if huongxanh then begin if cp <> 5 then cp:= cp+1 end else if cp <> 1 then cp:= cp-1;
's':if huongxanh then begin if hp <> 1 then hp:= hp-1 end else if hp <> 5 then hp:= hp+1;
#80:if huongxanh then begin if hp <> 1 then hp:= hp-1 end else if hp <> 5 then hp:= hp+1; //xuong
'2':if huongxanh then begin if hp <> 1 then hp:= hp-1 end else if hp <> 5 then hp:= hp+1;
'd':if huongxanh then begin if cp <> 1 then cp:= cp-1 end else if cp <> 5 then cp:= cp+1;
#77:if huongxanh then begin if cp <> 1 then cp:= cp-1 end else if cp <> 5 then cp:= cp+1; //phai
'6':if huongxanh then begin if cp <> 1 then cp:= cp-1 end else if cp <> 5 then cp:= cp+1;
'w':if huongxanh then begin if hp <> 5 then hp:= hp+1 end else if hp <> 1 then hp:= hp-1;
#72:if huongxanh then begin if hp <> 5 then hp:= hp+1 end else if hp <> 1 then hp:= hp-1; //len
'8':if huongxanh then begin if hp <> 5 then hp:= hp+1 end else if hp <> 1 then hp:= hp-1;
'q':if huongxanh then begin if hp <> 5 then hp:= hp+1; if cp <> 5 then cp:= cp+1 end else begin if hp <> 1 then hp:= hp-1; if cp <> 1 then cp:= cp-1; end; //wa
'7':if huongxanh then begin if hp <> 5 then hp:= hp+1; if cp <> 5 then cp:= cp+1 end else begin if hp <> 1 then hp:= hp-1; if cp <> 1 then cp:= cp-1; end;
'e':if huongxanh then begin if hp <> 5 then hp:= hp+1; if cp <> 1 then cp:= cp-1 end else begin if hp <> 1 then hp:= hp-1; if cp <> 5 then cp:= cp+1; end; //wd
'9':if huongxanh then begin if hp <> 5 then hp:= hp+1; if cp <> 1 then cp:= cp-1 end else begin if hp <> 1 then hp:= hp-1; if cp <> 5 then cp:= cp+1; end;
'c':if huongxanh then begin if hp <> 1 then hp:= hp-1; if cp <> 1 then cp:= cp-1 end else begin if hp <> 5 then hp:= hp+1; if cp <> 5 then cp:= cp+1; end; //sd
'3':if huongxanh then begin if hp <> 1 then hp:= hp-1; if cp <> 1 then cp:= cp-1 end else begin if hp <> 5 then hp:= hp+1; if cp <> 5 then cp:= cp+1; end;
'z':if huongxanh then begin if hp <> 1 then hp:= hp-1; if cp <> 5 then cp:= cp+1 end else begin if hp <> 5 then hp:= hp+1; if cp <> 1 then cp:= cp-1; end; //sa
'1':if huongxanh then begin if hp <> 1 then hp:= hp-1; if cp <> 5 then cp:= cp+1 end else begin if hp <> 5 then hp:= hp+1; if cp <> 1 then cp:= cp-1; end;
#13:choose;
' ':choose;
'5':choose; //chon
'x':choose;
#09:thongso:= not thongso;
'~':doitrongtran:= not doitrongtran;
'V':if doitrongtran and doishift then vay1:=not vay1;
'E':if doitrongtran and doishift then an1:= not(an1);
'D':begin huongxanh:= not huongxanh; if doip then begin cn:=6-cn; hn:=6-hn; end; end;
'p':if doitrongtran then doip:= not doip;
'A':if doitrongtran then autodoixanh:= not autodoixanh;
'%':doishift:=not doishift;
#71: begin
cp:=3;
hp:=3;
end;
'h': help;
{'S': setting;}
#27:out:=true;
end;
if (cn<>0) and (cp<>0) then checkhl;
if hl or out then
begin
qc[cq][hq]:=' ';
qc[cn][hn]:=lx;
chonquan:=false;
if luotxanh = true then begin cpx:=cn; hpx:=hn; end
else begin cpd:=cn; hpd:=hn; end;
end;
end;
anquan;
luotxanh:=not luotxanh;
demncdi;
cn:=0; hn:=0; cq:= 0; hq:= 0;
if autodoixanh then huongxanh:=luotxanh;
end;
//---------------------------------------------------------------
procedure choose_s;
begin
if s = 1 then s:= 0;
if s = 2 then an1:= not an1;
if s = 3 then vay1:= not vay1;
if s = 4 then autodoixanh:= not autodoixanh;
if s = 5 then setting_reset;
be_blk;
clrscr;
writeln('game co ganh by dangxuanchuon');
end;
procedure choose_e;
begin
if e = 1 then l:= 1;
if e = 2 then l:= 0;
if e<> 3 then e:= 0;
end;
procedure do_credit;
begin
be_blk;
gotoxy(23,1);
writeln('GAME CO GANH (CO CHEM) LAM BOI @DANGXUANCHUON');
gotoxy(23,2);
writeln('Nguon luat choi: wikipedia, thu thuat choi (an1 = false va vay1 = false)');
gotoxy(23,3);
writeln('luat choi ban dau (an1= true va vay1 = true): y/FU3auCFYGJc');
end;
procedure clear_credit;
begin
be_blk;
gotoxy(23,1);
writeln(' ');
gotoxy(23,2);
writeln(' ');
gotoxy(23,3);
writeln(' ');
end;
//---------------------------------------------------------------
procedure startscreen;
begin
be_blk;
clrscr;
textcolor(white);
writeln('game co ganh by dangxuanchuon');
s:=1;
delay(1000);
while s<>0 do
begin
gotoxy(1,3);
textcolor(white);
if s = 1 then be_yel else be_blk;
writeln('CHOI');
textcolor(red);
be_blk;
writeln('cai dat:');
textcolor(white);
if s = 2 then be_yel else be_blk;
if an1 then
begin
writeln('an quan bang cach doi mau quan co');
writeln('(doi lai la loai quan co khoi ban co khi enter vao)');
end
else
begin
writeln('an quan bang cach loai quan co khoi ban co khi enter vao');
writeln('(doi lai la doi mau quan co)');
end;
if s = 3 then be_yel else be_blk;
if vay1 then
begin
writeln('vay bang cach kep giua quan co');
writeln('(doi lai la di chuyen quan lam hang rao lam cho cac quan bi vay khong the di chuyen khi enter vao)')
end
else
begin
writeln('vay bang cach di chuyen quan lam hang rao lam cho cac quan bi vay khong the di chuyen');
writeln('(doi lai la kep giua quan co khi enter vao)')
end;
if s = 4 then be_yel else be_blk;
if autodoixanh then
begin
writeln('tu doi huong ban co khi qua luot');
writeln('(tat khi enter vao)')
end
else
begin
writeln('tat tu doi huong ban co khi qua luot');
writeln('(bat khi enter vao)')
end;
if s = 5 then be_yel else be_blk;
writeln('reset (cai dat lai luat choi va cac cai dat khac)');
repeat until keypressed;
case readkey of
#72: if s <> 1 then s:= s - 1 else s:=5;
#80: if s <> 5 then s:= s + 1 else s:=1;
#13: choose_s;
' ': choose_s;
#27: e:= 1 mod (s-s)
end;
be_blk;
end;
l:=1;
end;
procedure maingame;
begin
game_reset;
while (dmd<>0) and not out do
play;
l:=2;
end;
procedure endscreen;
begin
banco1;
thongso:=false;
banco2;
if luotxanh then
begin
gotoxy(5,10);
textcolor(red);
writeln('PHE DO THANG!');
end
else
begin
gotoxy(5,10);
textcolor(blue);
writeln('PHE XANH THANG!');
end;
e:=1;
textcolor(white);
while e<>0 do
begin
gotoxy(1,22);
case e of
1:
begin
be_yel;
writeln('choi lai');
be_blk;
writeln('man hinh chinh');
be_blk;
writeln('credit');
clear_credit;
end;
2:
begin
be_blk;
writeln('choi lai');
be_yel;
writeln('man hinh chinh');
be_blk;
writeln('credit');
clear_credit;
end;
3:
begin
be_blk;
writeln('choi lai');
be_blk;
writeln('man hinh chinh');
be_yel;
writeln('credit');
do_credit;
end;
end;
be_blk;
repeat until keypressed;
case readkey of
#72: if e <> 1 then e:= e - 1 else e:=3;
#80: if e <> 3 then e:= e + 1 else e:=1;
#13: choose_e;
' ': choose_e;
#27: e:= 1 mod (e-e)
end;
end;
end;
//---------------------------------------------------------------
begin
TRUEreset;
l:=0;
repeat
case l of
0:startscreen;
1:maingame;
2:endscreen;
end;
until out;
end.
CREDIT:
nguoi lam ra: dangxuanchuon
nguoi tro giup va kien thuc va lam cho d.x.chuon co y dinh lam procedure, function, ...: HauBright
12/6/2023 - 14/8/2023
(12/6/2023 - 29/7/2033 neu tinh toi co ban hoan thien)
(8/6/2023 - 14/8/2023 neu tinh cai bi loi truoc)
ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
ºã(16089)=177013º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Mã:
program cganh;
uses crt;
const nhanh =90; cham = 70;
type kqc = array [1..16] of record
hang: int8;
cot : int8;
phe : boolean;
dinhdanh: byte;
end;
var qc: kqc;
i, j, k, l, dem, soluot: byte;
luotxanh, hople: boolean;
nhap, lenh, baoloi: string;
procedure TRUEreset;
begin
soluot:=1; //bandau
luotxanh:= true; //ben xanh di trc
for i:=1 to 8 do
qc[i].phe:= true; //quyet dinh phe (true la xanh, false la do)
for i:=9 to 16 do
qc[i].phe:=false;
qc[1].cot:=1; qc[1].hang:=6;
qc[2].cot:=1; qc[2].hang:=1;
qc[3].cot:=6; qc[3].hang:=1;
qc[4].cot:=11; qc[4].hang:=1;
qc[5].cot:=16; qc[5].hang:=1;
qc[6].cot:=21; qc[6].hang:=1;
qc[7].cot:=21; qc[7].hang:=6;
qc[8].cot:=21; qc[8].hang:=11; //quyet dinh vi tri bat dau
qc[9].cot:=21; qc[9].hang:=16;
qc[10].cot:=21; qc[10].hang:=21;
qc[11].cot:=16; qc[11].hang:=21;
qc[12].cot:=11; qc[12].hang:=21;
qc[13].cot:=6; qc[13].hang:=21;
qc[14].cot:=1; qc[14].hang:=21;
qc[15].cot:=1; qc[15].hang:=16;
qc[16].cot:=1; qc[16].hang:=11;
end;
function ngaunhien(chm1, chm2, count: byte): byte;
begin
if (count = 1) and (luotxanh=true) then ngaunhien:=chm1
else ngaunhien:=chm2;
end;
procedure banco;
begin
clrscr;
for i:= 1 to 21 do
for j:= 1 to 21 do
begin
while random(ngaunhien(cham, nhanh, soluot)) = 0 do delay(1); //lam cham cho vui
textcolor(white); //
for k:= 1 to 16 do //
if ((i-1) mod 5 = 0) and ((j-1) mod 5 = 0) then //
if (qc[k].cot = i) and (qc[k].hang = j) then //hien thi vi tri cac quan co tren ban co
begin //
if qc[k].phe = true then textcolor(blue) else textcolor(red); //
gotoxy(i,j); //
write('0'); //
end //
else //
begin // khong su dung
gotoxy(i,j); //hien vi tri khong co quan co
write('0'); //
end; //
if ((i-1) mod 5 = 0) and ((j-1) mod 5 <> 0) then //
begin
gotoxy(i,j); //
write('|');
end; //
if ((j-1) mod 5 = 0) and ((i-1) mod 5 <> 0) then
begin //
gotoxy(i,j);
write('-'); //
end;
if (((i-2) mod 10 = 0) and ((j-2) mod 10 = 0)) or (((i-3) mod 10 = 0) and ((j-3) mod 10 = 0)) or //hien cac hinh ve tren ban co
(((i-4) mod 10 = 0) and ((j-4) mod 10 = 0)) or (((i-5) mod 10 = 0) and ((j-5) mod 10 = 0)) or
(((i-7) mod 10 = 0) and ((j-7) mod 10 = 0)) or (((i-8) mod 10 = 0) and ((j-8) mod 10 = 0)) or //
(((i-9) mod 10 = 0) and ((j-9) mod 10 = 0)) or ((i mod 10 = 0) and (j mod 10 = 0)) then
begin //
gotoxy(i,j);
write('\'); //
end;
if (((i-2) mod 10 = 0) and (j mod 10 = 0)) or (((i-3) mod 10 = 0) and ((j+1) mod 10 = 0)) or //
(((i-4) mod 10 = 0) and ((j+2) mod 10 = 0)) or (((i-5) mod 10 = 0) and ((j+3) mod 10 = 0)) or
(((i-7) mod 10 = 0) and ((j+5) mod 10 = 0)) or (((i-8) mod 10 = 0) and ((j+6) mod 10 = 0)) or //
(((i-9) mod 10 = 0) and ((j+7) mod 10 = 0)) or ((i mod 10 = 0) and ((j+8) mod 10 = 0)) then
begin //
gotoxy(i,j);
write('/'); //
end;
end; //
end;
procedure nhap_nuoc_di;
begin
for l:= 1 to 16 do qc[l].dinhdanh:=0;
l:=0;
lenh:='';
textcolor(white);
gotoxy(2,22);
writeln('nhap lenh:');
for j:= 1 to 5 do
for i:= 1 to 5 do
for k:= 1 to 16 do
if (qc[k].cot = 5*i-4) and (qc[k].hang = 5*j-4) then //hien ban co co stt quan co
begin
gotoxy(5*i-4,5*j-4);
if qc[k].phe = true then textcolor(blue) else textcolor(red);
if qc[k].phe=luotxanh then
begin
l:=l+1;
qc[k].dinhdanh:=l;
if l<10 then
write(l)
else write(chr(l+55));
end
else write('0');
end;
textcolor(white);
gotoxy(32, 20); write('ABC');
gotoxy(32, 21); write('H D'); //hien cach nhap lenh
gotoxy(32, 22); write('GFE');
if luotxanh = true then textcolor(blue) else textcolor(red);
gotoxy(33, 21); write('0');
textcolor(white);
gotoxy(27, 23); write('cach nhap lenh');
if baoloi = 'ko dung 2 ki tu' then
begin
gotoxy(1, 24); textcolor(red); writeln('LOI! cac ki tu can phai co d(d)ung(s) 2 ki tu');
writeln('ki tu dau chi stt cua quan co (quan co dinh di chuyen), vd: 3 (quan co 3)');
writeln('ki tu sau chi huong di chuyen (hoa hoac thuong), vd E (xuong phai)');
writeln('vd cu phap hop le: 3E, cu phap tuan theo luat nay co the khong hop le do luat choi');
textcolor(white);
end;
if baoloi = 'ko thay quan co' then
begin
gotoxy(1, 24); textcolor(red); writeln('LOI! quan co khong hop le');
writeln('chu cai dau can la so hoac chu(wx) co(s) tren hinh');
textcolor(white);
end;
if baoloi = 'biengioi' then
begin
gotoxy(1, 24); textcolor(red); writeln('LOI! quan co bi gioi han o bien gioi');
textcolor(white);
end;
gotoxy(1, 23); readln(nhap);
end;
function xacdinhk(lenh1:string): byte;
begin
if lenh1 = '1' then xacdinhk:=1;
if lenh1 = '2' then xacdinhk:=2;
if lenh1 = '3' then xacdinhk:=3;
if lenh1 = '4' then xacdinhk:=4;
if lenh1 = '5' then xacdinhk:=5;
if lenh1 = '6' then xacdinhk:=6;
if lenh1 = '7' then xacdinhk:=7;
if lenh1 = '8' then xacdinhk:=8;
if lenh1 = '9' then xacdinhk:=9;
if (lenh1 = 'A') or (lenh1= 'a') then xacdinhk:=10;
if (lenh1 = 'B') or (lenh1= 'b') then xacdinhk:=11;
if (lenh1 = 'C') or (lenh1= 'c') then xacdinhk:=12;
if (lenh1 = 'D') or (lenh1= 'd') then xacdinhk:=13;
if (lenh1 = 'E') or (lenh1= 'e') then xacdinhk:=14;
if (lenh1 = 'F') or (lenh1= 'f') then xacdinhk:=15;
if (lenh1 = 'G') or (lenh1= 'g') then xacdinhk:=16;
if not((lenh1 = '1') or (lenh1 = '2') or (lenh1 = '3') or (lenh1 = '4') or (lenh1 = '5') or (lenh1 = '6') or (lenh1 = '7') or (lenh1 = '8') or (lenh1 = '9')
or (lenh1 = 'a') or (lenh1 = 'b') or (lenh1 = 'c') or (lenh1 = 'd') or (lenh1 = 'e') or (lenh1 = 'f') or (lenh1 = 'g')
or (lenh1 = 'A') or (lenh1 = 'B') or (lenh1 = 'C') or (lenh1 = 'D') or (lenh1 = 'E') or (lenh1 = 'F') or (lenh1 = 'G')) then xacdinhk:= 100;
end;
procedure thuchien;
var cout: byte;
begin
cout:=0;
for k:= 1 to 16 do
qc[k].dinhdanh:=0;
for j:= 1 to 5 do
for i:= 1 to 5 do
for k:= 1 to 16 do
if (qc[k].cot = 5*i-4) and (qc[k].hang = 5*j-4) and (qc[k].phe = luotxanh) then
begin
cout:=cout+1;
qc[k].dinhdanh:=cout;
end;
for k:= 1 to 16 do
if (qc[k].dinhdanh = xacdinhk(lenh[1])) and (qc[k].phe =luotxanh) then
begin
if upcase(lenh[2]) = 'A' then begin qc[k].cot:=qc[k].cot-5; qc[k].hang:=qc[k].hang-5; end;
if upcase(lenh[2]) = 'B' then qc[k].hang:=qc[k].hang-5;
if upcase(lenh[2]) = 'C' then begin qc[k].cot:=qc[k].cot+5; qc[k].hang:=qc[k].hang-5; end;
if upcase(lenh[2]) = 'D' then qc[k].cot:=qc[k].cot+5;
if upcase(lenh[2]) = 'E' then begin qc[k].cot:=qc[k].cot+5; qc[k].hang:=qc[k].hang+5; end;
if upcase(lenh[2]) = 'F' then qc[k].hang:=qc[k].hang+5;
if upcase(lenh[2]) = 'G' then begin qc[k].cot:=qc[k].cot-5; qc[k].hang:=qc[k].hang+5; end;
if upcase(lenh[2]) = 'H' then qc[k].cot:=qc[k].cot-5;
end;
if luotxanh = false then soluot:=soluot+1;
end;
function benngoaibanco: boolean;
var cout: byte;
begin
cout:=0;
for k:= 1 to 16 do
qc[k].dinhdanh:=0;
for j:= 1 to 5 do
for i:= 1 to 5 do
for k:= 1 to 16 do
if (qc[k].cot = 5*i-4) and (qc[k].hang = 5*j-4) and (qc[k].phe = luotxanh) then
begin
cout:=cout+1;
qc[k].dinhdanh:=cout;
end;
benngoaibanco:=false;
for k:= 1 to 16 do
if (qc[k].dinhdanh = xacdinhk(lenh[1])) and (qc[k].phe =luotxanh) then
begin
if (upcase(lenh[2]) = 'A') and ((qc[k].cot=1) or (qc[k].hang=1)) then benngoaibanco:=true;
if (upcase(lenh[2]) = 'B') and (qc[k].hang=1) then benngoaibanco:=true;
if (upcase(lenh[2]) = 'C') and ((qc[k].cot=21) or (qc[k].hang=1)) then benngoaibanco:=true;
if (upcase(lenh[2]) = 'D') and (qc[k].cot=21) then benngoaibanco:=true;
if (upcase(lenh[2]) = 'E') and ((qc[k].cot=21) or (qc[k].hang=21)) then benngoaibanco:=true;
if (upcase(lenh[2]) = 'F') and (qc[k].hang=21) then benngoaibanco:=true;
if (upcase(lenh[2]) = 'G') and ((qc[k].cot=1) or (qc[k].hang=21)) then benngoaibanco:=true;
if (upcase(lenh[2]) = 'H') and (qc[k].cot=1) then benngoaibanco:=true;
end;
end;
procedure hienvanhap;
begin
clrscr;
hople := false;
baoloi:= '';
while hople = false do
begin
dem:=0;
for k:= 1 to 16 do
if qc[k].phe = luotxanh then dem:=dem+1;
hople := true;
banco;
gotoxy(3,2);
nhap_nuoc_di;
baoloi:= '';
if length(nhap)<>2 then begin hople := false; baoloi:= 'ko dung 2 ki tu'; end;
if (xacdinhk(nhap[1])>dem) and hople then begin hople := false; baoloi:= 'ko thay quan co'; end;
if benngoaibanco and hople then begin hople := false; baoloi:= 'biengioi'; end;
if hople = true then thuchien;
end;
lenh:=nhap;
end;
procedure play;
begin
hienvanhap;
thuchien;
luotxanh:= not luotxanh;
end;
begin
randomize;
clrscr;
TRUEreset;
while 1=1 do play;
readln;
end.
(giờ mình lặn đây)