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


C# Field.Apply方法代码示例

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


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

示例1: GetFields

		public IEnumerable<Field> GetFields(Field field, Block current)
		{
			// If not enough space, try these too.
			if (field.FirstFilled < 4)
			{
				foreach (var candidate in GetEndgamePaths(field, current))
				{
					yield return candidate.Field;
				}
			}
			else
			{
				foreach (var candidate in GetReachableHoles(field, current))
				{
					yield return candidate.Field;
				}

				foreach (var block in current.Variations)
				{
					int minRow = block.GetMinRow(field);
					int maxRow = block.GetMaxRow(field);

					foreach (var col in block.GetColumns(field))
					{
						for (var row = minRow; row <= maxRow; row++)
						{
							var test = field.Test(block, col, row);
							if (test == Field.TestResult.True)
							{
								var target = new Position(col, row);
								var applied = field.Apply(block, target);
								yield return applied;
							}
							if (test != Field.TestResult.Retry)
							{
								row = short.MaxValue;
							}
						}
					}
				}
			}
			if (field.Skips > 0)
			{
				yield return field.SkipBlock();
			}
		}
开发者ID:Corniel,项目名称:AIGames.BlockBattle.Kubisme,代码行数:46,代码来源:MoveGenerator.cs

示例2: TurnRight

		private static void TurnRight(string[] exp, Block block, Position position, Field field)
		{
			var act = new string[5];
			act[0] = field.Apply(block, position).ToString();

			for (var i = 1; i < 5; i++)
			{
				position = block.TurnRight(position);
				block = block.TurnRight();
				var apply = field.Apply(block, position).ToString();
				act[i] = apply;

				Console.WriteLine(apply.Replace("|", Environment.NewLine));
				Console.WriteLine();
			}

			foreach (var f in act)
			{
				Console.WriteLine('"' + f + '"' + ',');
			}
			CollectionAssert.AreEqual(exp, act);
		}
开发者ID:Corniel,项目名称:AIGames.BlockBattle.Kubisme,代码行数:22,代码来源:BlockRotationTest.cs

示例3: CopyTo

 public virtual void CopyTo(Field field)
 {
     field.Apply(this);
     
     if (this.Validator != null)
     {
         field.Validator.Fn = this.Validator;
     }
 }
开发者ID:shalves,项目名称:Ext.NET.Community,代码行数:9,代码来源:FieldDefaultsAttribute.cs

示例4: GetPaths

		public static IEnumerable<MoveCandiate> GetPaths(Field field, Block current, int[] targets, int maxRow)
		{
			var dones = new bool[current.RotationVariations.Length, field.RowCount + 1, 10];

			TempPath first = current.GetFirstTempPath(field.FirstFilled);
			dones[0, first.Position.Row + 1, first.Position.Col] = true;

			var stack = new Stack<TempPath>();
			stack.Push(first);

			while (stack.Count != 0)
			{
				var temp = stack.Pop();

				if (temp.Position.Row > maxRow) { continue; }

				var test = field.Test(temp.Block, temp.Position);

				// No reason the investigate
				if (test == Field.TestResult.False) { continue; }

				var tr = temp.TurnRight();
				if (tr.Position.Col >= 0 && tr.Position.Col <= tr.Block.ColumnMaximum &&
					!dones[(int)tr.Block.Rotation, tr.Position.Row + 1, tr.Position.Col])
				{
					dones[(int)tr.Block.Rotation, tr.Position.Row + 1, tr.Position.Col] = true;
					stack.Push(tr);
				}

				var tl = temp.TurnLeft();
				if (tl.Position.Col >= 0 && tl.Position.Col <= tl.Block.ColumnMaximum &&
					!dones[(int)tl.Block.Rotation, tl.Position.Row + 1, tl.Position.Col])
				{
					dones[(int)tl.Block.Rotation, tl.Position.Row + 1, tl.Position.Col] = true;
					stack.Push(tl);
				}

				if (temp.Position.Col < temp.Block.ColumnMaximum && !dones[(int)temp.Block.Rotation, temp.Position.Row + 1, temp.Position.Col + 1])
				{
					dones[(int)temp.Block.Rotation, temp.Position.Row + 1, temp.Position.Col + 1] = true;
					stack.Push(temp.Right());
				}

				if (temp.Position.Col > 0 && !dones[(int)temp.Block.Rotation, temp.Position.Row + 1, temp.Position.Col - 1])
				{
					dones[(int)temp.Block.Rotation, temp.Position.Row + 1, temp.Position.Col - 1] = true;
					stack.Push(temp.Left());
				}

				// we have a fit.
				if (test == Field.TestResult.True)
				{
					if (temp.Block.TouchPosition(temp.Position, targets))
					{
						var unique = temp.Block.Variations.Length == temp.Block.RotationVariations.Length;

						// if the block is rotation only, first check if counter part did not arrive already.
						if (!unique)
						{
							var rot_org = (int)temp.Block.Rotation & 1;
							var rot_acc = rot_org | 2;

							unique =
								dones[rot_org, temp.Position.Row + 1, temp.Position.Col] ^
								dones[rot_acc, temp.Position.Row + 1, temp.Position.Col];
						}
						if (unique)
						{
							var apply = field.Apply(temp.Block, temp.Position);
							yield return new MoveCandiate(temp.Path, apply);
						}
					}
				}
				else
				{
					if (!dones[(int)temp.Block.Rotation, temp.Position.Row + 2, temp.Position.Col])
					{
						dones[(int)temp.Block.Rotation, temp.Position.Row + 2, temp.Position.Col] = true;
						stack.Push(temp.Down());
					}
				}
			}
		}
开发者ID:Corniel,项目名称:AIGames.BlockBattle.Kubisme,代码行数:83,代码来源:MoveGenerator.cs


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