コード例 #1
0
ファイル: CoreHelper.cs プロジェクト: f15h96/AI
        public bool CheckCellSolutionForCollision(Vector2Int cellCoordinates, OutputGrid outputGrid)
        {
            foreach (var neighbour in Create4DirectionNeighbours(cellCoordinates))
            {
                if (outputGrid.CheckIfValidPosition(neighbour.cellToPropagatePosition) == false)
                {
                    continue;;
                }
                HashSet <int> possibleIndicies = new HashSet <int>();
                foreach (var patternIndexAtNeighbour in outputGrid.GetPossibleValueForPosition(neighbour.cellToPropagatePosition))
                {
                    var possibleNeighboursForBase =
                        patternManager.GetPossibleNeighboursForPatternInDirection(patternIndexAtNeighbour,
                                                                                  neighbour.directionFromBase.GetOppositeDirectionTo());
                    possibleIndicies.UnionWith(possibleNeighboursForBase);
                }

                if (possibleIndicies.Contains(outputGrid.GetPossibleValueForPosition(cellCoordinates).First()) == false)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        private void RemoveImpossibleNeighbours(VectorPair propagatePair, HashSet <int> possibleValuesAtNeighbour)
        {
            HashSet <int> possibleIndices = new HashSet <int>();

            foreach (var patternIndexAtBase in outputGrid.GetPossibleValueForPossition(propagatePair.BaseCellPosition))
            {
                var possibleNeighboursForBase = patternManager.GetPossibleNeighboursForPatternInDirection(patternIndexAtBase, propagatePair.DirectionFromBase);
                possibleIndices.UnionWith(possibleNeighboursForBase);
            }

            possibleValuesAtNeighbour.IntersectWith(possibleIndices);
        }