GithubHelp home page GithubHelp logo

luhan / aoi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jerryzhou/aoi

0.0 2.0 0.0 770 KB

area of interest(AOI), Navigation-Mesh

CMake 0.15% C 51.05% C++ 45.82% Lua 0.90% Makefile 0.11% Go 1.96%

aoi's Introduction

TODO:

  • foundation
    • imath: imatrix basic mathmatics
  • ai: fsm, learing-deep, game - tree algorithms
  • actor: moving-collide-system
  • rangite: make range-over is safe for container remove and delete
  • navi: auto-gen-mesh, gen-mesh-for-tilebased

视野服务 area of interest(AOI)

游戏服务器的AOI(area of interest)部分,位置有关的游戏实体一般都有一个视野或关心的范围

  • 适用于大批量的对象管理和查询
  • 采用四叉树来进行管理,可以通过少量改动支持3D
  • 动态节点回收管理,减少内存, 节点的数量不会随着四叉树的层次变得不可控,与对象数量成线性关系
  • 缓存搜索上下文,减少无效搜索,对于零变更的区域,搜索会快速返回
  • 整个搜索过程,支持自定义过滤器进行单元过滤
  • AOI 支持对象的内存缓冲区管理
  • 支持单位半径,不同单位可以定义不同的半径(开启半径感知,会损失一部分性能)
  • 只提供了搜索结构,不同单位的视野区域可以定义不一样

提高内存访问,建议启用 iimeta (1) 如果不需要单位半径感知 建议关闭 iiradius (0)

How to Build (CMake Tools)

```
mkdir build
cd build
cmake ../
make
```

性能测试

通过提供的prof 工具测试获取自己需要的参数 aoi-prof c [divide] [max-unit] [min-search-range] [max-rand-search-range] [benchtimes] 测试样例

单元测试

```
aoi-test
```

lua Test

build first and then:

```
lua test.lua
```

效率案例

地图 512x512 , 10 级分割 在地图上同时移动 1000 个对象 实时搜索100个对象周边的视野对象 总共平均耗时 1-2 毫秒 单次搜索平均耗时 8-15 纳秒 机器:i7(2.4), 8G

详情见wiki

简单实用

```
// make game world
imap *map = imapmake(pos, size, divide)

// make a unit
iunit *unit = iunitmake(id, x, y);

// add unit to game world
imapaddunit(map, unit);

// update the unit position
unit->pos.x = 1;
unit->pos.y = 1;

// refresh the unit position in game world
imapupdateunit(map, unit):

// remove the unit from game world
imapremoveunit(map, unit);

// make a aoi list
isearchresult *result = isearchresultmake();

// search the unit in range of unita
imapsearchfromunit(map, unita, result, range)

// free the aoi list
isearchresultfree(result)
```

wiki

主要是维护实体区域,并维护对象的AOI列表

8个对象,1个视野对象维护AOI

1.2M内存消耗,750 个对象同时移动,100个对象同时计算周围的AOI,总共消耗2毫秒的样子

增加了Navigation-Mesh 的方案

aoi's People

Contributors

donnki avatar jerryzhou avatar rocaltair avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.