コード例 #1
0
ファイル: ArrayMapTests.cs プロジェクト: 80LevelElf/Bigio
 private static void BinarySearch(ArrayMap<int> arrayMap, int count)
 {
     for (int i = 0; i < count; i++)
     {
         arrayMap.BlockInfo(_random.Next(BlockCount*ElementsInBlockCount));
     }
 }
コード例 #2
0
        public FieldMapperIterator(IEnumerable<IFieldMapper> fieldMappers, IEnumerable<Field> targetFields = null)
        {
            targetFields = targetFields ?? fieldMappers.SelectMany(mapper => mapper.Fields);

            var i = 0;
            var fieldIndices = targetFields.ToDictionary(field => field, field => i++);

            _maps = fieldMappers.Select(fm =>
                new FieldMapperFields
                {
                    FieldMapper = fm,
                    TargetIndices = fm.Fields.Select(ix => fieldIndices[ix]).ToArray()
                }
             ).ToArray();

            _map = new ArrayMap<object>();
        }
コード例 #3
0
        public void InitalizeNeighbors(ArrayMap<TheMatrixCode> knownUniverse, ArrayMap<TheMatrixCode>.CardnialNeighborPosition neighborPositions)
        {
            List<Point> neighborhood = knownUniverse.GetNeighborLocations(this.KnownUniverseLocation, neighborPositions);
            MyNeighbors = new TheMatrixCode[neighborhood.Count];
            int index = 0;

            foreach(Point p in neighborhood)
            {
                MyNeighbors[index] = knownUniverse[p];
                index++;
            }

            NeighborsInitalized = true;
        }
コード例 #4
0
        //private void InitializeCodeIterators(ArrayMap<TheMatrixCode> knownUniverse)
        //{
        //    int width = knownUniverse.Size.Width;
        //    Iterators = new ICodeIterator<TheMatrixCode>[width];
        //    for (int i = 0; i < width; i++)
        //    {
        //        Iterators[i] = new CodeIteratorRain(0.15f);
        //        knownUniverse[i].Iterator = Iterators[i];
        //        knownUniverse[i].Start();
        //    }
        //}
        private ArrayMap<TheMatrixCode> BuildTheKnownUniverse()
        {
            Size knownUniverseSize = new Size(Grid.Rows, Grid.Columns);
            ArrayMap<TheMatrixCode> knownUniverse = new ArrayMap<TheMatrixCode>(knownUniverseSize);

            Random random = new Random();
            int charIndex = 0;
            string character = String.Empty;

            List<Vector2> positions = new List<Vector2>(Grid.GetPositions());

            for (int i = 0; i < knownUniverse.Count; i++)
            {
                charIndex = GetRandomCharIndex(random);
                character = new String((char)Font.Characters[charIndex], 1);

                MatrixEffectCodeFader fader = new MatrixEffectCodeFader(Highlight, Shadow, random.Next(10, 20));
                OnOffCodeFader onOffFader = new OnOffCodeFader(Color.Green, Color.Red, 5.0f);

                knownUniverse[i] = new TheMatrixCode(fader)
                {
                    State = CodeModelState.Fading,
                    MyColor = Shadow,
                    RenderPosition = positions[i],
                    KnownUniverseLocation = knownUniverse.GetItemLocation(i),
                    Character = character
                };
            }

            return knownUniverse;
        }
コード例 #5
0
        public void Initialize()
        {
            Font = Game.Content.Load<SpriteFont>(FontName);
            // Grid needs initalized before TheCode can be built
            Grid = new Grid2D(Columns, FontSize, Game);

            KnownUniverse = BuildTheKnownUniverse();

            foreach (TheMatrixCode code in KnownUniverse)
            {
                code.InitalizeNeighbors(KnownUniverse, ArrayMap<TheMatrixCode>.CardnialNeighborPosition.South);
            }

            //InitializeCodeIterators(KnownUniverse);
        }
コード例 #6
0
ファイル: AVGCG.cs プロジェクト: zx8326123/LGame
 public AVGCG()
 {
     this.charas = new ArrayMap(10);
     this.style  = true;
     this.loop   = true;
 }
コード例 #7
0
 public void Add <T>(Func <T> func)
 {
     ArrayMap.Add(typeof(T), () => new[] { func.Invoke() }.Select(e => (object)e));
 }
