Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
N1ghtF1re committed Jan 24, 2018
2 parents 65f16a0 + 8f88299 commit e6c669f
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Source code/SeaBattle.stat
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[Stats]
EditorSecs=18971
DesignerSecs=2005
EditorSecs=19184
DesignerSecs=2011
InspectorSecs=1373
CompileSecs=460482
OtherSecs=1705
CompileSecs=464261
OtherSecs=1711
StartTime=1/23/2018 10:36:48 PM
RealKeys=0
EffectiveKeys=0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ uses ErrorPage, MainPage,game, AboutUs;

// resourcestring PlacingRules = 'Игровое поле — обычно квадрат 10×10 каждого игрока, на котором размещается флот кораблей. Горизонтали обычно нумеруются сверху вниз, а вертикали помечаются буквами слева направо. При этом используются буквы русского алфавита от «а» до «к» (буквы «ё» и «й» обычно пропускаются) либо от «а» до «и» (с использованием буквы «ё»), либо буквы латинского алфавита от «a» до «j». Иногда используется слово «республика» или «снегурочка», так как в этих 10-буквенных словах ни одна буква не повторяется. Поскольку существуют различные варианты задания системы координат, то об этом лучше заранее договориться.' + #1013 'Размещаются:';
procedure isHitted_wow(var player1matrix:TStringGrid; var i,j:byte);
var rand, g, l, iDamaged, jDamaged, K:integer;
var rand, g, l, iDamaged, jDamaged, K, trigr:integer;
stem,limit:Boolean;
begin
stem:=False;
Expand Down Expand Up @@ -133,10 +133,65 @@ if not(stem) then
limit:=True;
Rand:=Random(3);
case Rand of
0: if i<=9 then Inc(i) else Limit:=false;
1: if i>=2 then Dec(i) else Limit:=false;
2: if j<=9 then Inc(j) else Limit:=false;
3: if j>=2 then Dec(j) else Limit:=false;
0: if i<=9 then
begin
trigr:=0;
repeat
Inc(i);
Inc(trigr);
if ((i=10) and (player1matrix.cells[i,j] <> '')) and (player1matrix.Cells[i,j] <> 'S') then
begin
limit:=False;
dec(i,trigr);
end;
until (player1matrix.Cells[i,j]='S') or (player1matrix.Cells[i,j]='') or (i=10)
end
else Limit:=false;

1: if i>=2 then
begin
trigr:=0;
repeat
dec(i);
Inc(trigr);
if ((i=1) and (player1matrix.cells[i,j] <> '')) and (player1matrix.Cells[i,j] <> 'S') then
begin
limit:=False;
inc(i,trigr);
end;
until (player1matrix.Cells[i,j]='S') or (player1matrix.Cells[i,j]='') or (i=1)
end
else Limit:=false;

2: if j<=9 then
begin
trigr:=0;
repeat
Inc(j);
Inc(trigr);
if ((j=10) and (player1matrix.cells[i,j] <> '')) and (player1matrix.Cells[i,j] <> 'S') then
begin
limit:=False;
dec(j,trigr);
end;
until (player1matrix.Cells[i,j]='S') or (player1matrix.Cells[i,j]='') or (j=10)
end
else Limit:=false;

3: if j>=2 then
begin
trigr:=0;
repeat
dec(j);
Inc(trigr);
if ((j=1) and (player1matrix.cells[i,j] <> '')) and (player1matrix.Cells[i,j] <> 'S') then
begin
limit:=False;
inc(j,trigr);
end;
until (player1matrix.Cells[i,j]='S') or (player1matrix.Cells[i,j]='') or (j=1)
end
else Limit:=false;
end;
until ((limit) and ((player1matrix.Cells[i,j] = 'S') or (player1matrix.Cells[i,j] = ''))) or (k=30) ;
if k=30 then
Expand All @@ -155,17 +210,33 @@ if not(stem) then
case Rand of
0: if (J<=9)
then
repeat
begin
trigr:=0;
repeat
Inc(j);
if (j=10) and (player1matrix.cells[i,j]<>'') then limit:=False;
until (player1matrix.cells[i,j]='') or (j=10)
Inc(trigr);
if ((j=10) and ((player1matrix.cells[i,j]<>'') and (player1matrix.cells[i,j]<>'S'))) or (player1matrix.Cells[i,j]= '*') then
begin
limit:=False;
Dec(j,trigr);
end;
until (player1matrix.cells[i,j]='') or (player1matrix.cells[i,j]='S') or (j=10)
end
else limit:=false;
1: if (J>=2)
then
begin
trigr:=0;
repeat
Dec(j);
if (j=1) and (player1matrix.cells[i,j]<>'') then limit:=False;
until (player1matrix.cells[i,j]='') or (j=1)
inc(trigr);
if ((j=1) and ((player1matrix.cells[i,j]<>'') and (player1matrix.cells[i,j]<>'S'))) or (player1matrix.Cells[i,j]= '*') then
begin
limit:=False;
Inc(j,trigr);
end;
until (player1matrix.cells[i,j]='') or (player1matrix.cells[i,j]='S') or (j=1)
end
else limit:=false;
end;
until (limit) or (k=30);
Expand All @@ -176,17 +247,33 @@ if not(stem) then
Rand:=Random(1);
case Rand of
0: if (i<=9) then
begin
trigr:=0;
repeat
Inc(i);
if (i=10) and (player1matrix.cells[i,j]<>'') then limit:=False;
until (player1matrix.cells[i,j]='') or (i=10)
Inc(trigr);
if ((i=10) and ((player1matrix.cells[i,j]<>'') and (player1matrix.cells[i,j]<>'S'))) or (player1matrix.Cells[i,j]= '*') then
begin
limit:=False;
Dec(i,trigr);
end;
until (player1matrix.cells[i,j]='') or (player1matrix.cells[i,j]='S') or (i=10)
end
else limit:=false;
1: if (i>=2)
then
begin
trigr:=0;
repeat
Dec(i);
if (i=1) and (player1matrix.cells[i,j]<>'') then limit:=False;
until (player1matrix.cells[i,j]='') or (i=1)
Inc(trigr);
if ((i=1) and ((player1matrix.cells[i,j]<>'') and (player1matrix.cells[i,j]<>'S'))) or (player1matrix.Cells[i,j]= '*') then
begin
limit:=False;
Inc(i,trigr);
end;
until (player1matrix.cells[i,j]='') or (player1matrix.cells[i,j]='S') or (i=1)
end
else limit:=false;
end;
until (limit) or (k=30);
Expand Down Expand Up @@ -455,7 +542,7 @@ procedure Seabattle_fieldAI_generator(var P2F:TPF);
repeat
ib:=Random(n)+1;
jb:=Random(n)+1;
until not (quick_math(ib,jb)) or ( (jb+ship_size-1>10) or (ib+ship_size-1>10)) ;
until not (quick_math(ib,jb)) or ( (jb+ship_size-1>10) and (ib+ship_size-1>10)) ;
direction:=random(2)+1; //1-Right 2-Bottom 3-Left 4-up
if ship_size>1 then
begin
Expand Down

0 comments on commit e6c669f

Please sign in to comment.