Minesweeper help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Minesweeper help

coffeemakacoffeemaka United StatesPosts: 0Member
edited May 2014 in Pascal

I need help with this minesweeper program. I cant use crt with the software that i own (codewarrior) and im not able to use freepascal or any others. This is my problem at hand-- I cant get clear the area when you click on a empty tile that revels all the other empty tiles. As of right now this is what i have. (Im sorry if i have posted in wrong area or have enter info wrong just made a account)
`program test;

var
grid_esy:array [0..10,0..10] of integer; //might change togrid_esy:array [0..10,0..10] of integer;
grid_esy_adj:array [0..10,0..10] of integer;
grid_avg:array [1..15,1..15] of integer;
grid_hrd:array [1..20,1..20] of integer;
grid_esy_visual:array [0..10,0..10] of char;
index,counter,grid_esy_column,TypeOfGame,grid_esy_row:integer;
column,row,x,y,turn:integer;
comma:char;

label 1,2,3,4,6,7;

begin
randomize;
writeln('What type of game would you like');
writeln('1.) easy');
writeln('2.) average');
writeln('3.) Hard(ish)');
readln(TypeOfGame);
case TypeOfGame of
1: 1: begin
writeln('Use grid functions to pick your block.');
For grid_esy_row:=1 to 9 do // change values for harder difficulty
begin
For grid_esy_column:=1 to 9 do // change values for hared difficulty
begin
grid_esy[grid_esy_row,grid_esy_column]:=0;
write(grid_esy[grid_esy_row,grid_esy_column]);
end;
writeln;
end;
goto 2;
{----------------------------------grid set-------------------------------------------}
2: for index:=1 to 10 do // change values for harder difficulty
3: begin
row:=0;
column:=0;
row:=random(9)+1;
column:=random(9)+1;
if grid_esy[row,column] = 0
then begin
grid_esy[row,column]:=9; // change values for harder difficulty
writeln(row,column);
writeln(grid_esy[row,column]);
end
else begin
goto 3;
end;
end;

{----------------------------------mines set-------------------------------------------}

                For row:=1 to 9 do  // change values for harder difficulty
                    begin
                    For column:=1 to 9 do
                        begin
                        If grid_esy[row,column] <> 9
                            then
                                begin 
                                    If grid_esy[row - 1,column]= 9
                                        then 
                                            begin 
                                                grid_esy_adj[row,column]:= 1 + grid_esy_adj[row,column];
                                            end;
                                    IF grid_esy[row + 1,column]= 9
                                        then 
                                            begin
                                                grid_esy_adj[row,column]:= 1 + grid_esy_adj[row,column];
                                            end;
                                    IF grid_esy[row - 1,column - 1]= 9
                                        then 
                                            begin
                                                grid_esy_adj[row,column]:= 1 + grid_esy_adj[row,column];
                                            end;
                                    IF grid_esy[ row + 1,column + 1]= 9
                                        then 
                                            begin
                                                grid_esy_adj[row,column]:= 1 + grid_esy_adj[row,column];
                                            end;
                                    IF grid_esy[row,column + 1]= 9
                                        then 
                                            begin
                                                grid_esy_adj[row,column]:= 1 + grid_esy_adj[row,column];
                                            end;
                                    IF grid_esy[row,column - 1]= 9
                                        then 
                                            begin grid_esy_adj[row,column]:= 1 + grid_esy_adj[row,column];
                                            end;
                                    IF grid_esy[row - 1,column + 1]= 9
                                        then 
                                            begin grid_esy_adj[row,column]:= 1 + grid_esy_adj[row,column];
                                            end;
                                    IF grid_esy[row + 1,column - 1]= 9
                                        then 
                                            begin grid_esy_adj[row,column]:= 1 + grid_esy_adj[row,column];
                                            end;
                                    end
                            else
                                begin
                                    grid_esy_adj[row,column]:=9

                                end;

                        end;//end of loop 2
                    end;//end of loop 1

{----------------------------------labeling-------------------------------------------}
counter:=0;

writeln;

        For row:=1 to 9 do   
begin
For column:=1 to 9 do 
    begin
        grid_esy_visual[row,column] := char (254);
    end;
        writeln;
    end;

6: For row:=1 to 9 do
begin
For column:=1 to 9 do
begin
write(grid_esy_visual[row,column]);
end;
writeln;
end;

        Write('Use X and Y coordinates to pick Block you want to target:  ');
            read(x);
            read(comma);
            readln(y);
            turn:=1 + turn;
                If grid_esy_adj[x,y] = 9 
                    then 
                        begin
                            If turn = 1
                                then 
                                    begin
                                        if grid_esy_adj[x,y] = 9
                                            then
                                                begin

7: row:=random(9)+1;
column:=random(9)+1;
grid_esy_adj[x,y]:=0;
for index:=1 to 1 do
begin
if grid_esy_adj[row,column] = 0
then begin
grid_esy_adj[row,column]:=9; // change values for harder difficult
end
else begin
goto 7;
end;
end;
end;
end
else
begin
goto 4;
end;
end
else
begin
If grid_esy_adj[x,y] = 0
then // Rows the Columns Y then X
begin
grid_esy_visual[x,y] := char(255);
repeat
until
goto 6;
end
else
begin
grid_esy_visual[x,y]:=char(grid_esy_adj[x,y] + 48);
goto 6;
end;

                        end; 

4: writeln('That was a bomb sorry');
turn:=turn - 1;
writeln('You finshed ',turn:0,' turns without hitting a bomb');
{----------------------------------clearing/picking-------------------------------------------}
end;// end of case

    2:  begin

        end
    3:  begin

        end
    end;

end.

`

Sign In or Register to comment.