Вверх ↑
Ответов: 8923
Рейтинг: 823
#1: 2021-03-16 18:27:19 ЛС | профиль | цитата
Vadimluk1 писал(а):
некоторые ходы уберу

Хотя число возможных комбинаций крестиков и ноликов гораздо меньше (126), но подойти к каждой при игре можно сотнями способами и выкидывать ходы не надо
Вот программка, откройте в ней полученный в предыдущей программе текстовой файл и она добавит ещё две колонки -- четвёртая колонка чей выигрыш (1-ый или 2-ой игрок, а 0 -- ничья), а пятая колонка на каком ходу завершится игра (5 --9 ход).


Add(MainForm,2953706,357,168)
{
Left=200
Top=50
Width=243
Height=544
link(onCreate,6238456:doStart,[(396,188)(396,223)(347,223)(347,237)])
}
Add(StrList,1914584,287,154)
{
link(FileName,2487976:Value,[])
}
Add(Button,1715518,154,238)
{
Left=80
Top=10
Caption=">>"
link(onClick,15357628:doFor,[])
}
Add(ArrayRW,1461964,301,238)
{
link(onRead,6238456:doParse,[])
link(Array,1914584:Array,[])
link(Index,15357628:Position,[(314,229)(257,229)(257,278)(216,278)])
}
Add(Hub,2054965,245,140)
{
link(onEvent1,11364811:doWork3,[(277,146)])
link(onEvent2,1914584:doLoad,[(277,153)(277,188)])
}
Add(InlineCode,6238456,357,231)
{
WorkPoints=#7:doStart|7:doParse|
EventPoints=#5:onRes|
DataPoints=#3:Str|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|21:uses kol,Share,Debug;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|33: Gain: Array[0..7] of integer;|9: public|26: _data_Data:THI_Event;|19: Str:THI_Event;|22: onRes: THI_Event;|52: procedure doStart(var _Data:TData; Index:Word);|49: procedure doParse(var _Data:TData; Index:Word);|0:|5: end;|0:|14:implementation|0:|30:procedure THiAsmClass.doStart;|14:var i:integer;|5:begin|31: for i:=0 to 7 do Gain[i]:=0; |4:end;|0:|30:procedure THiAsmClass.doParse;|27:var s,ss,ss1,ss2,st:string;|26: i,j,k,n,m,sum:integer;|5:begin|33: st:=ReadString(_Data, Str, '');|24: if st = '' then Exit;|20: ss:=Copy(st,1,9); |21: ss1:=Copy(st,11,5);|21: ss2:=Copy(st,17,4);|32: for i:=0 to 7 do Gain[i]:=0; |19: for i:=1 to 3 do|74: begin |56: if ss1[i] in ['1','2','3'] then Gain[0]:=Gain[0]+1;|56: if ss1[i] in ['4','5','6'] then Gain[1]:=Gain[1]+1;|56: if ss1[i] in ['7','8','9'] then Gain[2]:=Gain[2]+1;|56: if ss1[i] in ['1','4','7'] then Gain[3]:=Gain[3]+1;|56: if ss1[i] in ['2','5','8'] then Gain[4]:=Gain[4]+1;|56: if ss1[i] in ['3','6','9'] then Gain[5]:=Gain[5]+1;|56: if ss1[i] in ['1','5','9'] then Gain[6]:=Gain[6]+1;|56: if ss1[i] in ['3','5','7'] then Gain[7]:=Gain[7]+1;|5: end;|18: for i:=0 to 7 do|8: begin|22: if Gain[i]=3 then|8: begin|35: _hi_onEvent(onRes, st + '1;5');|12: Exit;|10: end;|7: end;|3: |32: for i:=0 to 7 do Gain[i]:=0; |19: for i:=1 to 3 do|74: begin |56: if ss2[i] in ['1','2','3'] then Gain[0]:=Gain[0]+1;|56: if ss2[i] in ['4','5','6'] then Gain[1]:=Gain[1]+1;|56: if ss2[i] in ['7','8','9'] then Gain[2]:=Gain[2]+1;|56: if ss2[i] in ['1','4','7'] then Gain[3]:=Gain[3]+1;|56: if ss2[i] in ['2','5','8'] then Gain[4]:=Gain[4]+1;|56: if ss2[i] in ['3','6','9'] then Gain[5]:=Gain[5]+1;|56: if ss2[i] in ['1','5','9'] then Gain[6]:=Gain[6]+1;|56: if ss2[i] in ['3','5','7'] then Gain[7]:=Gain[7]+1;|5: end;|18: for i:=0 to 7 do|8: begin|22: if Gain[i]=3 then|8: begin|35: _hi_onEvent(onRes, st + '2;6');|12: Exit;|10: end;|7: end;|3: |32: for i:=0 to 7 do Gain[i]:=0; |19: for i:=1 to 4 do|74: begin |56: if ss1[i] in ['1','2','3'] then Gain[0]:=Gain[0]+1;|56: if ss1[i] in ['4','5','6'] then Gain[1]:=Gain[1]+1;|56: if ss1[i] in ['7','8','9'] then Gain[2]:=Gain[2]+1;|56: if ss1[i] in ['1','4','7'] then Gain[3]:=Gain[3]+1;|56: if ss1[i] in ['2','5','8'] then Gain[4]:=Gain[4]+1;|56: if ss1[i] in ['3','6','9'] then Gain[5]:=Gain[5]+1;|56: if ss1[i] in ['1','5','9'] then Gain[6]:=Gain[6]+1;|56: if ss1[i] in ['3','5','7'] then Gain[7]:=Gain[7]+1;|5: end;|18: for i:=0 to 7 do|8: begin|22: if Gain[i]=3 then|8: begin|35: _hi_onEvent(onRes, st + '1;7');|12: Exit;|10: end;|7: end;|3: |32: for i:=0 to 7 do Gain[i]:=0; |19: for i:=1 to 4 do|74: begin |56: if ss2[i] in ['1','2','3'] then Gain[0]:=Gain[0]+1;|56: if ss2[i] in ['4','5','6'] then Gain[1]:=Gain[1]+1;|56: if ss2[i] in ['7','8','9'] then Gain[2]:=Gain[2]+1;|56: if ss2[i] in ['1','4','7'] then Gain[3]:=Gain[3]+1;|56: if ss2[i] in ['2','5','8'] then Gain[4]:=Gain[4]+1;|56: if ss2[i] in ['3','6','9'] then Gain[5]:=Gain[5]+1;|56: if ss2[i] in ['1','5','9'] then Gain[6]:=Gain[6]+1;|56: if ss2[i] in ['3','5','7'] then Gain[7]:=Gain[7]+1;|5: end;|18: for i:=0 to 7 do|8: begin|22: if Gain[i]=3 then|8: begin|35: _hi_onEvent(onRes, st + '2;8');|12: Exit;|10: end;|9: end; |3: |32: for i:=0 to 7 do Gain[i]:=0; |19: for i:=1 to 5 do|74: begin |56: if ss1[i] in ['1','2','3'] then Gain[0]:=Gain[0]+1;|56: if ss1[i] in ['4','5','6'] then Gain[1]:=Gain[1]+1;|56: if ss1[i] in ['7','8','9'] then Gain[2]:=Gain[2]+1;|56: if ss1[i] in ['1','4','7'] then Gain[3]:=Gain[3]+1;|56: if ss1[i] in ['2','5','8'] then Gain[4]:=Gain[4]+1;|56: if ss1[i] in ['3','6','9'] then Gain[5]:=Gain[5]+1;|56: if ss1[i] in ['1','5','9'] then Gain[6]:=Gain[6]+1;|56: if ss1[i] in ['3','5','7'] then Gain[7]:=Gain[7]+1;|5: end;|18: for i:=0 to 7 do|8: begin|22: if Gain[i]=3 then|8: begin|35: _hi_onEvent(onRes, st + '1;9');|12: Exit;|10: end;|12: end; |31: _hi_onEvent(onRes,st + '0;9');|4:end;|0:|4:end.|
link(onRes,1461964:doWrite,[(396,237)(396,279)(291,279)(291,251)])
}
Add(DoData,12622426,259,294)
{
link(onEventData,10934407:doText,[(326,300)(326,321)])
link(Data,1914584:Text,[(265,222)(293,222)])
}
Add(ListBox,10934407,350,294)
{
Left=5
Top=40
Width=200
Height=460
AddType=1
}
Add(For,15357628,210,238)
{
IncludeEnd=1
link(onEvent,1461964:doRead,[])
link(onStop,12622426:doData,[(249,251)(249,300)])
link(End,1914584:Count,[(223,215)(300,215)])
}
Add(Button,1102391,161,84)
{
Left=150
Top=10
Caption="Save"
link(onClick,8735425:doExecute,[])
}
Add(SDialog,8735425,203,84)
{
Filter="TXT|*.txt"
StartDir="C:\A_WinGamesHiAsm\hiasm_4,04b186\"
FileName="Крест__Ноль.txt"
link(onExecute,1704031:doEvent1,[])
}
Add(Memory,2487976,294,84)
{
Default=String(C:\A_WinGamesHiAsm\hiasm_4,04b186\КрестНоль.txt)
}
Add(Hub,1704031,245,84)
{
link(onEvent1,11364811:doWork2,[])
link(onEvent2,1914584:doSave,[(270,97)(270,195)])
}
Add(Button,6061942,161,140)
{
Left=10
Top=10
Caption="Open"
link(onClick,10860520:doExecute,[])
}
Add(HubEx,11364811,273,84)
{
link(onEvent,2487976:doValue,[])
}
Add(ODialog,10860520,203,140)
{
Filter="TXT|*.txt"
StartDir="C:\A_WinGamesHiAsm\hiasm_4,04b186\."
FileName="КрестНоль.txt"
link(onExecute,2054965:doEvent1,[])
}

карма: 19

0