当前位置: 首页>>代码示例>>C#>>正文


C# State.Move方法代码示例

本文整理汇总了C#中State.Move方法的典型用法代码示例。如果您正苦于以下问题:C# State.Move方法的具体用法?C# State.Move怎么用?C# State.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在State的用法示例。


在下文中一共展示了State.Move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Successors

 /// <summary>
 /// List of possible successor states.
 /// </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 private Dictionary<int, State> Successors(State state)
 {
     Dictionary<int, State> succ = new Dictionary<int, State>(7);
     for(int i = 1; i <= 7; i++)
     {
         State s = state.Move(i);
         if (s != null) succ.Add(i, s);  // if move is valid add it to succ.
     }
     return succ;
 }
开发者ID:paiston,项目名称:oldcrap,代码行数:15,代码来源:Computer.cs

示例2: StartSearch

 //�������� ������� ����������� �����
 protected override void StartSearch()
 {
     Started();
        /* if (!DoHaveResolve(_start))
             Progressing("������� �� �����. ������� �� ������");
         else*/
         {
             SearchIDA searchIDA = new SearchIDA();
             State state = new State();
             for (int i = 0; i < SearchBase.Dimension * SearchBase.Dimension; ++i)
             {
                 int value = _start[i];
                 value++;
                 if (value != SearchBase.Dimension * SearchBase.Dimension)
                     state.SetCell(i / SearchBase.Dimension, i % SearchBase.Dimension, value);
                 else
                     state.SetEmpty(i / SearchBase.Dimension, i % SearchBase.Dimension);
             }
             searchIDA._state.m_cells = (uint[,])state.m_cells.Clone();
             searchIDA._state.m_emptyX = state.m_emptyX;
             searchIDA._state.m_emptyY = state.m_emptyY;
             _countStates = 0;
             //����� ����� ������������ ����
             List<Move> solution = searchIDA.GetOptimalSolution();
             //�� �������� ����� ����������� �� ������� ������� � ���������
             solution.Reverse();
             arResult = new int[solution.Count + 1][];
             arResult[0] = _start;
             int arIndex = 1;
             foreach (Move m in solution)
             {
                 state.Move(m);
                 arResult[arIndex] = new int[SearchBase.Dimension * SearchBase.Dimension];
                 int j = 0;
                 for (int ii = 0; ii < SearchBase.Dimension; ii++)
                     for (int jj = 0; jj < SearchBase.Dimension; jj++, j++)
                     {
                         if (ii == state.m_emptyX &&
                             jj == state.m_emptyY)
                             arResult[arIndex][j] = SearchBase.Dimension * SearchBase.Dimension - 1;
                         else
                             arResult[arIndex][j] = (int)state.m_cells[ii, jj];// - 1;
                     }
                 arIndex++;
             }
             TimeSpan timeSearch = DateTime.Now - timeStart;
             if (arResult.Length - 1 != 0)
             {
                 int v=(arResult.Length - 1)%10;
                 string st = (v == 2 || v == 3 || v == 4) ? " ����" : ((v == 1) ? " ���" : " �����");
                 Progressing("����",
                     "�����. " + Environment.NewLine + (arResult.Length).ToString(CultureInfo.InvariantCulture) +
                     st+Environment.NewLine + "�����:" + timeSearch.ToString() +
                     Environment.NewLine + "\n����� ���-�� ������������� ���������\t: " +
                     _countStates.ToString(CultureInfo.InvariantCulture) +
                     Environment.NewLine + "\n**** ����� �������� ****" +
                     Environment.NewLine + "\n����� ������\t: " + timeSearch.ToString() +
                     Environment.NewLine + "\n���-�� ����� ��� ����� �������\t: " +
                     (arResult.Length ).ToString(CultureInfo.InvariantCulture) +
                     Environment.NewLine + "\n  �� ������ ������ ������ \n(��� Ctrl+P) � ��������� ������� ����������� �����.");
             }
             else
                 Progressing("� ��� � ������ ������ ?");
         }
         Finished();
 }
开发者ID:densem-2013,项目名称:FifteenImage,代码行数:67,代码来源:Cod.cs


注:本文中的State.Move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。