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


C# RuleSet.GetBleedValue方法代码示例

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


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

示例1: BleedValue

		private bool BleedValue(RuleSet rule, RuleValue value, Direction direction)
		{
			int x, y;
			if(rule.mID == RuleID.RI_ROW)
			{
				x = direction == Direction.RIGHT ? value.minIndex : value.maxIndex;
				y = rule.mIndex;
			}
			else
			{
				x = rule.mIndex;
				y = direction == Direction.DOWN ? value.minIndex : value.maxIndex;
			}
			int idx = GetIndex(x, y);

			// Have we already found our start position?
			if (mBoard[idx] == SquareType.ST_BLACK)
			{
				bool canContinue = false;
				for (int i = 0; i < value.mValue; ++i)
				{
					SetBoardValue(idx, SquareType.ST_BLACK);
					value.AddIndex(idx);
					canContinue = ShiftIndex(ref idx, direction);
				}
				if (canContinue)
					SetBoardValue(idx, SquareType.ST_WHITE);

				value.ClampMinMax(rule.GetBleedValue(x, y), value.mValue - 1, direction);

				return true;
			}

			bool foundPortion = false;
			bool isValid = false;
			for (int i = 0; i < value.mValue; ++i)
			{
				if (mBoard[idx] == SquareType.ST_UNKNOWN)
				{
					if (foundPortion) // If we already found a portion of ourselves, it's impossible for this to not be black
					{
						SetBoardValue(idx, SquareType.ST_BLACK);
						//if (direction == Direction.RIGHT || direction == Direction.DOWN)
						//value.ClampMinMax(i + (value.mValue - 1));
						value.ClampMinMax(rule.GetBleedValue(x, y),  i + (value.mValue - 1), direction);
						//else
						//	value.ClampMinMax(value.maxIndex - i - (value.mValue - 1));
					}
					isValid = ShiftIndex(ref idx, direction);

					continue;
				}

				if (mBoard[idx] == SquareType.ST_WHITE) // It's not possible to fit in this space. Blank it out, and move ourselves forward
				{
					Debug.Assert(foundPortion == false); // It shouldn't be possible to have found a portion of ourselves, and then run out of room.

					int initIdx = GetIndex(x, y);
					for (int j = 0; j < i; ++j)
					{
						SetBoardValue(initIdx, SquareType.ST_WHITE);
						ShiftIndex(ref initIdx, direction);
					}

					if (direction == Direction.RIGHT || direction == Direction.DOWN)
						value.minIndex += (i + 1);
					else
						value.maxIndex -= (i+1);

					return BleedValue(rule, value, direction);
				}

				if (mBoard[idx] == SquareType.ST_BLACK)
				{
					if (!foundPortion) // special case. We can sometimes reduce our max range by 1 if this would make two black runs collide
					{
						int p;
						if (GetIndexOffset(idx, value.mValue, direction, rule, out p))
						{
							if (mBoard[p] == SquareType.ST_BLACK)
							{
								value.ClampMinMax(rule.GetBleedValue(x, y), i + (value.mValue - 2), direction);
							}
						}
					}

					foundPortion = true;
					//if (direction == Direction.RIGHT || direction == Direction.DOWN)
					//	value.SetMaxIndex(value.minIndex + i + (value.mValue - 1));
					//else
					//	value.SetMinIndex(value.maxIndex - i - (value.mValue - 1));
					value.ClampMinMax(rule.GetBleedValue(x, y), i + (value.mValue - 1), direction);
				}

				isValid = ShiftIndex(ref idx, direction);
			}

			if (isValid)
			{
				if (foundPortion && mBoard[idx] == SquareType.ST_WHITE)
//.........这里部分代码省略.........
开发者ID:JordanComino,项目名称:PandaPuzzle,代码行数:101,代码来源:Form1.cs


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