亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? steeringbehavior.vb

?? 一個(gè).Net下用VB編寫的用于游戲的人工智能引擎
?? VB
?? 第 1 頁 / 共 5 頁
字號:
        Dim WorldOffsetPos As Vector2D = Transformations.PointToWorldSpace(offset, leader.Heading(), leader.Side(), leader.Pos())

        Dim ToOffset As Vector2D = WorldOffsetPos.Minus(m_pVehicle.Pos())

        '//the lookahead time is propotional to the distance between the leader
        '//and the pursuer; and is inversely proportional to the sum of both
        '//agent's velocities
        Dim LookAheadTime As Double = ToOffset.Length() / (m_pVehicle.MaxSpeed() + leader.Speed())

        '//now Arrive at the predicted future position of the offset
        Return Arrive(WorldOffsetPos.Plus(leader.Velocity().Mutiply(LookAheadTime)), Deceleration.fast)

    End Function

    '//this behavior attempts to evade a pursuer
    '//----------------------------- Evade ------------------------------------
    '//
    '//  similar to pursuit except the agent Flees from the estimated future
    '//  position of the pursuer
    '//------------------------------------------------------------------------
    Private Function Evade(ByVal pursuer As Vehicle) As Vector2D
        '/* Not necessary to include the check for facing direction this time */

        Dim ToPursuer As Vector2D = pursuer.Pos().Plus(m_pVehicle.Pos())

        '//uncomment the following two lines to have Evade only consider pursuers 
        '//within a 'threat range'
        Dim ThreatRange As Double = 100.0
        If ToPursuer.LengthSQ() > ThreatRange * ThreatRange Then Return New Vector2D

        '//the lookahead time is propotional to the distance between the pursuer
        '//and the pursuer; and is inversely proportional to the sum of the
        '//agents' velocities
        Dim LookAheadTime As Double = ToPursuer.Length() / (m_pVehicle.MaxSpeed() + pursuer.Speed())

        '//now flee away from predicted future position of the pursuer
        Return Flee(pursuer.Pos().Minus(pursuer.Velocity()).Mutiply(LookAheadTime))

    End Function

    '//this behavior makes the agent wander about randomly
    '//--------------------------- Wander -------------------------------------
    '//
    '//  This behavior makes the agent wander about randomly
    '//------------------------------------------------------------------------
    Private Function Wander() As Vector2D
        '//this behavior is dependent on the update rate, so this line must
        '//be included when using time independent framerate.
        Dim JitterThisTimeSlice As Double = m_dWanderJitter * m_pVehicle.TimeElapsed()

        '//first, add a small random vector to the target's position
        m_vWanderTarget.PlusEqual(New Vector2D(Utils.RandomClamped() * JitterThisTimeSlice, Utils.RandomClamped() * JitterThisTimeSlice))

        '//reproject this new vector back on to a unit circle
        m_vWanderTarget.Normalize()

        '//increase the length of the vector to the same as the radius
        '//of the wander circle
        m_vWanderTarget.MutiplyEqual(m_dWanderRadius)

        '//move the target into a position WanderDist in front of the agent
        Dim target As Vector2D = m_vWanderTarget.Plus(New Vector2D(m_dWanderDistance, 0))

        '//project the target into world space
        Dim tTarget As Vector2D = Transformations.PointToWorldSpace(target, m_pVehicle.Heading(), m_pVehicle.Side(), m_pVehicle.Pos())

        '//and steer towards it
        Return tTarget.Minus(m_pVehicle.Pos())

    End Function

    '//this returns a steering force which will attempt to keep the agent 
    '//away from any obstacles it may encounter
    '//---------------------- ObstacleAvoidance -------------------------------
    '//
    '//  Given a vector of CObstacles, this method returns a steering force
    '//  that will prevent the agent colliding with the closest obstacle
    '//------------------------------------------------------------------------
    Private Function ObstacleAvoidance(ByVal obstacles As ArrayList) As Vector2D
        '//the detection box length is proportional to the agent's velocity
        m_dDBoxLength = Prm.MinDetectionBoxLength + (m_pVehicle.Speed() / m_pVehicle.MaxSpeed()) * Prm.MinDetectionBoxLength

        '//tag all obstacles within range of the box for processing
        m_pVehicle.World().TagObstaclesWithinViewRange(m_pVehicle, m_dDBoxLength)

        '//this will keep track of the closest intersecting obstacle (CIB)
        Dim ClosestIntersectingObstacle As BaseGameEntity = Nothing

        '//this will be used to track the distance to the CIB
        Dim DistToClosestIP As Double = Double.MaxValue

        '//this will record the transformed local coordinates of the CIB
        Dim LocalPosOfClosestObstacle As Vector2D

        Dim curOb As BaseGameEntity

        Dim i As Integer
        For i = 0 To obstacles.Count - 1
            curOb = obstacles(i)
            '//if the obstacle has been tagged within range proceed
            If curOb.IsTagged Then
                '//calculate this obstacle's position in local space
                Dim LocalPos As Vector2D = Transformations.PointToLocalSpace(curOb.Pos(), m_pVehicle.Heading(), m_pVehicle.Side(), m_pVehicle.Pos())

                '//if the local position has a negative x value then it must lay
                '//behind the agent. (in which case it can be ignored)
                If (LocalPos.x >= 0) Then
                    '//if the distance from the x axis to the object's position is less
                    '//than its radius + half the width of the detection box then there
                    '//is a potential intersection.
                    Dim ExpandedRadius As Double = curOb.BRadius() + m_pVehicle.BRadius()

                    If Math.Abs(LocalPos.y) < ExpandedRadius Then
                        '//now to do a line/circle intersection test. The center of the 
                        '//circle is represented by (cX, cY). The intersection points are 
                        '//given by the formula x = cX +/-sqrt(r^2-cY^2) for y=0. 
                        '//We only need to look at the smallest positive value of x because
                        '//that will be the closest point of intersection.
                        Dim cX As Double = LocalPos.x
                        Dim cY As Double = LocalPos.y

                        '//we only need to calculate the sqrt part of the above equation once
                        Dim SqrtPart As Double = Math.Sqrt(ExpandedRadius * ExpandedRadius - cY * cY)

                        Dim ip As Double = cX - SqrtPart

                        If (ip <= 0.0) Then
                            ip = cX + SqrtPart
                        End If

                        '//test to see if this is the closest so far. If it is keep a
                        '//record of the obstacle and its local coordinates
                        If (ip < DistToClosestIP) Then

                            DistToClosestIP = ip

                            ClosestIntersectingObstacle = curOb

                            LocalPosOfClosestObstacle = LocalPos
                        End If
                    End If
                End If
            End If
        Next

        '//if we have found an intersecting obstacle, calculate a steering 
        '//force away from it
        Dim SteeringForce As New Vector2D
        If Not ClosestIntersectingObstacle Is Nothing Then
            '//the closer the agent is to an object, the stronger the 
            '//steering force should be
            Dim multiplier As Double = 1.0 + (m_dDBoxLength - LocalPosOfClosestObstacle.x) / m_dDBoxLength

            '//calculate the lateral force
            SteeringForce.y = (ClosestIntersectingObstacle.BRadius() - LocalPosOfClosestObstacle.y) * multiplier

            '//apply a braking force proportional to the obstacles distance from
            '//the vehicle. 
            Dim BrakingWeight As Double = 0.2
            SteeringForce.x = (ClosestIntersectingObstacle.BRadius() - LocalPosOfClosestObstacle.x) * BrakingWeight
        End If

        '//finally, convert the steering vector from local to world space
        Return Transformations.VectorToWorldSpace(SteeringForce, m_pVehicle.Heading(), m_pVehicle.Side())
    End Function

    '//this returns a steering force which will keep the agent away from any
    '//walls it may encounter
    '//--------------------------- WallAvoidance --------------------------------
    '//
    '//  This returns a steering force that will keep the agent away from any
    '//  walls it may encounter
    '//------------------------------------------------------------------------
    Private Function WallAvoidance(ByVal walls As ArrayList) As Vector2D
        '//the feelers are contained in a std::vector, m_Feelers
        CreateFeelers()

        Dim DistToThisIP As Double = 0.0
        Dim DistToClosestIP As Double = Double.MaxValue

        '//this will hold an index into the vector of walls
        Dim ClosestWall As Integer = -1
        Dim SteeringForce As Vector2D
        Dim point As Vector2D '         //used for storing temporary info
        Dim ClosestPoint As Vector2D '  //holds the closest intersection point

        '//examine each feeler in turn
        Dim flr As Integer
        Dim w As Integer
        For flr = 0 To m_Feelers.Count - 1
            '//run through each wall checking for any intersection points
            For w = 0 To walls.Count - 1
                If Geometry.LineIntersection2D(m_pVehicle.Pos(), m_Feelers(flr), CType(walls(w), Wall2D).From(), CType(walls(w), Wall2D).ToB, DistToThisIP, point) Then
                    '//is this the closest found so far? If so keep a record
                    If (DistToThisIP < DistToClosestIP) Then
                        DistToClosestIP = DistToThisIP
                        ClosestWall = w
                        ClosestPoint = point

                    End If
                End If

            Next
            '//if an intersection point has been detected, calculate a force  
            '//that will direct the agent away
            If (ClosestWall >= 0) Then
                '//calculate by what distance the projected position of the agent
                '//will overshoot the wall
                Dim OverShoot As Vector2D = CType(m_Feelers(flr), Vector2D).Minus(ClosestPoint)

                '//create a force in the direction of the wall normal, with a 
                '//magnitude of the overshoot
                SteeringForce = CType(walls(ClosestWall), Wall2D).Normal() * OverShoot.Length()
            End If
        Next


        Return SteeringForce
    End Function


    '//given a series of Vector2Ds, this method produces a force that will
    '//move the agent along the waypoints in order
    '//------------------------------- FollowPath -----------------------------
    '//
    '//  Given a series of Vector2Ds, this method produces a force that will
    '//  move the agent along the waypoints in order. The agent uses the
    '// 'Seek' behavior to move to the next waypoint - unless it is the last
    '//  waypoint, in which case it 'Arrives'
    '//------------------------------------------------------------------------
    Private Function FollowPath() As Vector2D
        '//move to next target if close enough to current target (working in
        '//distance squared space)
        If Vector2D.Vec2DDistanceSQ(m_pPath.CurrentWaypoint(), m_pVehicle.Pos()) < m_dWaypointSeekDistSq Then
            m_pPath.SetNextWaypoint()
        End If
        If Not m_pPath.Finished() Then
            Return Seek(m_pPath.CurrentWaypoint())
        Else
            Return Arrive(m_pPath.CurrentWaypoint(), Deceleration.normal)
        End If

    End Function

    '//this results in a steering force that attempts to steer the vehicle
    '//to the center of the vector connecting two moving agents.
    '//--------------------------- Interpose ----------------------------------
    '//
    '//  Given two agents, this method returns a force that attempts to 
    '//  position the vehicle between them
    '//------------------------------------------------------------------------
    Private Function Interpose(ByVal AgentA As Vehicle, ByVal AgentB As Vehicle) As Vector2D
        '//first we need to figure out where the two agents are going to be at 
        '//time T in the future. This is approximated by determining the time
        '//taken to reach the mid way point at the current time at at max speed.
        Dim MidPoint As Vector2D = AgentA.Pos().Plus(AgentB.Pos()).Divided(2.0)

        Dim TimeToReachMidPoint As Double = Vector2D.Vec2DDistance(m_pVehicle.Pos(), MidPoint) / m_pVehicle.MaxSpeed()

        '//now we have T, we assume that agent A and agent B will continue on a
        '//straight trajectory and extrapolate to get their future positions
        Dim APos As Vector2D = AgentA.Pos().Plus(AgentA.Velocity().Mutiply(TimeToReachMidPoint))
        Dim BPos As Vector2D = AgentB.Pos().Plus(AgentB.Velocity().Mutiply(TimeToReachMidPoint))

        '//calculate the mid point of these predicted positions
        MidPoint = APos.Plus(BPos).Divided(2.0)

        '//then steer to Arrive at it
        Return Arrive(MidPoint, Deceleration.fast)

    End Function

    '//given another agent position to hide from and a list of BaseGameEntitys this
    '//method attempts to put an obstacle between itself and its opponent
    Private Function Hide(ByVal hunter As Vehicle, ByVal obstacles As ArrayList) As Vector2D
        Dim DistToClosest As Double = Double.MaxValue
        Dim BestHidingSpot As Vector2D
        Dim curOb, closest As BaseGameEntity
        Dim i As Integer
        For i = 0 To obstacles.Count - 1
            curOb = obstacles(i)
            '//calculate the position of the hiding spot for this obstacle
            Dim HidingSpot As Vector2D = GetHidingPosition(curOb.Pos(), curOb.BRadius(), hunter.Pos())

            '//work in distance-squared space to find the closest hiding
            '//spot to the agent
            Dim dist As Double = Vector2D.Vec2DDistanceSQ(HidingSpot, m_pVehicle.Pos())

            If (dist < DistToClosest) Then
                DistToClosest = dist
                BestHidingSpot = HidingSpot
                closest = curOb
            End If

        Next

        '//if no suitable obstacles found then Evade the hunter
        If (DistToClosest <> Single.MaxValue) Then
            Return Evade(hunter)

        End If


        '//else use Arrive on the hiding spot
        Return Arrive(BestHidingSpot, Deceleration.fast)

    End Function


