コード例 #1
0
ファイル: BfsShould.cs プロジェクト: DarkSanny/PathBuilder
        public void ReturnStart_WhenEndIsStart()
        {
            var start = new Point(1, 1);
            var end   = start;

            A.CallTo(() => _field.GetAreaOfPoint(A <Point> .Ignored)).Returns(new List <Point>());
            A.CallTo(() => _field.IsCouldVisited(A <Point> .Ignored)).Returns(true);
            _bfs.FindPath(_field, start, end).Should().BeEquivalentTo(start);
        }
コード例 #2
0
ファイル: Robot.cs プロジェクト: VsALT2000/Killer
        private static Tuple <int, int> GetTargetLocate(int x, int y)
        {
            var wayToPlayer = Bfs.FindPath(new Point(x, y), _targets).FirstOrDefault();

            if (wayToPlayer == null)
            {
                return(Tuple.Create(-1, -1));
            }
            var point = wayToPlayer.Reverse().Skip(1).First();

            return(Tuple.Create(point.X, point.Y));
        }
コード例 #3
0
        private static Tuple <int, int> GetPlayerLocation(int x, int y)
        {
            for (var dx = x - DetectPlayer; dx <= x + DetectPlayer; dx++)
            {
                for (var dy = y - DetectPlayer; dy <= y + DetectPlayer; dy++)
                {
                    if (dx >= 0 && dy >= 0 && dx < _game.Width && dy < _game.Height)
                    {
                        if (_game.Map[dx, dy] is Player || _game.Map[dx, dy] is PlayerWithGun)
                        {
                            var wayToPlayer = Bfs.FindPath(new Point(x, y), _game).FirstOrDefault();
                            if (wayToPlayer == null)
                            {
                                return(Tuple.Create(-1, -1));
                            }
                            var point = wayToPlayer.Reverse().Skip(1).First();
                            return(Tuple.Create(point.X, point.Y));
                        }
                    }
                }
            }

            return(Tuple.Create(-1, -1));
        }