コード例 #8
0
ファイル: ArrayMapTests.cs プロジェクト: 80LevelElf/Bigio
        private static IEnumerable<TestResult> GetResult(TestArguments arguments)
        {
            //Prepare data
            var blockCollection = new BlockCollection<int>();
            for (int i = 0; i < BlockCount; i++)
            {
                blockCollection.Add(GetFilledBlock(ElementsInBlockCount));
            }

            var blockStructure = new ArrayMap<int>(new FixedBalancer(),  blockCollection);

            //Prepare measure engine
            var method = GetMethodInfo(arguments.MethodName);

            foreach (var currentCount in arguments.TestCountArray)
            {
                List<object> argumentList = new List<object> { blockStructure, currentCount};

                //Get middle estimation of several times calling
                long timeOfAllInvoketionsMs = 0;
                int countOfInvokations = 3;

                for (int i = 0; i < countOfInvokations; i++)
                {
                    timeOfAllInvoketionsMs += MeasureEngine.MeasureStaticMethod(method, argumentList);
                }

                yield return new TestResult(currentCount, timeOfAllInvoketionsMs / countOfInvokations);
            }
        }
コード例 #9
0
ファイル: SmartTiles.cs プロジェクト: Grovespaz/MLLE
        public bool Apply(ArrayMap <ushort> localTiles, ref ushort tileID)
        {
            ArrayMap <bool?>      LocalTilesAreRelated = new ArrayMap <bool?>(5, 6);
            Func <int, int, bool> getRelatedness       = (x, y) =>
            {
                x += 2;
                y += 3;
                return(LocalTilesAreRelated[x, y] ?? (LocalTilesAreRelated[x, y] = TilesIGoNextTo.Contains(localTiles[x, y], TilesIGoNextTo.Comparer)).Value);
            };

            int assignmentID = 47;

            switch (
                (getRelatedness(0, -1) ? 1 : 0) |
                (getRelatedness(0, 1) ? 2 : 0) |
                (getRelatedness(-1, 0) ? 4 : 0) |
                (getRelatedness(1, 0) ? 8 : 0)
                )
            {
            case 0:     //no neighbors at all
                assignmentID = 47;
                break;

            case 1:     //U
                assignmentID = 77;
                break;

            case 2:     //D
                if (getRelatedness(0, 2))
                {
                    if (getRelatedness(-1, 1) && !getRelatedness(1, 1) && getRelatedness(-1, 2))
                    {
                        assignmentID = 80; break;
                    }
                    else if (getRelatedness(1, 1) && !getRelatedness(-1, 1) && getRelatedness(1, 2))
                    {
                        assignmentID = 81; break;
                    }
                }
                assignmentID = 57;
                break;

            case 3:     //UD
                assignmentID = 67;
                break;

            case 4:     //L
                assignmentID = 32;
                break;

            case 5:                                                                                          //LU
                if (!getRelatedness(-1, -1))                                                                 //thin
                {
                    if (getRelatedness(1, -1) && !getRelatedness(0, -2) && Assignments[94].Tiles.Count != 0) //horizontal tube slope
                    {
                        assignmentID = 94;
                    }
                    else if (getRelatedness(-1, 1) && !getRelatedness(-2, 0))     //vertical tube slope
                    {
                        assignmentID = 87;
                    }
                    else
                    {
                        assignmentID = 25;
                    }
                }
                else     //thick
                {
                    if (!getRelatedness(1, -1) && !getRelatedness(0, -2) && getRelatedness(-1, -2) && !getRelatedness(-1, -3))
                    {
                        assignmentID = 93;
                        break;
                    }
                    if (Assignments[53].Tiles.Count != 0 && getRelatedness(1, -1))     //ceiling slope
                    {
                        if (getRelatedness(0, -2))
                        {
                            if (getRelatedness(-1, -2) && getRelatedness(1, -2) && Assignments[43].Tiles.Count != 0)
                            {
                                assignmentID = 53;
                                break;
                            }
                        }
                        else
                        {
                            if (Assignments[63].Tiles.Count != 0)
                            {
                                assignmentID = 53;
                                break;
                            }
                        }
                    }
                    if (Assignments[75].Tiles.Count != 0 && getRelatedness(-1, 1))     //wall slope
                    {
                        if (getRelatedness(-2, 0))
                        {
                            if (getRelatedness(-2, -1) && Assignments[74].Tiles.Count != 0)
                            {
                                assignmentID = 75;
                                break;
                            }
                        }
                        else
                        {
                            if (Assignments[76].Tiles.Count != 0)
                            {
                                assignmentID = 75;
                                break;
                            }
                        }
                    }
                    assignmentID = 22;
                }
                break;

            case 6:                                                                                        //LD
                if (!getRelatedness(-1, 1))                                                                //thin
                {
                    if (getRelatedness(1, 1) && !getRelatedness(0, 2) && Assignments[85].Tiles.Count != 0) //horizontal tube slope
                    {
                        assignmentID = 85;
                    }
                    else if (getRelatedness(-1, -1) && !getRelatedness(-2, 0))     //vertical tube slope
                    {
                        assignmentID = 97;
                    }
                    else
                    {
                        assignmentID = 5;
                    }
                }
                else                                                                                                                                       //thick
                {
                    if (Assignments[41].Tiles.Count != 0)                                                                                                  //floor slope
                    {
                        if (getRelatedness(1, 1))                                                                                                          //normal slope
                        {
                            if (Assignments[getRelatedness(0, 2) ? (getRelatedness(1, 2) ? (getRelatedness(-1, 2) ? 51 : 79) : 99) : 61].Tiles.Count != 0) //99 is a cheat, it will be false, there's no such tile
                            {
                                assignmentID = 41;
                                break;
                            }
                        }
                        else                                                       //downward slope at the end of the platform
                        {
                            if (getRelatedness(-1, -1) && !getRelatedness(-1, -2)) //slope continues above but is not outright wall
                            {
                                if (!getRelatedness(0, 2))
                                {
                                    if (Assignments[93].Tiles.Count != 0)
                                    {
                                        assignmentID = 41;
                                        break;
                                    }
                                }
                                else
                                {
                                    if (getRelatedness(-1, 2) && Assignments[83].Tiles.Count != 0)
                                    {
                                        assignmentID = 41;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (Assignments[65].Tiles.Count != 0 && getRelatedness(-1, -1))     //wall slope
                    {
                        if (getRelatedness(-2, 0))
                        {
                            if (getRelatedness(-2, 1) && Assignments[64].Tiles.Count != 0)
                            {
                                assignmentID = 65;
                                break;
                            }
                        }
                        else
                        {
                            if (Assignments[66].Tiles.Count != 0)
                            {
                                assignmentID = 65;
                                break;
                            }
                        }
                    }
                    assignmentID = 2;
                }
                break;

            case 7:     //LUD
                if (getRelatedness(-1, -1))
                {
                    assignmentID = getRelatedness(-1, 1) ? (!getRelatedness(1, -1) && !getRelatedness(0, -2) && getRelatedness(-1, -2) && !getRelatedness(-1, -3) ? 83 : 12) : (getRelatedness(-2, 0) ? 27 : 56);
                }
                else
                {
                    assignmentID = getRelatedness(-1, 1) ? (getRelatedness(1, -1) || getRelatedness(0, -2) ? (getRelatedness(-2, 0) ? 37 : 46) : 90) : 15;
                }
                break;

            case 8:     //R
                assignmentID = 30;
                break;

            case 9:                                                                                           //RU
                if (!getRelatedness(1, -1))                                                                   //thin
                {
                    if (getRelatedness(-1, -1) && !getRelatedness(0, -2) && Assignments[95].Tiles.Count != 0) //horizontal tube slope
                    {
                        assignmentID = 95;
                    }
                    else if (getRelatedness(1, 1) && !getRelatedness(2, 0))     //vertical tube slope
                    {
                        assignmentID = 96;
                    }
                    else
                    {
                        assignmentID = 23;
                    }
                }
                else     //thick
                {
                    if (!getRelatedness(-1, -1) && !getRelatedness(0, -2) && getRelatedness(1, -2) && !getRelatedness(1, -3))
                    {
                        assignmentID = 92;
                        break;
                    }
                    if (Assignments[52].Tiles.Count != 0 && getRelatedness(-1, -1))     //ceiling slope
                    {
                        if (getRelatedness(0, -2))
                        {
                            if (getRelatedness(1, -2) && getRelatedness(-1, -2) && Assignments[42].Tiles.Count != 0)
                            {
                                assignmentID = 52;
                                break;
                            }
                        }
                        else
                        {
                            if (Assignments[62].Tiles.Count != 0)
                            {
                                assignmentID = 52;
                                break;
                            }
                        }
                    }
                    if (Assignments[54].Tiles.Count != 0 && getRelatedness(1, 1))     //wall slope
                    {
                        if (getRelatedness(2, 0))
                        {
                            if (getRelatedness(2, -1) && Assignments[55].Tiles.Count != 0)
                            {
                                assignmentID = 54;
                                break;
                            }
                        }
                        else
                        {
                            if (Assignments[56].Tiles.Count != 0)
                            {
                                assignmentID = 54;
                                break;
                            }
                        }
                    }
                    assignmentID = 20;
                }
                break;

            case 10:                                                                                        //RD
                if (!getRelatedness(1, 1))                                                                  //thin
                {
                    if (getRelatedness(-1, 1) && !getRelatedness(0, 2) && Assignments[84].Tiles.Count != 0) //horizontal tube slope
                    {
                        assignmentID = 84;
                    }
                    else if (getRelatedness(1, -1) && !getRelatedness(2, 0))     //vertical tube slope
                    {
                        assignmentID = 86;
                    }
                    else
                    {
                        assignmentID = 3;
                    }
                }
                else                                      //thick
                {
                    if (Assignments[40].Tiles.Count != 0) //floor slope
                    {
                        if (getRelatedness(-1, 1))        //normal slope
                        {
                            if (Assignments[getRelatedness(0, 2) ? (getRelatedness(-1, 2) ? (getRelatedness(1, 2) ? 50 : 78) : 99) : 60].Tiles.Count != 0)
                            {
                                assignmentID = 40;
                                break;
                            }
                        }
                        else                                                     //downward slope at the end of the platform
                        {
                            if (getRelatedness(1, -1) && !getRelatedness(1, -2)) //slope continues above but is not outright wall
                            {
                                if (!getRelatedness(0, 2))
                                {
                                    if (Assignments[92].Tiles.Count != 0)
                                    {
                                        assignmentID = 40;
                                        break;
                                    }
                                }
                                else
                                {
                                    if (getRelatedness(1, 2) && Assignments[82].Tiles.Count != 0)
                                    {
                                        assignmentID = 40;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (Assignments[44].Tiles.Count != 0 && getRelatedness(1, -1))     //wall slope
                    {
                        if (getRelatedness(2, 0))
                        {
                            if (getRelatedness(2, 1) && Assignments[45].Tiles.Count != 0)
                            {
                                assignmentID = 44;
                                break;
                            }
                        }
                        else
                        {
                            if (Assignments[46].Tiles.Count != 0)
                            {
                                assignmentID = 44;
                                break;
                            }
                        }
                    }
                    assignmentID = 0;
                }
                break;

            case 11:     //RUD
                if (getRelatedness(1, -1))
                {
                    assignmentID = getRelatedness(1, 1) ? (!getRelatedness(-1, -1) && !getRelatedness(0, -2) && getRelatedness(1, -2) && !getRelatedness(1, -3) ? 82 : 10) : (getRelatedness(2, 0) ? 26 : 76);
                }
                else
                {
                    assignmentID = getRelatedness(1, 1) ? (getRelatedness(-1, -1) || getRelatedness(0, -2) ? (getRelatedness(2, 0) ? 36 : 66) : 91) : 13;
                }
                break;

            case 12:     //LR
                assignmentID = 31;
                break;

            case 13:     //LRU
                if (getRelatedness(-1, -1))
                {
                    assignmentID = getRelatedness(1, -1) ? 21 : (getRelatedness(0, -2) ? 18 : 61);
                }
                else
                {
                    assignmentID = getRelatedness(1, -1) ? (getRelatedness(0, -2) ? 19 : 60) : 24;
                }
                break;

            case 14:     //LRD
                if (getRelatedness(-1, 1))
                {
                    assignmentID = getRelatedness(1, 1) ? 1 : (getRelatedness(0, 2) ? 8 : 63);
                }
                else
                {
                    assignmentID = getRelatedness(1, 1) ? (getRelatedness(0, 2) ? 9 : 62) : 4;
                }
                break;

            case 15:     //LRUD
                switch (
                    (getRelatedness(-1, -1) ? 1 : 0) |
                    (getRelatedness(1, -1) ? 2 : 0) |
                    (getRelatedness(1, 1) ? 4 : 0) |
                    (getRelatedness(-1, 1) ? 8 : 0)
                    )
                {
                case 0:         //no corners at all, full pipe plus
                    assignmentID = 14;
                    break;

                case 1:
                    assignmentID = 39;
                    break;

                case 2:
                    assignmentID = 38;
                    break;

                case 3:
                    assignmentID = 58;
                    break;

                case 4:
                    assignmentID = 28;
                    break;

                case 5:
                    assignmentID = (getRelatedness(-1, -1) && !getRelatedness(0, -2)) ? 79 : 69;
                    break;

                case 6:
                    assignmentID = 48;
                    break;

                case 7:
                    if (!getRelatedness(0, 2))
                    {
                        assignmentID = 42;
                    }
                    else if (!getRelatedness(-2, 0))
                    {
                        assignmentID = 55;
                    }
                    else
                    {
                        assignmentID = 7;
                    }
                    break;

                case 8:
                    assignmentID = 29;
                    break;

                case 9:
                    assignmentID = 49;
                    break;

                case 10:
                    assignmentID = (getRelatedness(1, -1) && !getRelatedness(0, -2)) ? 78 : 68;
                    break;

                case 11:
                    if (!getRelatedness(0, 2))
                    {
                        assignmentID = 43;
                    }
                    else if (!getRelatedness(2, 0))
                    {
                        assignmentID = 74;
                    }
                    else
                    {
                        assignmentID = 6;
                    }
                    break;

                case 12:
                    assignmentID = 59;
                    break;

                case 13:
                    if (!getRelatedness(0, -2))
                    {
                        assignmentID = 51;
                    }
                    else if (!getRelatedness(2, 0))
                    {
                        assignmentID = 64;
                    }
                    else
                    {
                        assignmentID = 16;
                    }
                    break;

                case 14:
                    if (!getRelatedness(0, -2))
                    {
                        assignmentID = 50;
                    }
                    else if (!getRelatedness(-2, 0))
                    {
                        assignmentID = 45;
                    }
                    else
                    {
                        assignmentID = 17;
                    }
                    break;

                case 15:         //totally surrounded, normal wall tile
                    assignmentID = 11;
                    break;
                }
                break;
            }

            ResolveAssignmentIDToSomethingWithTilesInIt(ref assignmentID);

            bool lastRuleApplied = true;

            foreach (Rule rule in Assignments[assignmentID].Rules)
            {
                List <ushort> frames  = rule.Result;
                bool          applies = lastRuleApplied && rule.Applies(localTiles, Tileset.SmartTiles, TilesICanPlace.Comparer);
                if (frames.Count == 0) //and
                {
                    lastRuleApplied = applies;
                }
                else //then
                {
                    if (applies)
                    {
                        tileID = frames[frames.Count == 1 ? 0 : Rand.Next(frames.Count)];
                        return(true);
                    }
                    lastRuleApplied = true;
                }
            }

            var tiles = Assignments[assignmentID].Tiles;

            if (tiles.Count >= 1)
            {
                tileID = tiles[tiles.Count == 1 ? 0 : Rand.Next(tiles.Count)];
            }
            else
            {
                return(false);
            }
            return(true);
        }
コード例 #10
0
ファイル: SmartTiles.cs プロジェクト: Grovespaz/MLLE
        internal void UpdateAllPossibleTiles(List <SmartTile> smartTiles, bool updateFriends = true)
        {
            TilesICanPlace.Clear();
            foreach (var assignment in Assignments)
            {
                if (assignment.Tiles != Extras)
                {
                    assignment.UnionWith(TilesICanPlace);
                }
            }

            TilesIGoNextTo.Clear();
            TilesIGoNextTo.UnionWith(TilesICanPlace);
            TilesIGoNextTo.UnionWith(Extras);

            if (updateFriends)
            {
                UpdateTilesIGonextTo(smartTiles);
            }

            try
            {
                var               qualifyingAssignment = Assignments[MandatoryAssignmentIDs.First(i => !Assignments[i].Empty)];
                ushort            qualifyingTileID     = qualifyingAssignment.Tiles[0];
                ArrayMap <ushort> surroundingTiles     = new ArrayMap <ushort>(3 + 2 * 2, 3 + 3 + 2);
                for (int x = 2; x < 5; ++x)
                {
                    for (int y = 3; y < 6; ++y)
                    {
                        surroundingTiles[x, y] = qualifyingTileID;
                    }
                }
                for (int pass = 0; pass < 2; ++pass) //why not
                {
                    for (int x = 2; x < 5; ++x)
                    {
                        for (int y = 3; y < 6; ++y)
                        {
                            ArrayMap <ushort> localTiles = new ArrayMap <ushort>(5, 6);
                            for (int xx = 0; xx < 5; ++xx)
                            {
                                for (int yy = 0; yy < 6; ++yy)
                                {
                                    localTiles[xx, yy] = surroundingTiles[x + xx - 2, y + yy - 3];
                                }
                            }
                            ushort tileID = surroundingTiles[x, y];
                            if (Apply(localTiles, ref tileID)) //not sure why this would return false, but...
                            {
                                surroundingTiles[x, y] = tileID;
                            }
                        }
                    }
                }
                PreviewTileIDs = Enumerable.Range(0, 9).Select(i => surroundingTiles[(i % 3) + 2, (i / 3) + 3]).ToArray();
                Available      = true;
            }
            catch //in First
            {
                PreviewTileIDs = new ushort[9];
                Available      = false;
            }
        }
コード例 #11
0
 public ParamsSequence(String expr, ArrayMap <String, Double> paramList) : base(expr, new ArithmeticSyntaxParser())
 {
     this._prms = paramList;
 }
コード例 #12
0
 public ParamsSequence(String expr, IFormulaParser p, ArrayMap <String, Double> paramList) : base(expr, p)
 {
     this._prms = paramList;
 }
コード例 #13
0
        public void FOVSenseMapEquivalency()
        {
            ArrayMap <bool> map = new ArrayMap <bool>(100, 100);

            QuickGenerators.GenerateRectangleMap(map);

            var positions = Enumerable.Range(0, 100).Select(x => map.RandomPosition(true)).ToList();

            // Make 2-layer thick walls to verify wall-lighting is working properly
            foreach (var pos in map.Positions())
            {
                if (pos.X == 1 || pos.Y == 1 || pos.X == map.Width - 2 || pos.Y == map.Height - 2)
                {
                    map[pos] = false;
                }
            }

            var fov         = new FOV(map);
            var senseMap    = new SenseMap(new LambdaTranslationMap <bool, double>(map, x => x ? 0.0 : 1.0));
            var senseSource = new SenseSource(SourceType.SHADOW, map.RandomPosition(true), 5, Distance.EUCLIDEAN);

            senseMap.AddSenseSource(senseSource);


            foreach (var curPos in positions)
            {
                if (!map[curPos])
                {
                    continue;
                }

                senseSource.Position = curPos;
                fov.Calculate(senseSource.Position, senseSource.Radius, senseSource.DistanceCalc);
                senseMap.Calculate();

                foreach (var pos in map.Positions())
                {
                    bool success = fov.BooleanFOV[pos] == (senseMap[pos] > 0.0 ? true : false);

                    if (!success)
                    {
                        Console.WriteLine($"Failed on pos {pos} with source at {senseSource.Position}.");
                        Console.WriteLine($"FOV: {fov[pos]}, SenseMap: {senseMap[pos]}");
                        Console.WriteLine($"Distance between source and fail point: {Distance.EUCLIDEAN.Calculate(senseSource.Position, pos)}, source radius: {senseSource.Radius}");
                    }

                    Assert.AreEqual(true, success);
                }
            }


            var degreesList = Enumerable.Range(0, 360).ToList();

            degreesList.FisherYatesShuffle();
            var spanList = Enumerable.Range(1, 359).ToList();

            spanList.FisherYatesShuffle();

            var degrees = degreesList.Take(30).ToList();
            var spans   = spanList.Take(30).ToList();

            senseSource.IsAngleRestricted = true;
            // Test angle-based shadowcasting
            foreach (var curPos in positions.Take(1))
            {
                if (!map[curPos])
                {
                    continue;
                }

                foreach (var degree in degrees)
                {
                    foreach (var span in spans)
                    {
                        senseSource.Angle = degree;
                        senseSource.Span  = span;

                        senseSource.Position = curPos;
                        fov.Calculate(senseSource.Position, senseSource.Radius, senseSource.DistanceCalc, senseSource.Angle, senseSource.Span);
                        senseMap.Calculate();

                        foreach (var pos in map.Positions())
                        {
                            bool success = fov.BooleanFOV[pos] == (senseMap[pos] > 0.0 ? true : false);

                            if (!success)
                            {
                                Console.WriteLine($"Failed on pos {pos} with source at {senseSource.Position}, angle: {senseSource.Angle}, span: {senseSource.Span}.");
                                Console.WriteLine($"FOV: {fov[pos]}, SenseMap: {senseMap[pos]}");
                                Console.WriteLine($"Distance between source and fail point: {Distance.EUCLIDEAN.Calculate(senseSource.Position, pos)}, source radius: {senseSource.Radius}");
                            }

                            Assert.AreEqual(true, success);
                        }
                    }
                }
            }
        }
コード例 #14
0
ファイル: Screen.cs プロジェクト: zhangxin8105/LGame
        public virtual void OnCreate(int width, int height)
        {
            this.mode       = SCREEN_NOT_REPAINT;
            this.stageRun   = true;
            this.width      = width;
            this.height     = height;
            this.halfWidth  = width / 2;
            this.halfHeight = height / 2;
            this.lastTouchX = lastTouchY = touchDX = touchDY = 0;
            this.isLoad     = isLock = isClose = isTranslate = isGravity = false;

            /*if (sprites != null)
             * {
             *      sprites.close();
             *      sprites.removeAll();
             *      sprites = null;
             * }
             * this.sprites = new Sprites("ScreenSprites", this, width, height);
             * if (desktop != null)
             * {
             *      desktop.close();
             *      desktop.clear();
             *      desktop = null;
             * }
             * this.desktop = new Desktop("ScreenDesktop", this, width, height);*/
            this.isNext       = true;
            this.tx           = ty = 0;
            this.isTranslate  = false;
            this._screenIndex = 0;
            this._lastTocuh.Empty();
            this._keyActions.Clear();
            this._visible          = true;
            this._rotation         = 0;
            this._scaleX           = _scaleY = _alpha = 1f;
            this._baseColor        = null;
            this._isExistCamera    = false;
            this._initLoopEvents   = false;
            this._desktopPenetrate = false;
            if (this.delayTimer == null)
            {
                this.delayTimer = new LTimer(0);
            }
            if (this.pauseTimer == null)
            {
                this.pauseTimer = new LTimer(LSystem.SECOND);
            }
            if (this._rect_limits == null)
            {
                this._rect_limits = new TArray <RectBox>(10);
            }
            if (this._action_limits == null)
            {
                this._action_limits = new TArray <ActionBind>(10);
            }
            if (this._touchAreas == null)
            {
                this._touchAreas = new TArray <LTouchArea>();
            }
            if (this._conns == null)
            {
                this._conns = new loon.utils.reply.Closeable.Set();
            }
            if (this._keyActions == null)
            {
                this._keyActions = new ArrayMap();
            }
        }
コード例 #15
0
 public void Remove <T>(Func <T> func)
 {
     ArrayMap.Remove(typeof(T));
 }
コード例 #16
0
ファイル: ArrayMapTests.cs プロジェクト: 80LevelElf/Bigio
        private static void LinearSearch(ArrayMap<int> arrayMap, int count)
        {
            //To prevent using BinarySearch
            arrayMap.DataChanged(0);

            for (int i = 0; i < count; i++)
            {
                arrayMap.BlockInfo(_random.Next(BlockCount * ElementsInBlockCount));
            }
        }
コード例 #17
0
ファイル: SmartTiles.cs プロジェクト: Grovespaz/MLLE
            internal bool Applies(ArrayMap <ushort> tileMap, List <SmartTile> otherSmartTiles, IEqualityComparer <ushort> comparer)
            {
                ushort tileID = tileMap[X + 2, Y + 3];

                return(Not ^ ((OtherSmartTileID == -1) ? SpecificTiles.Contains(tileID, comparer) : (otherSmartTiles[OtherSmartTileID].TilesICanPlace.Contains(tileID, comparer) || otherSmartTiles[OtherSmartTileID].Extras.Contains(tileID, comparer))));
            }
コード例 #18
0
 public VariableStrings()
 {
     varsToStrings = ArrayMap.NewArrayMap();
     numVarsSet    = new IntCounter <string>(MapFactory.ArrayMapFactory <string, MutableInteger>());
 }
コード例 #19
0
ファイル: ArrayMapTests.cs プロジェクト: 80LevelElf/Bigio
 //API
 static ArrayMapTests()
 {
     BlockSize = 1024;
     TestStructure = CteareTestStructure();
 }
コード例 #20
0
 public void Add <T>(Func <IEnumerable <T> > func)
 {
     ArrayMap.Add(typeof(T), () => func.Invoke().Select(e => (object)e));
 }