?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区免费视频| 国产丝袜美腿一区二区三区| 亚洲激情图片小说视频| 色婷婷亚洲综合| 午夜精品一区二区三区三上悠亚| 欧美疯狂做受xxxx富婆| 久久国产生活片100| 国产欧美一区二区三区沐欲| 东方欧美亚洲色图在线| 亚洲欧美日韩国产综合| 欧美乱熟臀69xxxxxx| 韩国一区二区视频| 国产精品毛片大码女人| 欧美亚洲免费在线一区| 久久激情五月激情| 国产精品久久久久久久第一福利 | 中文字幕欧美日韩一区| 成人h动漫精品| 亚洲777理论| 久久久精品欧美丰满| 欧洲av在线精品| 国产精品一品视频| 亚洲一二三区不卡| 久久嫩草精品久久久久| 欧美综合亚洲图片综合区| 精品午夜久久福利影院| 亚洲天堂久久久久久久| 4438x成人网最大色成网站| 国产主播一区二区| 亚洲免费观看高清完整版在线观看| 欧美精品第一页| 丁香婷婷综合激情五月色| 亚洲国产成人精品视频| 国产视频一区二区在线观看| 欧美日韩久久久| 成人免费毛片aaaaa**| 日韩成人伦理电影在线观看| 国产精品久久久久久久久动漫| 欧美高清视频一二三区 | 色网站国产精品| 激情综合色丁香一区二区| 有坂深雪av一区二区精品| 久久色在线观看| 91精品欧美福利在线观看| 91美女在线看| 国产成人av影院| 奇米777欧美一区二区| 最近日韩中文字幕| 国产欧美一区二区在线观看| 91精品国产色综合久久不卡电影| 不卡一区二区在线| 国产精品一线二线三线精华| 日韩高清电影一区| 亚洲午夜私人影院| 中文字幕国产精品一区二区| 日韩午夜激情av| 欧美三区在线观看| 色域天天综合网| 91最新地址在线播放| 国产美女在线观看一区| 乱一区二区av| 三级影片在线观看欧美日韩一区二区| 国产精品福利av| 国产精品色哟哟| 久久看人人爽人人| 久久免费偷拍视频| 精品久久久久久最新网址| 91精选在线观看| 欧美日韩国产首页| 欧美性猛片xxxx免费看久爱| 色噜噜夜夜夜综合网| 99这里都是精品| 成人黄色片在线观看| 粉嫩av一区二区三区粉嫩| 国产高清精品久久久久| 国内精品国产成人国产三级粉色| 免费高清在线一区| 免费成人小视频| 麻豆成人91精品二区三区| 日本麻豆一区二区三区视频| 首页国产欧美日韩丝袜| 日韩电影免费一区| 精品一区二区三区视频| 国产一区二区三区在线观看免费 | 国产精品一区二区在线播放 | 蜜臀av一区二区| 奇米在线7777在线精品| 美腿丝袜亚洲色图| 美女在线视频一区| 国产精品自拍av| 成人国产一区二区三区精品| a级高清视频欧美日韩| 99精品在线免费| 欧美熟乱第一页| 日韩欧美综合一区| 国产亚洲欧美日韩俺去了| 国产嫩草影院久久久久| 亚洲码国产岛国毛片在线| 亚洲一区在线视频观看| 三级久久三级久久久| 精一区二区三区| 高清视频一区二区| 91国产免费观看| 日韩三级伦理片妻子的秘密按摩| 久久精品一区四区| 香港成人在线视频| 另类的小说在线视频另类成人小视频在线 | 日韩欧美成人激情| 国产色一区二区| 亚洲综合在线免费观看| 奇米精品一区二区三区在线观看 | 91成人免费在线| 日韩一级黄色片| 国产精品久久久久永久免费观看 | 国产三级精品在线| 一区二区三区免费看视频| 美日韩一区二区三区| 成人a免费在线看| 日韩欧美中文字幕制服| 亚洲丝袜另类动漫二区| 五月婷婷色综合| 国产99久久久久| 欧美二区三区的天堂| 国产精品盗摄一区二区三区| 日韩中文字幕91| 成人av电影在线观看| 欧美一区二区三区在线看| 中文字幕永久在线不卡| 蜜臂av日日欢夜夜爽一区| 91丨porny丨在线| www国产精品av| 视频一区国产视频| 99精品在线观看视频| 久久综合色综合88| 日精品一区二区| 99国内精品久久| 国产亚洲一区二区三区四区| 日韩精品国产精品| 91免费看片在线观看| 国产视频在线观看一区二区三区| 天天综合天天综合色| 99re这里只有精品6| 久久综合精品国产一区二区三区| 亚洲一区在线播放| 99精品国产视频| 中文字幕免费不卡在线| 国产一区在线视频| 91麻豆精品国产91久久久使用方法 | 婷婷六月综合网| 91网站在线观看视频| 国产日韩欧美一区二区三区乱码| 日本vs亚洲vs韩国一区三区二区| 日本精品裸体写真集在线观看| 久久精品一区蜜桃臀影院| 久久精品国产99国产精品| 欧美日韩在线播放| 亚洲一区二区三区中文字幕| 日韩免费性生活视频播放| 亚洲综合另类小说| 91国产免费看| 亚洲欧美另类图片小说| 99热精品国产| 国产精品福利av| av电影在线观看一区| 国产精品久久久久久久久免费丝袜| 国产成人在线电影| 国产亚洲短视频| 国产高清精品网站| 日本一区二区免费在线| 国产高清不卡一区| 久久久激情视频| 成人久久18免费网站麻豆| 欧美国产日韩在线观看| 不卡一卡二卡三乱码免费网站 | 国产精品美女久久福利网站| 国产精品综合一区二区三区| 国产亚洲欧美日韩俺去了| 粉嫩av一区二区三区粉嫩| 国产日本欧洲亚洲| 99视频精品免费视频| 亚洲免费在线视频一区 二区| 在线观看日韩国产| 亚洲风情在线资源站| 91麻豆精品91久久久久同性| 久久精品国产一区二区三 | 成人美女在线观看| 亚洲品质自拍视频网站| 欧美日韩三级一区| 琪琪久久久久日韩精品| 久久影院视频免费| 成人免费视频播放| 一区二区激情小说| 欧美精品亚洲一区二区在线播放| 蜜臀av性久久久久蜜臀aⅴ | 国产精品久久久爽爽爽麻豆色哟哟| 91小视频免费观看| 视频在线观看91| 国产亚洲成aⅴ人片在线观看 | 国产成人免费9x9x人网站视频| 国产欧美精品国产国产专区 |