Good evening all,
im really sorry for having to post my code like this however ive complete mucked up everything. i got a few snippets of code and need some help piecing them together. however i think part of its in java. what i would like to a decent game of battleships. using mutliplayer as well as a computer on a grid 10 by 10.
var map : array 1 .. 10, 1 .. 10 of int
var r, r2 : int
loop
for c : 1 .. 10
for d : 1 .. 10
map (c, d) := 0
end for
end for
for i : 1 .. 4
randint (r, 1, 10)
randint (r2, 1, 10)
map (r, r2) := 1
end for
var dir : int
for i : 1 .. 3
randint (r, 1, 10)
randint (r2, 1, 10)
randint (dir, 1, 10)
map (r, r2) := 2
if dir = 1 then
if r < 10 and r2 < 10 then
map (r + 1, r2) := 2
end if
else
if r < 10 and r2 < 10 then
map (r, r2 + 1) := 2
end if
end if
end for
for i : 1 .. 2
randint (r, 1, 10)
randint (r2, 1, 10)
randint (dir, 1, 10)
map (r, r2) := 3
if dir = 1 then
if r < 9 and r2 < 10 then
map (r + 1, r2) := 3
map (r + 2, r2) := 3
end if
else
if r < 10 and r2 < 9 then
map (r, r2 + 1) := 3
map (r, r2 + 2) := 3
end if
end if
end for
for i : 1 .. 1
randint (r, 1, 10)
randint (r2, 1, 10)
randint (dir, 1, 10)
map (r, r2) := 4
if dir = 1 then
if r < 8 and r2 < 10 then
map (r + 1, r2) := 4
map (r + 2, r2) := 4
map (r + 3, r2) := 4
end if
else
if r < 10 and r2 < 8 then
map (r, r2 + 1) := 4
map (r, r2 + 2) := 4
map (r, r2 + 3) := 4
end if
end if
end for
var count : int := 0
for c : 1 .. 10
for d : 1 .. 10
if map (c, d) = 1 or map (c, d) = 2 or map (c, d) = 3 or map (c, d) = 4 then
count := count + 1
end if
end for
end for
if count = 20 then
exit
end if
end loop
for c : 1 .. 10
for d : 1 .. 10
put map (c, d) ..
end for
put ""
end for
if there might be any help i look forward to your replies
regards