[b][red]This message was edited by aram76 at 2005-10-30 10:53:35[/red][/b][hr]
THE PROBLEM IS THAT PRGRAM 9NINESWEEPER
DOES NOT WORK AFTER THE COLUMN 6
AND HAVE U ANY suggestion 4 THE SHOW??and how to play ??
please send code>>???
[CODE]
PROGRAM MINESWEEPER;
uses crt;
const row=10;
column=10;
type data=record
mine :boolean;
n:integer;
x,y:integer;
symbl:string;
end;
board =array [1..row,1..column] of data;
var patch:board;
r1,c1:integer;
procedure do_mine(var patch:board;var r,c:integer); {here the patch must be }
var i,j,difficulty:integer; {var because we used the .mine }
begin {in later procedure }
randomize;
difficulty:=random(row-1);
i:=0;
repeat
inc(i);
r:=random(difficulty)+1;
c:=random(r)+2;
patch[r,c].mine:=true;
until i=row;
end;
procedure how_many(var patch:board;var rw,col:integer);
var r,c:integer;
begin
for r:=1 to ( row) do
begin
for c:=1 to (column) do
if patch[r,c].mine=true then
begin
inc(patch[r ,c+1].n);
inc(patch[r-1,c+1].n);
inc(patch[r+1,c+1].n);
inc(patch[r-1,c-1].n);
inc(patch[r+1,c-1].n);
inc(patch[r ,c-1].n);
inc(patch[r-1,c ].n);
inc(patch[r+1,c ].n);
end;
rw:=r;
col:=c;
end;
end;
procedure show_all(var patch:board);
var c,r,num:integer;
begin
for c:=1 to (column) do
begin
for r:=1 to ( row) do
if patch[r,c].mine then
write ('*':3)
else
write(patch[r,c].n:3);
writeln;
end;
end;
procedure boom;
begin
write('*');
sound(222);
delay(100);
nosound;
clrscr;
show_all( patch);
end;
procedure show(var patch:board;var r,c:integer);
var i,j,num,
x,y:integer;
symbl:string;
begin
patch[r,c].symbl:='
@';
for i:=1 to row do {draw}
begin
for j:=1 to row do
begin
write( patch[r,c].symbl:3);
patch[i,j].x:=wherex-3;{to corect the
} {the broblem is after th 6 }
patch[i,j].y:=wherey; {column the value is 0 ????}
end;
writeln;
{ patch[r,c].x:=wherex;} {the loction here won't draw corectly}
{ patch[i,j].y:=wherey; }
end;
str(patch[r,c].n, patch[r,c].symbl);
if patch[r,c].mine then
boom
else
gotoxy(patch[r,c].x,patch[r,c].y);
write(patch[r,c].symbl:3);
end;
var ch:char;
r,c:integer;
begin
do_mine(patch,r,c); {calculate}
how_many(patch,r,c);
clrscr;
repeat
clrscr;
readln(r);
readln(c);
show(patch,r,c);
readln;
until ch='q';
readln;
end.
[/CODE]
Comments
: THE PROBLEM IS THAT PRGRAM 9NINESWEEPER
: DOES NOT WORK AFTER THE COLUMN 6
: AND HAVE U ANY suggestion 4 THE SHOW??and how to play ??
: please send code>>???
: [CODE]
: PROGRAM MINESWEEPER;
: uses crt;
: const row=10;
: column=10;
: type data=record
: mine :boolean;
: n:integer;
: x,y:integer;
: symbl:string;
: end;
: board =array [1..row,1..column] of data;
: var patch:board;
: r1,c1:integer;
:
:
: procedure do_mine(var patch:board;var r,c:integer); {here the patch must be }
: var i,j,difficulty:integer; {var because we used the .mine }
: begin {in later procedure }
: randomize;
: difficulty:=random(row-1);
: i:=0;
: repeat
: inc(i);
: r:=random(difficulty)+1;
: c:=random(r)+2;
: patch[r,c].mine:=true;
: until i=row;
: end;
:
: procedure how_many(var patch:board;var rw,col:integer);
: var r,c:integer;
: begin
: for r:=1 to ( row) do
: begin
: for c:=1 to (column) do
: if patch[r,c].mine=true then
: begin
: inc(patch[r ,c+1].n);
: inc(patch[r-1,c+1].n);
: inc(patch[r+1,c+1].n);
: inc(patch[r-1,c-1].n);
: inc(patch[r+1,c-1].n);
: inc(patch[r ,c-1].n);
: inc(patch[r-1,c ].n);
: inc(patch[r+1,c ].n);
: end;
: rw:=r;
: col:=c;
: end;
: end;
:
: procedure show_all(var patch:board);
: var c,r,num:integer;
: begin
: for c:=1 to (column) do
: begin
: for r:=1 to ( row) do
: if patch[r,c].mine then
: write ('*':3)
: else
: write(patch[r,c].n:3);
: writeln;
: end;
: end;
:
:
:
:
: procedure boom;
: begin
: write('*');
: sound(222);
: delay(100);
: nosound;
: clrscr;
: show_all( patch);
: end;
:
:
: procedure show(var patch:board;var r,c:integer);
: var i,j,num,
: x,y:integer;
: symbl:string;
: begin
: patch[r,c].symbl:='@';
: for i:=1 to row do {draw}
: begin
: for j:=1 to [red][b]row[/b][/red] do
: begin
: write( patch[r,c].symbl:3);
: patch[i,j].x:=wherex-3;{to corect the } {the broblem is after th 6 }
: patch[i,j].y:=wherey; {column the value is 0 ????}
: end;
: writeln;
: { patch[r,c].x:=wherex;} {the loction here won't draw corectly}
: { patch[i,j].y:=wherey; }
: end;
:
: str(patch[r,c].n, patch[r,c].symbl);
: if patch[r,c].mine then
: boom
: else
: gotoxy(patch[r,c].x,patch[r,c].y);
: write(patch[r,c].symbl:3);
: end;
:
:
:
:
: var ch:char;
: r,c:integer;
: begin
: do_mine(patch,r,c); {calculate}
: how_many(patch,r,c);
:
: clrscr;
: repeat
: clrscr;
: readln(r);
: readln(c);
: show(patch,r,c);
: readln;
: until ch='q';
:
: readln;
: end.
: [/CODE]
:
:
I think the problem is in the red location. Shouldn't this need to be column?
: : THE PROBLEM IS THAT PRGRAM 9NINESWEEPER
: : DOES NOT WORK AFTER THE COLUMN 6
: : AND HAVE U ANY suggestion 4 THE SHOW??and how to play ??
: : please send code>>???
: : [CODE]
: : PROGRAM MINESWEEPER;
: : uses crt;
: : const row=10;
: : column=10;
: : type data=record
: : mine :boolean;
: : n:integer;
: : x,y:integer;
: : symbl:string;
: : end;
: : board =array [1..row,1..column] of data;
: : var patch:board;
: : r1,c1:integer;
: :
: :
: : procedure do_mine(var patch:board;var r,c:integer); {here the patch must be }
: : var i,j,difficulty:integer; {var because we used the .mine }
: : begin {in later procedure }
: : randomize;
: : difficulty:=random(row-1);
: : i:=0;
: : repeat
: : inc(i);
: : r:=random(difficulty)+1;
: : c:=random(r)+2;
: : patch[r,c].mine:=true;
: : until i=row;
: : end;
: :
: : procedure how_many(var patch:board;var rw,col:integer);
: : var r,c:integer;
: : begin
: : for r:=1 to ( row) do
: : begin
: : for c:=1 to (column) do
: : if patch[r,c].mine=true then
: : begin
: : inc(patch[r ,c+1].n);
: : inc(patch[r-1,c+1].n);
: : inc(patch[r+1,c+1].n);
: : inc(patch[r-1,c-1].n);
: : inc(patch[r+1,c-1].n);
: : inc(patch[r ,c-1].n);
: : inc(patch[r-1,c ].n);
: : inc(patch[r+1,c ].n);
: : end;
: : rw:=r;
: : col:=c;
: : end;
: : end;
: :
: : procedure show_all(var patch:board);
: : var c,r,num:integer;
: : begin
: : for c:=1 to (column) do
: : begin
: : for r:=1 to ( row) do
: : if patch[r,c].mine then
: : write ('*':3)
: : else
: : write(patch[r,c].n:3);
: : writeln;
: : end;
: : end;
: :
: :
: :
: :
: : procedure boom;
: : begin
: : write('*');
: : sound(222);
: : delay(100);
: : nosound;
: : clrscr;
: : show_all( patch);
: : end;
: :
: :
: : procedure show(var patch:board;var r,c:integer);
: : var i,j,num,
: : x,y:integer;
: : symbl:string;
: : begin
: : patch[r,c].symbl:='@';
: : for i:=1 to row do {draw}
: : begin
: : for j:=1 to [red][b]row[/b][/red] do
: : begin
: : write( patch[r,c].symbl:3);
: : patch[i,j].x:=wherex-3;{to corect the } {the broblem is after th 6 }
: : patch[i,j].y:=wherey; {column the value is 0 ????}
: : end;
: : writeln;
: : { patch[r,c].x:=wherex;} {the loction here won't draw corectly}
: : { patch[i,j].y:=wherey; }
: : end;
: :
: : str(patch[r,c].n, patch[r,c].symbl);
: : if patch[r,c].mine then
: : boom
: : else
: : gotoxy(patch[r,c].x,patch[r,c].y);
: : write(patch[r,c].symbl:3);
: : end;
: :
: :
: :
: :
: : var ch:char;
: : r,c:integer;
: : begin
: : do_mine(patch,r,c); {calculate}
: : how_many(patch,r,c);
: :
: : clrscr;
: : repeat
: : clrscr;
: : readln(r);
: : readln(c);
: : show(patch,r,c);
: : readln;
: : until ch='q';
: :
: : readln;
: : end.
: : [/CODE]
: :
: :
: I think the problem is in the red location. Shouldn't this need to be column?
:
yes indeed .....THANXXXXX
if there is a mine
how can i stop it
[code]
PROGRAM MINESWEEPER;
uses crt;
const row=10;
column=10;
type data=record
mine :boolean;
n:integer;
x,y:integer;
symbl:string;
end;
board =array [1..row,1..column] of data;
var patch:board;
r1,c1:integer;
procedure do_mine(var patch:board;var r,c:integer); {here the patch must be }
var i,j,difficulty:integer; {var because we used the .mine }
begin {in later procedure }
randomize;
difficulty:=random(row-1);
i:=0;
repeat
inc(i);
r:=random(difficulty)+1 ;
c:=random(r)+2;
patch[r,c].mine:=true;
until i=row;
end;
procedure how_many(var patch:board;var rw,col:integer);
var r,c:integer;
code:integer;
begin
for r:=1 to ( row) do
begin
for c:=1 to (column) do
if patch[r,c].mine=true then
begin
inc(patch[r ,c+1].n);
inc(patch[r-1,c+1].n);
inc(patch[r+1,c+1].n);
inc(patch[r-1,c-1].n);
inc(patch[r+1,c-1].n);
inc(patch[r ,c-1].n);
inc(patch[r-1,c ].n);
inc(patch[r+1,c ].n);
{VAL('*', patch[r,c].n,code);}
end;
rw:=r;
col:=c;
end;
end;
procedure show_all(var patch:board);
var c,r,num:integer;
begin
for r:=1 to (row) do
begin
for c:=1 to ( column) do
if patch[r,c].mine then
write ('*':3)
else
write(patch[r,c].n:3);
writeln;
end;
end;
(*================================*)
procedure boom( r,c:integer);
var n,code:integer;
begin
VAL('*', patch[r,c].n,code); {simply write(*);}
write( patch[r,c].n);
sound(222);
delay(500);
nosound;
clrscr;
show_all( patch);
end;
{+++++++++++++++++++++++++++++++++++}
procedure aid(var patch:board;var r,c:integer);
var i:integer;
begin
for i:=0 to 10 do
repeat
if (not patch[r-i,c-i].mine)or (not patch[r+i,c+i].mine) then
begin
str(patch[r-i,c-i].n, patch[r-i,c-i].symbl);
gotoxy(patch[r-i,c-i].x,patch[r-i,c-i].y);
write(patch[r-i,c-i].symbl:3);
str(patch[r+i,c+i].n, patch[r+i,c+i].symbl);
gotoxy(patch[r+i,c+i].x,patch[r+i,c+i].y);
write(patch[r+i,c+i].symbl:3);
end; {the problem is that if there a mine, the loop }
until (patch[r+i,c+i].n<>0) or (patch[r-i,c-i].n<>0); {will continue....}
end;
{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
procedure show(var patch:board;var r,c:integer);
var i,j,num,
x,y:integer;
symbl:string;
begin
patch[r,c].symbl:='?';
for i:=1 to row do {draw}
begin
for j:=1 to column do
begin
write( patch[r,c].symbl:3);
patch[i,j].x:=wherex-3;{to corect the }
patch[i,j].y:=wherey;
end;
writeln;
end;
(*if patch[r,c].mine then {this must be inside the loop}
boom(r,c) *)
repeat
if patch[r,c].mine then
boom(r,c)
else
GOTOXY(3,11);
readln(r);
GOTOXY(3,12);
readln(c);
str(patch[r,c].n, patch[r,c].symbl);
gotoxy(patch[r,c].x,patch[r,c].y);
write(patch[r,c].symbl:3);
if (patch[r,c].n=0) then
aid(patch,r,c);
until patch[r,c].symbl='*';
end;
{+=========================================+}
var ch:char;
r,c:integer;
begin {main}
do_mine(patch,r,c); {calculate}
how_many(patch,r,c);
clrscr;
show(patch,r,c);
readln;
end.
[/code]