public void FinishMatchWithStart() { var start = new Point(0, 0); var map = LeeAlgorithm.SpreadWave(start, p => true, p => true); Assert.IsTrue(map.ContainsKey(start)); Assert.IsTrue(map[start] == 0); }
public void FinishNearWithStart() { var start = new Point(0, 0); var finish = new Point(1, 0); var map = LeeAlgorithm.SpreadWave(start, p => true, p => p == finish); Assert.IsTrue(map.Values.Count <= 5); Assert.IsTrue(map.ContainsKey(start) && map.ContainsKey(finish)); Assert.IsTrue(map[start] == 0 && map[finish] == 1); }
public void MakeMapTest(string stringMap, int pathLen, int maxCountPointInResultMap = -1) { var map = CreateMap(stringMap); var bestFinish = FindChar(map, 'b').First(); var finish = FindChar(map, 'f'); var start = FindChar(map, 's').First(); var resultMap = LeeAlgorithm.SpreadWave(start, p => map[p.Y][p.X] != '#', p => finish.Contains(p) || bestFinish == p); if (maxCountPointInResultMap != -1) { Assert.IsTrue(resultMap.Count <= maxCountPointInResultMap); } Assert.IsTrue(resultMap.ContainsKey(start)); Assert.IsTrue(resultMap.ContainsKey(bestFinish)); Assert.IsTrue(resultMap[bestFinish] == pathLen); }
public static IEnumerable <Point> SaveMod() { if (BombManager.IsBoomArea(HeroPosition, 5)) { var path = LeeAlgorithm.Search(HeroPosition, p => { if (BombManager.IsBoomArea(p, 5)) { return(BombManager.BoomAreaRange(p) != LeeAlgorithm.valueWave); } return(p.IsElementAs(Elements.FreeForHero)); }, p => !BombManager.IsBoomArea(p, 5)); return(path); } return(Array.Empty <Point>()); }
public static Point FindNearEnemyNextPoint() { var targetEnemies = Board.GetOtherBombermans(); targetEnemies = targetEnemies.Where(p => !BombManager.IsBoomArea(p, 5)).ToList(); var path = LeeAlgorithm.Search(HeroPosition, p => { return((p.IsElementAs(Elements.FreeForHero) || targetEnemies.Contains(p)) && !DangerPoints.Contains(p)); }, targetEnemies); if (LeeAlgorithm.IsFinished) { NearEnemy = LeeAlgorithm.Finish; } if (path.Count() > 1) { var next = path.Skip(1).First(); return(next); } return(new Point()); }
public PointData(Point point) { Point = point; BoomArea = BombManager.BoomAreaRange(point); IsFree = point.IsElementAs(Elements.FreeForHero); IsEnemy = point.IsElementAs(Element.OTHER_BOMBERMAN); IsNearEnemy = point.GetNear(Element.OTHER_BOMBERMAN).Any(); IsNearChoper = point.GetNear(Element.MEAT_CHOPPER).Any(); CountNearFree = point.GetNear(Elements.FreeForHero).Where(v => !(v == HeroPosition && Game.IsAct)).Count(); var path = LeeAlgorithm.Search(point, p => p.IsElementAs(Elements.FreeForHero), p => { return(!BombManager.IsBoomArea(p, 5)); }); LenPathToNearPointNoBoom = path.Count() - 1; if (LenPathToNearPointNoBoom == -1) { LenPathToNearPointNoBoom = 99; } // data[point] = this; }
public static bool IsNextMoveDeadlock(Point next, int minFreePointInZone = 10) { if (Board.Get(Element.BOMB_BOMBERMAN).Any() || IsAct) { var countFreeSpace = 0; var mapSpreadWave = LeeAlgorithm.SpreadWave(next, p => p.IsElementAs(Elements.FreeForHero), p => { if (countFreeSpace >= minFreePointInZone) { return(true); } countFreeSpace++; return(false); }); if (mapSpreadWave.Count < minFreePointInZone) { return(true); } } return(false); }