I will load it up somewhere and give links As soon as it is finished. I will then accept opinions, suggestions and bug reports. I realised however I will also need a better AI. Since the squares where ships are located is totally random shooting at random places is yet okay but after the organisation, shipparts will be adjecent to each other so the AI will take that into concideration and count differently if it made a hit. For now the shooting procedure is like this:
Code:
Procedure TAI.RandomShot;
var c1,c2,i:integer;
neednewshot:longint;
begin
Repeat
neednewshot:=0;
c1:=random(10);
c2:=random(10)+1;
for i:=1 to n do {n is a global integer variable it stores how many squares have the ai shot at.}
begin
if alreadyshot[i]=c1*10+c2 then neednewshot:=neednewshot+1; {alreadyshot is an array of bytes of the object type TAI which stores at what squares tha ai has already shot at to make sure it won't shoot there again}
end; //This is in begin-end because I might add some additional factors later.
Until neednewshot=0;
alreadyshot[n]:=c1*10+c2;
n:=n+1;
if fleet[c1+1][c2]=3 then
begin
hits:=true;
misses:=false; //These two are variables of the object type TAI
fleet[c1+1][c2]:=1; {global 10x10 matrix variable it stores the shipplaces of the player}
playershipcount:=playershipcount-1;
ReDrawBoard_Playerships('hit',c1+1,c2);
if playershipcount=0 then defeated;
end
else
begin
hits:=false;
misses:=true;
fleet[c1+1][c2]:=2;
ReDrawBoard_Playerships('nothit',c1+1,c2);
end;
end;
{ReDrawBoard_Playerships(hit:string,x,y:byte) is a procedure to draw either a red(hit) or gray(miss) square at the shot coordinates.}
Now my plans are to make a procedure TAI.AccurateShot(x,y:byte); so inside the TAI.AITurn procedure there will be a check. Until a hit is made the TAI.RandomShot will be called. If the AI hits it will shoot at adjecent squares to that coordinate(x,y) until there aren't any adjecent squares left to be shot near any hit squares. Then the TAI.RandomShot will be called again etc. This isn't as easy as I thought I think however I will be able to do it. But for now I'm packing because I'm going home. Have a nice weekend everyone!
Bookmarks