本文整理汇总了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;
}
示例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();
}