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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cellspacepartition.vb

?? 一個.Net下用VB編寫的用于游戲的人工智能引擎
?? VB
字號:
'//  Desc:   class to divide a 2D space into a grid of cells each of which
'//          may contain a number of entities. Once created and initialized 
'//          with entities, fast proximity querys can be made by calling the
'//          CalculateNeighbors method with a position and proximity radius.
'//
'//          If an entity is capable of moving, and therefore capable of moving
'//          between cells, the Update method should be called each update-cycle
'//          to sychronize the entity and the cell space it occupies

Public Class CellSpacePartition
    Private Class Cell
        '//all the entities inhabiting this cell
        Public Members As ArrayList

        '//the cell's bounding box (it's inverted because the Window's default
        '//co-ordinate system has a y axis that increases as it descends)
        Public BBox As InvertedAABBox2D

        Public Sub New(ByVal topleft As Vector2D, ByVal botright As Vector2D)
            BBox = New InvertedAABBox2D(topleft, botright)
            Members = New ArrayList
        End Sub
    End Class

    '//the required amount of cells in the space
    Dim m_Cells As New ArrayList

    '//this is used to store any valid neighbors when an agent searches
    '//its neighboring space
    Dim m_Neighbors As New ArrayList

    '//this iterator will be used by the methods next and begin to traverse
    '//through the above vector of neighbors
    Dim m_curNeighbor As Integer

    '//the width and height of the world space the entities inhabit
    Dim m_dSpaceWidth As Double
    Dim m_dSpaceHeight As Double

    '//the number of cells the space is going to be divided up into
    Dim m_iNumCellsX As Integer
    Dim m_iNumCellsY As Integer

    Dim m_dCellSizeX As Double
    Dim m_dCellSizeY As Double


    '//given a position in the game space this method determines the           
    '//relevant cell's index
    '//--------------------- PositionToIndex ----------------------------------
    '//
    '//  Given a 2D vector representing a position within the game world, this
    '//  method calculates an index into its appropriate cell
    '//------------------------------------------------------------------------
    Private Function PositionToIndex(ByVal pos As Vector2D) As Integer
        Dim idx As Integer = CInt(m_iNumCellsX * pos.x / m_dSpaceWidth) + CInt((m_iNumCellsY * pos.y / m_dSpaceHeight) * m_iNumCellsX)

        '//if the entity's position is equal to vector2d(m_dSpaceWidth, m_dSpaceHeight)
        '//then the index will overshoot. We need to check for this and adjust
        If (idx > m_Cells.Count - 1) Then idx = m_Cells.Count - 1
        Return idx
    End Function


    '  CellSpacePartition(double width,        //width of the environment
    '                    double height,       //height ...
    '                     int   cellsX,       //number of cells horizontally
    '                   int   cellsY,       //number of cells vertically
    '                  int   MaxEntitys);  //maximum number of entities to add
    Public Sub New(ByVal width As Double, ByVal height As Double, ByVal cellsX As Integer, ByVal cellsY As Integer, ByVal MaxEntitys As Integer)
        m_dSpaceWidth = width
        m_dSpaceHeight = height
        m_iNumCellsX = cellsX
        m_iNumCellsY = cellsY
        m_Neighbors = New ArrayList '(MaxEntitys, entity())
        '//calculate bounds of each cell
        m_dCellSizeX = width / cellsX
        m_dCellSizeY = height / cellsY

        '  //create the cells
        Dim x, y As Integer
        For y = 0 To m_iNumCellsY - 1
            For x = 0 To m_iNumCellsX
                Dim left As Double = x * m_dCellSizeX
                Dim right As Double = left + m_dCellSizeX
                Dim top As Double = y * m_dCellSizeY
                Dim bot As Double = top + m_dCellSizeY

                m_Cells.Add(New Cell(New Vector2D(left, top), New Vector2D(right, bot)))

            Next
        Next
    End Sub

    '//adds entities to the class by allocating them to the appropriate cell
    'inline void AddEntity(const entity& ent);
    Public Sub AddEntity(ByVal o As BaseGameEntity)
        Dim sz As Integer = m_Cells.Count
        Dim idx = PositionToIndex(o.Pos)

        CType(m_Cells(idx), Cell).Members.Add(o)
    End Sub

    '//update an entity's cell by calling this from your entity's Update method 
    'inline void UpdateEntity(const entity& ent, Vector2D OldPos);
    Public Sub UpdateEntity(ByVal ent As BaseGameEntity, ByVal OldPos As Vector2D)
        '//if the index for the old pos and the new pos are not equal then
        '//the entity has moved to another cell.
        Dim OldIdx As Integer = PositionToIndex(OldPos)
        Dim NewIdx As Integer = PositionToIndex(ent.Pos())

        If (NewIdx = OldIdx) Then Return

        '//the entity has moved into another cell so delete from current cell
        '//and add to new one
        CType(m_Cells(OldIdx), Cell).Members.Remove(ent)
        CType(m_Cells(NewIdx), Cell).Members.Add(ent)

    End Sub

    '//this method calculates all a target's neighbors and stores them in
    '//the neighbor vector. After you have called this method use the begin, 
    '//next and end methods to iterate through the vector.
    '//----------------------- CalculateNeighbors ----------------------------
    '//
    '//  This must be called to create the vector of neighbors.This method 
    '//  examines each cell within range of the target, If the 
    '//  cells contain entities then they are tested to see if they are situated
    '//  within the target's neighborhood region. If they are they are added to
    '//  neighbor list
    '//------------------------------------------------------------------------
    Public Sub CalculateNeighbors(ByVal TargetPos As Vector2D, ByVal QueryRadius As Double)
        '//create an iterator and set it to the beginning of the neighbor vector
        Dim curNbor As Integer = 0

        '//create the query box that is the bounding box of the target's query
        '//area
        Dim QueryBox As New InvertedAABBox2D(TargetPos.Minus(New Vector2D(QueryRadius, QueryRadius)), TargetPos.Plus(New Vector2D(QueryRadius, QueryRadius)))

        '//iterate through each cell and test to see if its bounding box overlaps
        '//with the query box. If it does and it also contains entities then
        '//make further proximity tests.
        Dim curCell As Integer
        Dim it As Integer
        For curCell = 0 To m_Cells.Count - 1
            '//test to see if this cell contains members and if it overlaps the
            '//query box
            If CType(m_Cells(curCell), Cell).BBox.isOverlappedWith(QueryBox) And CType(m_Cells(curCell), Cell).Members.Count > 0 Then
                '//add any entities found within query radius to the neighbor list
                For it = 0 To CType(m_Cells(curCell), Cell).Members.Count - 1
                    If Vector2D.Vec2DDistanceSQ(CType(CType(m_Cells(curCell), Cell).Members(it), BaseGameEntity).Pos, TargetPos) < QueryRadius * QueryRadius Then
                        Me.m_Neighbors.Add(CType(m_Cells(curCell), Cell).Members(it))
                    End If
                Next

            End If
        Next
    End Sub

    '//returns a reference to the entity at the front of the neighbor vector
    Public Function begin() As Object
        m_curNeighbor = 0
        Return m_Neighbors(0)
    End Function

    '//this returns the next entity in the neighbor vector
    Public Function nextNeighbor() As Object
        m_curNeighbor += 1
        Return m_Neighbors(m_curNeighbor)
    End Function

    '//returns true if the end of the vector is found (a zero value marks the end)
    Public Function IsEnd() As Boolean
        Return m_curNeighbor = m_Neighbors.Count - 1 Or m_curNeighbor = 0
    End Function

    '//empties the cells of entities
    Public Sub EmptyCells()
        Dim i As Integer
        For i = 0 To m_Cells.Count - 1
            CType(m_Cells(i), Cell).Members.Clear()
        Next
    End Sub

    '//call this to use the gdi to render the cell edges
    Public Sub RenderCells(ByVal g As Graphics)

    End Sub

    Public ReadOnly Property Neighbors() As ArrayList
        Get
            Return m_Neighbors
        End Get
    End Property
End Class

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区二区不卡| 国产性做久久久久久| 日韩天堂在线观看| 亚洲视频资源在线| 国产黄色精品视频| 欧美一卡二卡在线| 亚洲男人都懂的| 国产乱码精品一区二区三区忘忧草| 欧美这里有精品| 中文字幕欧美激情一区| 久久99精品久久久久婷婷| 欧美精品一卡二卡| 亚洲综合色在线| 色综合 综合色| 国产精品久久久久久久裸模| 国产精品一区二区久久不卡| 日韩一区二区高清| 日韩av电影一区| 欧美日韩免费高清一区色橹橹| 亚洲区小说区图片区qvod| 国产成人日日夜夜| 久久久精品中文字幕麻豆发布| 日韩成人av影视| 91精品国产麻豆| 免费观看在线综合| 日韩精品一区在线| 久久国产精品99久久久久久老狼| 日韩欧美国产一区二区在线播放| 天使萌一区二区三区免费观看| 欧美性xxxxxxxx| 亚洲国产精品久久不卡毛片| 色爱区综合激月婷婷| 亚洲欧美偷拍卡通变态| 91麻豆国产在线观看| 综合久久久久综合| 欧洲亚洲国产日韩| 水野朝阳av一区二区三区| 欧美日韩国产a| 久久99日本精品| 日本一区二区三区久久久久久久久不| 国产精品一区二区三区99| 国产精品午夜久久| 99亚偷拍自图区亚洲| 亚洲女同女同女同女同女同69| 色综合色综合色综合色综合色综合 | 91网站在线观看视频| 亚洲精品欧美综合四区| 欧美二区三区的天堂| 久久97超碰国产精品超碰| 国产区在线观看成人精品| 成人少妇影院yyyy| 亚洲在线视频网站| 日韩亚洲欧美在线| va亚洲va日韩不卡在线观看| 亚洲综合男人的天堂| 欧美电影免费观看高清完整版| 黄页网站大全一区二区| 国产精品超碰97尤物18| 欧美夫妻性生活| 国产成+人+日韩+欧美+亚洲| 亚洲人成网站精品片在线观看| 欧美日韩国产区一| 国产精品99久久久久久久vr| 亚洲女同女同女同女同女同69| 91精品欧美一区二区三区综合在 | 日韩一区二区中文字幕| 国产成人啪午夜精品网站男同| 国产精品久久久久久久午夜片| 欧美视频一区二区三区在线观看| 久久97超碰国产精品超碰| 亚洲精品乱码久久久久久久久 | 欧美日韩精品三区| 国产精品乡下勾搭老头1| 亚洲精品视频在线观看免费 | 国产精品天天看| 欧美日韩久久不卡| 粗大黑人巨茎大战欧美成人| 五月婷婷激情综合| 国产精品丝袜黑色高跟| 日韩欧美一级二级三级| 欧美中文字幕一区二区三区 | 欧美日韩国产片| 成人精品一区二区三区中文字幕| 五月综合激情网| 一区二区三区中文免费| 日本一区二区三区四区| 日韩视频免费观看高清完整版 | 亚洲h动漫在线| 亚洲图片激情小说| 久久久无码精品亚洲日韩按摩| 欧美精品777| 欧美性色黄大片| 91毛片在线观看| 北条麻妃国产九九精品视频| 激情六月婷婷综合| 精品在线一区二区| 日韩国产欧美视频| 亚洲大尺度视频在线观看| 亚洲视频 欧洲视频| 国产精品乱人伦中文| 久久久一区二区三区| 日韩精品中午字幕| 日韩欧美国产小视频| 777久久久精品| 欧美一区二区三区免费| 欧美日韩高清不卡| 在线91免费看| 欧美三级电影网站| 欧美日韩一区二区三区高清| 久久品道一品道久久精品| 欧美电影免费观看完整版| 欧美一区午夜视频在线观看| 日韩一级视频免费观看在线| 欧美日韩激情一区二区三区| 欧美午夜视频网站| 欧美日韩久久不卡| 日韩一卡二卡三卡| 亚洲精品在线观| 欧美高清在线一区| 最新欧美精品一区二区三区| 中文字幕字幕中文在线中不卡视频| 国产精品高清亚洲| 亚洲男同1069视频| 亚洲成av人在线观看| 日本不卡一区二区| 国产在线观看一区二区| 成人综合在线视频| 色综合视频在线观看| 欧美高清激情brazzers| 精品国产青草久久久久福利| 久久久www成人免费毛片麻豆| 国产女主播一区| 亚洲男同性恋视频| 七七婷婷婷婷精品国产| 高清av一区二区| 色呦呦国产精品| 欧美一级免费观看| 中文字幕不卡在线| 亚洲午夜三级在线| 九九久久精品视频| 不卡免费追剧大全电视剧网站| 91成人网在线| 欧美一级精品在线| 国产精品区一区二区三| 香蕉av福利精品导航| 激情综合网激情| 一本大道久久a久久精二百| 欧美一级生活片| 久久99最新地址| 色婷婷狠狠综合| 精品少妇一区二区三区日产乱码| 欧美激情一二三区| 亚洲bdsm女犯bdsm网站| 国产精品911| 欧美精品一二三四| 中文av字幕一区| 日本成人在线不卡视频| 91亚洲午夜精品久久久久久| 在线播放一区二区三区| 国产精品国产三级国产普通话蜜臀 | 日韩电影在线一区二区| 国产成人免费视频一区| 欧美老肥妇做.爰bbww视频| 国产精品色哟哟| 另类小说视频一区二区| 欧美亚洲图片小说| 欧美国产一区二区| 美女网站色91| 欧美日韩一区久久| 亚洲欧美一区二区视频| 狠狠色丁香久久婷婷综合丁香| 日本精品一区二区三区高清| 日本一区二区免费在线| 日本系列欧美系列| 欧美天堂一区二区三区| 亚洲欧美在线观看| 国产成人精品综合在线观看 | 欧美日韩免费一区二区三区| 国产精品国产三级国产普通话蜜臀| 午夜免费欧美电影| 欧美日韩亚洲不卡| 一区二区三区蜜桃网| 91美女视频网站| 国产精品久久久久精k8 | 麻豆一区二区99久久久久| 91搞黄在线观看| 1区2区3区精品视频| 国产盗摄女厕一区二区三区 | 欧美国产日本韩| 激情文学综合插| 日韩午夜在线播放| 秋霞成人午夜伦在线观看| 欧美人妖巨大在线| 偷拍日韩校园综合在线| 欧美日韩国产成人在线91| 肉丝袜脚交视频一区二区| 欧美唯美清纯偷拍| 亚洲成人动漫精品| 91精品婷婷国产综合久久性色| 天天综合网 天天综合色|