<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=3531439</guid>
        <pubDate>Fri, 03 Oct 2014 06:29:15 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=3531439</link>
        <description><![CDATA[ujif: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=9552&view=findpost&p=3531427'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>leo &#064; <time class="tag-quote__quoted-time" datetime="2014-10-03T08:47:27+04:00">03.10.14, 04:47</time></span><div class='quote '></div></div><br>
Спасибо Уважаемый Leo за поддержку]]></description>
        <author>ujif</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=3531427</guid>
        <pubDate>Fri, 03 Oct 2014 04:47:27 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=3531427</link>
        <description><![CDATA[leo: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=9552&view=findpost&p=3531396'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>ujif &#064; <time class="tag-quote__quoted-time" datetime="2014-10-02T18:47:12+00:00">02.10.14, 18:47</time></span><div class='quote '>программа вылетает на строке<br>
while nbit[i]=0 do inc(i);</div></div><br>
Выход за пределы диапазона. Нужно так:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">while (i &#60;= High(nbit)) and (nbit[i]=0) do inc(i);</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=9552&view=findpost&p=3531396'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>ujif &#064; <time class="tag-quote__quoted-time" datetime="2014-10-02T18:47:12+00:00">02.10.14, 18:47</time></span><div class='quote '>почему у ncbit двойной индекс ,массив вроде не двумерный</div></div><br>
Двумерный:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">ncbit : array [1..MAXROW] of BitType; {= array[1..MAXROW] of array [1..BIT] of integer = array[1..MAXROW,1..BIT] of integer;}</div></ol></div></div></div></div>]]></description>
        <author>leo</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=3531396</guid>
        <pubDate>Thu, 02 Oct 2014 18:47:12 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=3531396</link>
        <description><![CDATA[ujif: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=9552&view=findpost&p=92595'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>pascal.km.ru &#064; <time class="tag-quote__quoted-time" datetime="2003-02-25T20:50:40+00:00">25.02.03, 20:50</time></span><div class='quote '></div></div><br>
в процедуре ChooseMove<br>
программа вылетает на строке<br>
  while nbit[i]=0 do inc(i); <br>
 с кодом 201 если вводишь<br>
 в самом начале игры следующие данные<br>
 ряд - 1 ,кол-во фишек кот.нужно убрать - 2<br>
 поле построено 3 - 4 - 5<br>
  Плохо что нет объяснения что делает следующая строка<br>
    for j := 1 to nrow do nbit[i] := nbit[i] xor ncbit[j,i] <br>
   почему у ncbit двойной индекс ,массив вроде не двумерный<br>
   вообще бы хотелось более подробного объяснения процедуры<br>
  ChooseMove]]></description>
        <author>ujif</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=655255</guid>
        <pubDate>Wed, 23 Mar 2005 10:55:08 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=655255</link>
        <description><![CDATA[Artem: Есть хорошее описание этой игры на сайте http://potential.org.ru<br><br><br>Игра Ним или как математики играют в игры <br>http://potential.org.ru/bin/view/Info/ArtDt200502101334PH3C2J2<br><br><br><br>Там описан общий принцип определения стратегии для конечных нейтральных игр.<br><br>И описан алгоритм вычисления Нимберсов для таких игр.<br><br>А на сайте http://acm.mipt.ru/judge есть несколько задач про игры<br><br> 1 Ним  http://acm.mipt.ru/judge/bin/problems.pl?problem=100&sort=ID&lang=ru<br> 2 Камешки  http://acm.mipt.ru/judge/bin/problems.pl?problem=101&sort=ID&lang=ru<br> 2 Ним в поддавки   (кстати, очень интересная штука) http://acm.mipt.ru/judge/bin/problems.pl?problem=103&sort=ID&lang=ru<br> 3 Ромашки  http://acm.mipt.ru/judge/bin/problems.pl?problem=104&sort=ID&lang=ru<br><br>так что свои коды вы можете постить туда, а система автоматически проверит, насколько они рабочие.]]></description>
        <author>Artem</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92596</guid>
        <pubDate>Wed, 26 Feb 2003 07:11:40 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92596</link>
        <description><![CDATA[cnyx: Большое спасибо всем кто ответил. Вы мне очень помогли.<br>З.Ы.<br>Я студент-заочник. Я не говорил, что мне нужет ИИ. Просто предмет называется СИИ. Но большей частью будем изучать экспертные системы. Еще раз спасибо.<br>З.З.Ы.<br>Я не знаю, что что за игра &quot;НИМ&quot;. Может она на кваку похожа, но так в задании написано. Тут я полностью полагался на препода, который давал задание.]]></description>
        <author>cnyx</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92595</guid>
        <pubDate>Tue, 25 Feb 2003 20:50:40 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92595</link>
        <description><![CDATA[pascal.km.ru: <span class="tag-color tag-color-named" data-value="red" style="color: red">исправлено by GrAnd</span><br>{Логическая игра &nbsp;ним. Описание игры и программы см. п.2.7.3 книги 1} <br>Uses CRT; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {подключение библиотеки дополнительных <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; процедур и функций для управления экраном} <br>const <br> &nbsp;MAXROW = 14; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{максимальное количество рядов} <br> &nbsp;MAXCOL = 20; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{максимальное количество фишек в ряду} <br>type <br> &nbsp;ColType &nbsp; = array [1..MAXROW] of integer; <br>var <br> &nbsp;exit &nbsp; : Boolean; &nbsp; &nbsp; {признак окончания работы} <br> &nbsp;change : Boolean; &nbsp; &nbsp; {признак изменения условий игры} <br> &nbsp;nrow &nbsp; : integer; &nbsp; &nbsp; {количество рядов} <br> &nbsp;ncol &nbsp; : ColType; &nbsp; &nbsp; {м ксимальное количество фишек по рядам} <br> &nbsp;col &nbsp; &nbsp;: ColType; &nbsp; &nbsp; {текущее количество фишек по рядам} <br>{------------------------------------------------------------} <br>Procedure ShowField; <br>{ Отобр ж ет н &nbsp;экр не текущее состояние игрового поля } <br>const <br> &nbsp;FISH = #220; &nbsp; &nbsp; &nbsp;{ символ-указатель фишки } <br> &nbsp;X0 &nbsp; = 4; &nbsp; &nbsp; &nbsp; &nbsp; { левая колонка &nbsp;номеров рядов } <br> &nbsp;X1 &nbsp; = 72; &nbsp; &nbsp; &nbsp; &nbsp;{ прав я колонка &nbsp;количеств &nbsp;фишек } <br> &nbsp;X &nbsp; &nbsp;= 20; &nbsp; &nbsp; &nbsp; &nbsp;{ левый край игрового поля } <br>var <br> &nbsp;i,j : integer; <br>begin {ShowField} <br> &nbsp;for i := 1 to nrow do <br> &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp;GotoXY(X0,i+4); <br> &nbsp; &nbsp; &nbsp;write(i); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ номер ряда } <br> &nbsp; &nbsp; &nbsp;GotoXY(X1,i+4); <br> &nbsp; &nbsp; &nbsp;write(col[i]:2); &nbsp; &nbsp; &nbsp; &nbsp; { количество фишек в ряду } <br> &nbsp; &nbsp; &nbsp;for j := 1 to ncol[i] do { вывод ряда фишек:} <br> &nbsp; &nbsp; &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GotoXY(X+2*j,i+4); <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if j&lt;=col[i] then write(FISH) else write('.') <br> &nbsp; &nbsp; &nbsp; &nbsp;end <br> &nbsp; &nbsp;end <br>end; &nbsp;{ShowField} <br>{------------------------------------------------------------} <br>Procedure Prepare; <br>{ Подготовка &nbsp;данных и формирование экрана } <br>const <br> &nbsp;Header0 = 'И Г Р А &nbsp; Н И М'; <br> &nbsp;Header1 = 'Вы можете взять любое число фишек из любого ряд .'; <br> &nbsp;Header2 = 'Выигрывает тот, кто возьмет последнюю фишку.'; <br> &nbsp;Header3 = 'Номер ряд '; <br> &nbsp;Header4 = 'Кол-во фишек'; <br>var <br> &nbsp;i : integer; <br>begin {Prepare} <br> &nbsp;clrscr; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { очистить экран } <br> &nbsp;{ Вывести з головок: } <br> &nbsp;GotoXY((80-Length(Header0)) div 2,1); <br> &nbsp;write(Header0); <br> &nbsp;GotoXY((80-Length(Header1)) div 2,2); <br> &nbsp;write(Header1); <br> &nbsp;GotoXY((80-Length(Header2)) div 2,3); <br> &nbsp;writeln(Header2); <br> &nbsp;write(Header3); <br> &nbsp;GotoXY(80-Length(Header4),4); <br> &nbsp;write(Header4); <br> &nbsp;{ Подготовить начальную раскладку: } <br> &nbsp;for i := 1 to nrow do col[i] := ncol[i] <br>end; &nbsp;{Prepare} <br>{------------------------------------------------------------} <br>Procedure GetPlayerMove; <br>{ Получить, проконтролировать и отобразить ход игрок &nbsp;} <br>const <br> &nbsp;TEXT1 = 'Введите В ш ход в форм те РЯД КОЛИЧ (н пример, 2 3 - взять из 2 ряд &nbsp;3 фишки)'; <br> &nbsp;TEXT2 = 'или введите 0 0 для выход &nbsp;из игры; -1 0 для н стройки игры'; <br> &nbsp;TEXT3 = 'В ш ход: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '; <br> &nbsp;Y &nbsp; &nbsp; = 20; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{номер строки для вывод &nbsp;сообщений} <br>var <br> &nbsp;correctly : Boolean; &nbsp; {признак правильности сделанного ход } <br> &nbsp;x1,x2 &nbsp; &nbsp; : integer; &nbsp; {вводимый ход} <br>{-------------------------------------} <br>Procedure GetChange; <br>{ Ввести новую настройку игры (количество рядов и <br> &nbsp;количество фишек в каждом ряду } <br>const <br> &nbsp;t1 = 'Н А С Т Р О Й К А &nbsp; &nbsp;И Г Р Ы'; <br> &nbsp;t2 = '(ввод количеств &nbsp;рядов и количеств &nbsp;фишек в каждом ряду)'; <br>var <br> &nbsp;correctly : Boolean; <br> &nbsp;i &nbsp; &nbsp; &nbsp; &nbsp; : integer; <br>begin {GetChange} <br> &nbsp;clrscr; <br> &nbsp;GotoXY((80-Length(t1)) div 2,1); <br> &nbsp;write(t1); <br> &nbsp;GotoXY((80-Length(t2)) div 2,2); <br> &nbsp;write(t2); <br> &nbsp;repeat <br> &nbsp; &nbsp;GotoXY(1,3); <br> &nbsp; &nbsp;write('Введите количество рядов (максимум ',MAXROW,'): &nbsp; &nbsp; &nbsp;'); <br> &nbsp; &nbsp;GotoXY(WhereX-6,WhereY); <br> &nbsp; &nbsp;readln(nrow); <br> &nbsp; &nbsp;correctly := (nrow&lt;=MAXROW) and (nrow&gt;1); <br> &nbsp; &nbsp;if not correctly then <br> &nbsp; &nbsp; &nbsp;write(#7) <br> &nbsp;until correctly; <br> &nbsp;for i := 1 to nrow do <br> &nbsp; &nbsp;repeat <br> &nbsp; &nbsp; &nbsp;GotoXY(1,i+3); <br> &nbsp; &nbsp; &nbsp;write(' ряд ',i,', количество фишек (максимум ',MAXCOL,'): &nbsp; &nbsp; &nbsp; '); <br> &nbsp; &nbsp; &nbsp;GotoXY(WhereX-6,WhereY); <br> &nbsp; &nbsp; &nbsp;readln(ncol[i]); <br> &nbsp; &nbsp; &nbsp;correctly := (ncol[i]&lt;=MAXCOL) and (ncol[i]&gt;0); <br> &nbsp; &nbsp; &nbsp;if not correctly then <br> &nbsp; &nbsp; &nbsp; &nbsp;write(#7) <br> &nbsp; &nbsp;until correctly <br>end; &nbsp;{GetChange} <br>{-------------------------------------} <br>begin {GetPlayerMove} <br> &nbsp;ShowField; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ показать начальное состояние поля } <br> &nbsp;{ Сообщить игроку пр вил &nbsp;ввод &nbsp;ход : } <br> &nbsp;GotoXY((80-Length(TEXT1)) div 2,Y); <br> &nbsp;write(TEXT1); <br> &nbsp;GotoXY((80-Length(TEXT2)) div 2,Y+1); <br> &nbsp;write(TEXT2); <br> &nbsp;repeat <br> &nbsp; &nbsp;{ Пригл сить игрок &nbsp;ввести ход: } <br> &nbsp; &nbsp;GotoXY(1,Y+2); <br> &nbsp; &nbsp;write(TEXT3); &nbsp; &nbsp; &nbsp; &nbsp;{вывести приглашение и стереть предыдущий ход} <br> &nbsp; &nbsp;GotoXY(WhereX-16,Y+2); {курсор влево н &nbsp;16 позиций} <br> &nbsp; &nbsp;readln(x1,x2); &nbsp; &nbsp; &nbsp; {ввести очередной ход} <br> &nbsp; &nbsp;exit &nbsp; := x1=0; &nbsp; &nbsp; &nbsp;{контроль команды выход } <br> &nbsp; &nbsp;change := x1=-1; &nbsp; &nbsp; {контроль команды изменения} <br> &nbsp; &nbsp;if not (exit or change) then <br> &nbsp; &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp; &nbsp;correctly := (x1&gt;0) and (x1&lt;=nrow) and <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (x2&lt;=col[x1]) and (x2&gt;0); <br> &nbsp; &nbsp; &nbsp; &nbsp;if correctly then <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ход пр вильный:} <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;col[x1] := col[x1]-x2; {изменить раскладку фишек} <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowField &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{показать поле} <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end <br> &nbsp; &nbsp; &nbsp; &nbsp;else <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;write(#7) &nbsp; &nbsp; &nbsp;{ход неправильный: дать звуковой сигнал } <br> &nbsp; &nbsp; &nbsp;end <br> &nbsp; &nbsp;else <br> &nbsp; &nbsp; &nbsp;correctly := true &nbsp;{случай EXIT или CHANGE} <br> &nbsp;until correctly; <br> &nbsp;if change then <br> &nbsp; &nbsp;GetChange <br>end; &nbsp;{GetPlayerMove} <br>{------------------------------------------------------------} <br>Procedure SetOwnerMove; <br>{ Найти и отобразить очередной ход программы } <br>{-------------------------------------} <br>FUNCTION CheckField : integer; <br>{ Проверка &nbsp;состояния игры. Возвращает 0, если нет ни одной <br> &nbsp;фишки (побед &nbsp;игрок ), 1 - есть один ряд (побед &nbsp;м шины) <br> &nbsp;и количество непустых рядов в остальных случаях } <br>var <br> &nbsp;i,j : integer; <br>begin {CheckField} &nbsp;<br> &nbsp;j := 0; <br> &nbsp;for i := 1 to nrow do if col[i]&gt;0 then inc(j); <br> &nbsp;CheckField := j <br>end; &nbsp;{CheckField} <br>{-------------------------------------} <br>Procedure CheckPlay; <br>{ Контроль оконч ния игры } <br>var <br> &nbsp;i : integer; <br>begin {CheckPlay} <br> &nbsp;GotoXY(1,25); <br> &nbsp;write('Введите 1, если хотите сыграть еще раз, 0 - выход: '); <br> &nbsp;readln(i); <br> &nbsp;if i=1 then change := true else exit := true <br>end; &nbsp;{CheckPlay} <br>{-------------------------------------} <br>Procedure PlayerVictory; <br>{ Поздравить игрок &nbsp;с победой и усложнить игру } <br>const <br> &nbsp;t1 = 'ПОЗДРАВЛЯЮ С ОТЛИЧНОЙ ПОБЕДОЙ!'; <br>var i : integer; <br>begin <br> &nbsp;GotoXY((80-Length(t1)) div 2,24); <br> &nbsp;writeln(t1,#7); <br> &nbsp;for i := 1 to nrow do <br> &nbsp; &nbsp;if ncol[i]&lt;MAXROW then inc(ncol[i]); <br> &nbsp;CheckPlay <br>end; &nbsp;{PlayerVictory} <br>{-------------------------------------} <br>Procedure OwnVictory; <br>{ Побед &nbsp;м шины } <br>const <br> &nbsp;t1 = 'ВЫ ПРОИГРАЛИ: СЛЕДУЮЩИМ ХОДОМ Я БЕРУ ВЕСЬ РЯД '; <br>var <br> &nbsp;i : integer; <br>begin {OwnVictory} <br> &nbsp;i := 1; <br> &nbsp;while col[i]=0 do inc(i); <br> &nbsp;GotoXY((80-Length(t1)) div 2,24); <br> &nbsp;write(t1,i,#7); <br> &nbsp;delay(2000); &nbsp; &nbsp; {задержка на 2 секунды} <br> &nbsp;col[i] := 0; <br> &nbsp;ShowField; <br> &nbsp;CheckPlay <br>end; &nbsp;{OwnVictory} <br>{-------------------------------------} <br>Procedure ChooseMove; <br>{ Выбор очередного ход &nbsp;} <br>const <br> &nbsp;BIT = 6; &nbsp; &nbsp; &nbsp; &nbsp; {количество двоичных разрядов} <br>type <br> &nbsp;BitType = array [1..BIT] of integer; <br>var <br> &nbsp;ncbit : array [1..MAXROW] of BitType; <br> &nbsp;i,j,k : integer; <br> &nbsp;nbit &nbsp;: BitType; <br>{-------------------------------------} <br>Procedure BitForm(n : integer; var b : BitType); <br>{ Формирует двоичное представление b целого числа &nbsp;n } <br>var <br> &nbsp;i : integer; <br>begin {BitForm} <br> &nbsp;for i := BIT downto 1 do <br> &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp;if odd(n) then b[i] := 1 else b[i] := 0; <br> &nbsp; &nbsp; &nbsp;n := n shr 1 <br> &nbsp; &nbsp;end <br>end; &nbsp;{BitForm} <br>{-------------------------------------} <br>begin {ChooseMove} <br> &nbsp;{Найти двоичное представление количеств &nbsp;фишек во всех ряд х:} <br> &nbsp;for i := 1 to nrow do BitForm(col[i],ncbit[i]); <br> &nbsp;{Найти сумму разрядов по модулю 2:} <br> &nbsp;for i := 1 to BIT do <br> &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp;nbit[i] := 0; <br> &nbsp; &nbsp; &nbsp;for j := 1 to nrow do nbit[i] := nbit[i] xor ncbit[j,i] <br> &nbsp; &nbsp;end; <br> &nbsp;{Н йти i = старший ненулевой разряд суммы} <br> &nbsp;i := 1; <br> &nbsp;while nbit[i]=0 do inc(i); <br> &nbsp;if i&gt;BIT then <br> &nbsp; &nbsp;{Оп сный в ри нт} <br> &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp;j := 1; <br> &nbsp; &nbsp; &nbsp;while col[j]=0 do inc(j); &nbsp; {найти ненулевой ряд} <br> &nbsp; &nbsp; &nbsp;k := 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{взять из него 1 фишку} <br> &nbsp; &nbsp;end <br> &nbsp;else <br> &nbsp; &nbsp;{Безоп сный в ри нт} <br> &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp;j := 1; <br> &nbsp; &nbsp; &nbsp;while ncbit[j,i]=0 do inc(j); {найти нужный ряд} <br> &nbsp; &nbsp; &nbsp;for i := i to BIT do <br> &nbsp; &nbsp; &nbsp; &nbsp;if nbit[i]=1 then <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ncbit[j,i] := ord(ncbit[j,i]=0); {инверсия разрядов} <br> &nbsp; &nbsp; &nbsp;k := 0; <br> &nbsp; &nbsp; &nbsp;for i := 1 to BIT do <br> &nbsp; &nbsp; &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ncbit[j,i]=1 then inc(k); <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if i&lt;BIT then k := k shl 1 <br> &nbsp; &nbsp; &nbsp; &nbsp;end; <br> &nbsp; &nbsp; &nbsp;k := col[j] - k <br> &nbsp; &nbsp;end; <br> &nbsp; &nbsp;GotoXY(1,23); <br> &nbsp; &nbsp;write('Мой ход: &nbsp; &nbsp; &nbsp; &nbsp; '); <br> &nbsp; &nbsp;GotoXY(WhereX-8,WhereY); <br> &nbsp; &nbsp;delay(1000); <br> &nbsp; &nbsp;write(j,' ',k); <br> &nbsp; &nbsp;col[j] := col[j]-k <br>end; &nbsp;{ChooseMove} <br>{-------------------------------------} <br>begin {SetOwnerMove} <br> &nbsp;case CheckField of &nbsp; &nbsp; &nbsp;{проверить количество непустых рядов} <br> &nbsp; &nbsp;0 : PlayerVictory; &nbsp; &nbsp;{все ряды пусты - побед &nbsp;игрок } <br> &nbsp; &nbsp;1 : OwnVictory; &nbsp; &nbsp; &nbsp; {один непустой ряд - побед &nbsp;м шины} <br> &nbsp; &nbsp;else <br> &nbsp; &nbsp; &nbsp;ChooseMove; &nbsp; &nbsp; &nbsp; &nbsp; {выбрать очередной ход} <br> &nbsp;end; {case} <br>end; &nbsp;{SetOwnerMove} <br>{------------------------------------------------------------} <br>begin {Гл вн я прогр мм } <br> &nbsp;nrow := 3; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ Подготовить игру } <br> &nbsp;ncol[1] := 3; &nbsp; &nbsp; &nbsp; &nbsp; { н &nbsp;поле из трех &nbsp;} <br> &nbsp;ncol[2] := 4; &nbsp; &nbsp; &nbsp; &nbsp; { рядов фишек &nbsp; &nbsp; &nbsp;} <br> &nbsp;ncol[3] := 5; <br> &nbsp;repeat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ Цикл изменения условий игры } <br> &nbsp; &nbsp;Prepare; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ Подготовить экран } <br> &nbsp; &nbsp;repeat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ Игровой цикл } <br> &nbsp; &nbsp; &nbsp;GetPlayerMove; &nbsp; &nbsp;{ Получить ход пользователя } <br> &nbsp; &nbsp; &nbsp;if not (exit or change) then <br> &nbsp; &nbsp; &nbsp; &nbsp;SetOwnerMove &nbsp; &nbsp;{ Определить собственный ход } <br> &nbsp; &nbsp;until exit or change <br> &nbsp;until exit <br>end.<br>Вот полный текст программы, о который вы говорили.... Также можно скачать здесь : http://c-l-a-n-e.narod.ru/NIM.PAS]]></description>
        <author>pascal.km.ru</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92594</guid>
        <pubDate>Tue, 25 Feb 2003 20:33:10 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92594</link>
        <description><![CDATA[albom: Возможно, но я такой книги не читал.]]></description>
        <author>albom</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92592</guid>
        <pubDate>Tue, 25 Feb 2003 20:23:48 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92592</link>
        <description><![CDATA[pascal.km.ru: По-моему пример этой игры был в книге Фаронова по Турбо Паскалю.....]]></description>
        <author>pascal.km.ru</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92591</guid>
        <pubDate>Tue, 25 Feb 2003 19:53:55 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92591</link>
        <description><![CDATA[albom: Могу ошибаться, но это игра - модифицированная игра Баше.<br>
А вот игра НИМ сложнее.<br>
Там есть несколько кучек, брать за ход можно только из одной.<br>
К этой игре уже можно ИИ приделать (хотя зачем?).<br>
<br>
<br>
Есть хороший исходник для TP7: <a class='tag-url' href='http://albom.nm.ru/nim.pas' target='_blank'>http://albom.nm.ru/nim.pas</a>.<br>
]]></description>
        <author>albom</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92590</guid>
        <pubDate>Tue, 25 Feb 2003 17:23:33 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92590</link>
        <description><![CDATA[esperanto: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <span class='tag-quote__quote-info'>ozzy, 25.02.03, 12:03:10</span><div class='quote '>Форсайт &quot;Программирование на языке Паскаль&quot;<br>Выйду с больничного, могу выслать текст программы.</div></div><br><br>какой текст<br><br>вся программа две строчки<br><br><br>алгоритм простой за каждые два хода твой и его ты всегда можешь гарантировать в сумме м+1 камень что и ведет к выигрышу<br><br>только это ни какой не ИИ, поэтому не понятно что вы хотите<br>]]></description>
        <author>esperanto</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92589</guid>
        <pubDate>Tue, 25 Feb 2003 09:03:10 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92589</link>
        <description><![CDATA[Булат Шакиров: Форсайт &quot;Программирование на языке Паскаль&quot;<br>Выйду с больничного, могу выслать текст программы.]]></description>
        <author>Булат Шакиров</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92588</guid>
        <pubDate>Tue, 25 Feb 2003 08:50:16 +0000</pubDate>
        <title>Алгоритм для игры &amp;quot;НИМ&amp;quot;.</title>
        <link>https://forum.sources.ru/index.php?showtopic=9552&amp;view=findpost&amp;p=92588</link>
        <description><![CDATA[cnyx: Алгоритм для игры &quot;НИМ&quot; (иногда камни или спички). Дано n спичек, максимум можно брать по m спичек. Игроков 2-е. Проигрывает тот, кто берет последнюю спичку. Подскажите, пожалуйста, алгоритм выйгрыша. Мне это надо по предмету &quot;Системы искусственного интеллекта&quot;. Буду благодарен за любую информацию.]]></description>
        <author>cnyx</author>
        <category>Алгоритмы</category>
      </item>
	
      </channel>
      </rss>
	