SeganX

conflict of dimensions

AI for Cnep —

It’s about 3 weeks that our playable demo of Cnep is ready. it has 2 main mechanics. create and place towers, shoot on enemies. you can find more info about the game here. I improved some features of engine during the demo was developing. AI was one of these features.
Currently the AI includes path finding, mission based decision making and Hierarchical State-Driven Agent Behavior from “Programming Game AI by Example by Mat Buckland”. here I try to explain it briefly to give you some concepts.

States
Each state is a class which inherits from standard state class interface. each agent in the game has a primary state. in addition agents can also have a parallel state to do some parallel operations. we can create an state and replace it with the current state slot of the agent. these states will control the behavior of agent. in other word each agent is similar to a Atari game consul and each state is similar to cartridge of that. by replacing states, the behavior of agent will change.
in Buckland’s design, each state can be atomic or composite. atomic states have no sub states and just do simple operations. for instance pressing a button in the game to open a door. but composite states have a list of sub states. depending on the circumstances in the game, composite states may create sub states and add them to the list. sub states will process consecutively. each sub state will removed when operation completed.
for example when an agent is traversing a path which is closed by a door, the agent can create a sub state for pressing a key to open the door and push it to the list. this new sub state may include some more sub states to find a path to the key, push the key and etc. this process of decomposing and satisfying states continues until the entire hierarchy has been traversed and the agent arrives to the goal.

here is a shot to describes traversing a path which closed by a door :

Hierarchical State-Driven Agent Behavior


in www.ai-junkie.com you can find more books, tutorials, source codes and …

Missions
In this game each Mission is a simple data structure contains position, time, behavior flag and etc. flag of mission can be a combination of different behavior. the brain of agent uses this data structure to make a decision depending on mission flag. there is a queue of missions in the brain of agent. we can push new mission to the brain and the brain will perform each mission respectively.
here is a simple sample which I used in one of our game prototype to set the enemies behavior. the game is in tower defense genre and enemies try to reach the base which placed in the center of game world. also enemies can attack to the towers and when they arrive to the base, they must remove themselves from the game :

Mission m;
m.flag      = MISSION_GOTO_POSITION | MISSION_KILL_ENEMY;
m.pos       = float3(0, 0, 0);
m.status    = Mission::MS_ACTIVE;
pAgent->GetBrain()->AddMission(m);

m.flag = MISSION_SUICIDE;
pAgent->GetBrain()->AddMission(m);

in this example I added two missions to the brain of enemy agent. in the first mission, the flag is the combination of two behaviors include “go to specified position” and “kill the enemies”. the brain creates one state for agents move to the specified position and set that as main state. also the brain creates the other state to find and kill enemies and set that as parallel state. finally if the first mission was successfully completed the brain will process the next mission. the flag of next mission is “suicide” which cause the brain remove his agent from the game.


Cnep —

We start to making a simple game by the engine. so many works I have to do and the time is limited. deadline is so closed and I have no time to update weblog frequently. in this regard I start to develop the engine and editor simultaneous.

Currently the engine has background loading of textures and geometries with 3 level of LOD, step by step validation/invalidation system to load/unload resources in scene, simple shader based material system, particle system, AI path nodes ( POV ), simple 2×2 PCF shadow map, an incomplete forward shading pipeline and some usual features which every engine should have. some works that I have done will described later.

official site of Cnep

Here is some screen shots : [Intel sonoma 1.8 GH – Nvidia GF GO 6400]

Material editor


Particle system


use POV node to handle this game


using LOD increase performance dramatically


Animation as NodeMember —

Lots of engines have different node types and static meshes usually are separate from animated meshes and so on. I don’t prefer to separate static meshes from animated meshes and generally every things from anything. in my engine the base and the most important object in scene structure in Node type. Node types have transformation informations, volumes and etc. they can have parent and child. in addition they can carry NodeMember types. any other objects will inherit of NodeMember type. in other word they are exactly some things similar to components. basically NodeMembers don’t have transformation, volumes and etc and generally geometry. thus They are not counted by scene manager. node members can describe behavior of a node in the scene. for instance a node can has more than one meshes and materials, some rigid bodies and triggers, some AI and script members and sounds that form this node.

Unlike other systems which have different types of meshes for animated meshes, static meshes and even breakable meshes; I think that they can be one mesh type and even the animation can be an independent object type. because we want to attach shaders, nodes and node members to them easily and to draw them in any rendering pipelines unexceptionable. reaching this goal is possible and simple in engine’s scene structure.

In this regard I created a NodeMember called Animator. this object is same as animation controller which can contain shared animations and animation data. by attaching an Animator to a node, any mesh of node, which have shader of animation, will obey the animations sequences. also this member add new node as number of bones to its parent to attach every other things to any specified bones easily. by detaching this object from the node, all meshes will become to default mode and additional nodes will disconnected from the parent.


here is screen shots that show the bones and nodes as red and white cube

nodes with mesh and animator


nodes with mesh and animator playing

model from : http://www.gfx-3d-model.com/2008/07/ninja/


Scene Manager —

I think that Scene manager is the most important part of an engine. rendering pipelines, some lighting techniques and shadow map generators, culling and collision systems, AI system, triggers and any other things in the game that need to cooperate with objects in the scene, have to use the features of Scene managers.

For managing objects in the scene there are many algorithms and techniques of scene management. most of them use tree structures to hold them. the programmers had to use software rasterizer to draw polygons in 3D space before new graphics accelerators appeared. because of that reducing number of polygons and ordering them from back to front was some of the important issues. in this regard objects in the scene managers was usually polygon and the algorithms generally try to split the scene to separated polygons. nowadays hardware rasterizers have different behaviors.

However, rendering a large number of small objects, each made from a few polygons, imposes a big strain on today’s GPUs and rendering libraries. Graphics APIs such as Direct3D and OpenGL are not designed to efficiently render a small number of polygons thousands of times per frame (Wloka 2003).

Today most of scene managers don’t split scene to separate polygons and the algorithms try to manage batches ( meshes, instances , … ) by their location instead of polygons. in addition there are hybrid scene systems which use different algorithms to manage the scene. for instance using Octree to partition the space and BSP to separate meshes to polygons and vice versa. anyway choosing and implementing an appropriate scene management algorithm depends on the genre of the game.

To implement some various kinds of scene graphs in SeganX engine, there is a ::SceneManager interface that contain necessary virtual abstract functions. we can easily implement our scene algorithm by write down a new scene manager class which derived from interface, mentioned before. after that we can pass it to the ::Scene class to let the engine to uses our scene system instead of it’s default scene manager.
some things like this :

    //  interface of scene manager
    class SEGAN_API SceneManager
    {
    public:
        /*!
        fill the node list by founded nodes in the frustum.
        NOTE: this function called by many parts of core/rendering/AI/etc and should be fast as possible.
        */

        virtual void GetNodesByFrustum(const Frustum& frustum, IN_OUT ArrayPNode& nodeList) = 0;
    ...
    };
   
    //  our new scene manager derived from SceneManager
    class MySceneManager : public SceneManager
    {
    public:
        virtual void GetNodesByFrustum(const Frustum& frustum, IN_OUT ArrayPNode& nodeList);
    ...
    };
   
    //  implement our new scene manager to the engine
    MySceneManager pSceneManager = SEGAN_NEW( MySceneManager );
    Scene::Initialize( pSceneManager );
    ...



Currently the engine has a default scene manager that use Spherical Bounding Volume Hierarchy (SBVH) to manage the objects in the scene by their bounding sphere. supporting dynamic objects and removing compile step to create the tree are some of my algorithm features. all nodes can insert/remove/update in run time mode, collecting and gathering nodes is guaranteed and the performance is acceptable. but using sphere as bounding volume has basically some drawbacks and no required accuracy. the main disadvantage of using SBVH is sinking spheres which cause to traverse useless nodes in the tree.

Scene manager in debug mode




however simple and fast collision detection for spheres ( in comparison with others ) make the algorithm faster and acceptable.

scene manager in debug mode draw sphere of each sector




The heart of the algorithm is the place that we choose a leaf of node ( Sector in my tree ) to traverse the tree to find an appropriate position for new sector when we want to insert or update a node. in this situation there is three sectors, two sector from the node of the tree and our new one. at first look, comparing two distance of sectors that compute by center of their spheres between our new sector and the others is the good solution. but not actually! contributing more parameters like third distance and radius of spheres to choose the next sector to traverse the tree can greatly effects on the form of the tree.

here are my function implementation to find nearest node to the specified sphere of new node. I used this function just for insert new node to the scene manager :

inline void FindNearestSectorTo(const PSector root, const Sphere& sphere, IN_OUT PSector& result)
{
    static float dis = 0.0f;
    if ( !root ) return;

    if ( !sphere.Intersect(root->m_sphere, dis) || root->m_node)
    {
        if ( distance_Point_Point_sqr(root->m_sphere.center, sphere.center) < distance_Point_Point_sqr(result->m_sphere.center, sphere.center) )
            result = root;
        return;
    }

    if (root->m_left && root->m_left->m_node && root->m_right->m_node)
    {
        float dis_left = distance_Sector_Point_sqr( root->m_left, sphere.center);
        float dis_right = distance_Sector_Point_sqr( root->m_right, sphere.center);
        float dis_left_right = distance_Sector_Sector_sqr(root->m_left, root->m_right);
        PSector res = NULL;

        if (root->m_left && dis_left<dis_left_right && dis_left<dis_right)
            res = root->m_left;
        else if (root->m_right && dis_right<dis_left_right && dis_right<dis_left)
            res = root->m_right;
        else
            res = root;

        if ( distance_Point_Point_sqr(res->m_sphere.center, sphere.center) < distance_Point_Point_sqr(result->m_sphere.center, sphere.center) )
            result = res;
    }
    else
    {
        FindNearestSectorTo( root->m_left, sphere, result );
        FindNearestSectorTo( root->m_right, sphere, result );
    }
}

as you can see I used three parameters of distance between point and left sector, point and right sector and in addition distance between left sector and right sector. certainly there are many better algorithm to choose right sector and the code still need more optimization.


popular personal essay writers for hire usa buy astronomy presentation write my religious studies thesis statement help me write professional phd essay on trump esl dissertation results writing for hire best custom essay ghostwriter for hire for college best admission essay writers service au professional dissertation hypothesis proofreading services for college professional masters blog post topic custom academic essay editor for hire for mba top curriculum vitae editing service au help with my custom critical thinking online pay to write cheap admission essay best blog post writing services cheap paper ghostwriters services for university professional homework writer website gb top dissertation hypothesis editing services uk custom essay ghostwriter for hire for university esl problem solving editor site us type my classic english literature report help me write custom reflective essay esl critical analysis essay proofreading for hire ca cheap curriculum vitae ghostwriting site us best reflective essay ghostwriters websites for mba top dissertation hypothesis editor sites usa cheap content editing for hire for college popular report ghostwriting services usa popular admission essay editor services usa descriptive essay writer site uk custom dissertation abstract editing sites cheap research proposal editing service usa best school essay writers service online cheap college cheap essay advice buy english report professional blog editor website for masters professional dissertation ghostwriting websites online esl case study ghostwriting service us pay to do top problem solving online cheap critical analysis essay proofreading sites for college cheap article review ghostwriters sites uk soft shell lobster top article ghostwriting websites au custom creative essay writing service gb popular blog post ghostwriter site for university top expository essay writers websites custom university essay editing sites for university cheap mba admission essay ideas do my human resource management creative writing dissertation ghostwriter websites au professional speech editor websites for masters best writing service online esl analysis essay writer website uk professional school homework assistance best dissertation methodology writing for hire for phd best literature review ghostwriting websites for phd popular application letter writing websites for college esl letter writer website gb top definition essay writer site best creative writing writers sites online popular biography editor sites for university culture essay writing for hire best cover letter ghostwriter website for mba top presentation ghostwriting services usa professional dissertation methodology proofreading services for college esl blog post writers sites for masters esl speech editor website usa popular university essay ghostwriting sites for phd professional dissertation methodology writers websites for masters cheap papers writing service gb top papers writer sites for phd esl descriptive essay editor sites for university top home work writer website for university top dissertation results editing service for mba popular thesis proposal writers for hire online cheap definition essay ghostwriter services usa professional scholarship essay editor site us esl bibliography editing site online type my family and consumer science curriculum vitae cheap expository essay proofreading for hire critical analysis essay proofreading services au law essay sample top personal statement editor site buy professional letter top academic essay ghostwriters service for school popular blog ghostwriters sites us best mba essay writer sites ca reflective essay for university write my engineering application letter cheap masters essay writers services for mba professional presentation ghostwriter website ca ancient egyptian paper best admission essay writing websites for university custom thesis writer for hire us custom reflective essay ghostwriter service for school popular college essay ghostwriter site online custom definition essay writing for hire gb write environmental studies bibliography popular essays ghostwriter site uk cheap assignment ghostwriters service for mba custom paper writing sites gb pay to write admission essay on lincoln professional personal statement proofreading websites for masters cheap scholarship essay writing sites ca top content ghostwriting service gb popular analysis essay editing website online esl report writing service for mba help with my ancient civilizations dissertation chapter top problem solving ghostwriters site online popular course work ghostwriters website for university best definition essay ghostwriter site for university cheap analysis essay writer service for school help with trigonometry dissertation methodology custom editor service for masters preschool child observation report pay to do communication term paper pay to do health course work popular essays ghostwriting for hire online esl thesis proposal writing websites for mba type my top best essay professional research paper ghostwriter service usa professional research proposal proofreading service esl dissertation proposal ghostwriter service for university popular creative writing ghostwriter websites ca best blog ghostwriting site for college best content writer service gb professional presentation ghostwriting site uk esl university dissertation chapter example popular mba essay writers sites online popular dissertation introduction ghostwriters site au liberal view on poverty order top scholarship essay on usa top scholarship essay proofreading service ca top annotated bibliography writers for hire for phd cheap mba dissertation methodology examples the buried life summary popular argumentative essay writer sites for masters best research proposal editor sites for phd professional research proposal proofreading websites usa top papers editor sites uk esl biography proofreading service us cheap college cover letter samples popular college creative writing examples pay for custom problem solving online personal proofreading service au custom dissertation abstract writers websites online cheap research paper writing site online best bibliography editing services gb hamlet comic relief top university biography topics top scholarship essay writers website gb esl term paper editor website for masters top term paper ghostwriters services us esl admission essay writers for hire for university personal statement editor for hire online top blog writers site au cheap paper editing services for college business essay writer sites top speech editing for hire us pay for my custom reflective essay on donald trump cheap dissertation chapter writers websites for school professional report ghostwriter service for college best admission paper ghostwriting services for masters custom blog editor site for mba julius caesar paper help with my esl persuasive essay on civil war custom thesis writing service for university custom scholarship essay writer services ca a seperate peace theme write esl expository essay on usa community identity stability best movie review ghostwriters sites for university custom article review editing websites for school pay for professional rhetorical analysis essay on brexit community essay sample top resume ghostwriting site for phd esl article review writing services ca best book review proofreading website for mba custom thesis writing site au popular admission paper ghostwriter website au best book review editing websites usa cheap homework editor website for university cheap cover letter writer websites for mba just lather esl university academic essay example esl paper editing services ca best university cv example pay to write popular admission essay on lincoln professional research paper editing sites online top case study ghostwriter site for college top speech ghostwriting website for mba professional speech writing website for university custom course work proofreading for hire for college professional dissertation methodology editor for hire for masters popular rhetorical analysis essay proofreading service au critical essay ghostwriting for hire uk help with my esl custom essay on usa popular dissertation hypothesis ghostwriter for hire for mba best thesis ghostwriters service for mba pros of racial profiling custom critical analysis essay ghostwriting site usa pay to get phd essay on usa cheap cv ghostwriters for hire usa esl research proposal ghostwriting service gb write me esl book review esl best essay proofreading site help me write shakespeare studies cover letter help me write best critical essay on presidential elections professional cv ghostwriting sites for mba write my best bibliography online best masters thesis advice top analysis essay writers website for university website review essay best analysis essay writer site for university pay for my professional creative essay on presidential elections custom content writing sites au best reflective essay ghostwriting for hire usa professional curriculum vitae editor website au esl dissertation chapter writer websites usa custom phd biography topic cheap phd curriculum vitae advice popular book review ghostwriter service for university write top business plan online blog ghostwriters sites online esl university assignment sample custom essays ghostwriters for hire for school custom essay ghostwriters service top persuasive essay ghostwriting service for school custom reflective essay editor websites ca top academic essay writers service for phd best writer site au professional dissertation proposal writers service for college top admission essay editor for hire for school best dissertation results editor service for mba popular rhetorical analysis essay editor site au cheap phd essay ghostwriters website for university custom scholarship essay writing service usa blog post ghostwriters service au best phd essay ghostwriter website for school cheap biography writers website us custom argumentative essay proofreading websites for mba cheap mba business plan topics help writing life science thesis write medicine letter popular academic essay ghostwriting services au pay to do popular phd essay on presidential elections professional admission paper ghostwriting for hire gb professional content writers sites for school help me write best masters essay on lincoln esl course work ghostwriter site uk popular article ghostwriter for hire for phd custom critical essay ghostwriting sites uk scholarship editor website usa mom is best popular blog post ghostwriter sites au cheap academic essay writer service au cheap scholarship essay writers services au cheap dissertation writing for hire usa top thesis proposal ghostwriter service gb professional academic essay ghostwriting service for university dissertation abstract writing for hire gb popular content writer website au esl annotated bibliography writers website uk best critical analysis essay writers services for university custom dissertation results editing websites for masters love in la sparknotes top biography writing for hire uk best academic essay ghostwriters site for university top report ghostwriters service for college popular dissertation introduction writer services for masters professional best essay editor services us popular article review ghostwriters services for college custom personal essay on usa custom thesis proposal ghostwriters websites for mba top annotated bibliography proofreading service for university best critical analysis essay writing website ca popular dissertation abstract ghostwriting services us popular blog writing websites best school essay writing sites for masters pay to write art & architecture bibliography top research paper writers website for phd top literature review ghostwriter website gb cheap college movie review socialization and culture top letter editing site au top dissertation results writers sites for school popular cv editing site for university popular thesis writing websites au best creative essay ghostwriting service online cheap literature review editor site au custom college course work example help me write popular creative essay on hacking top academic essay ghostwriter service best critical thinking editor website us professional masters expository essay help best rhetorical analysis essay ghostwriting services uk popular expository essay writer service for school professional homework proofreading website for mba cheap article editing site for college popular school cv examples logic essay ghostwriting site professional mba dissertation proposal esl dissertation ghostwriter services for phd phd essay on history best dissertation methodology ghostwriter website au popular book review proofreading site for university popular course work ghostwriter website usa cheap creative essay ghostwriting for hire for phd esl creative writing writing for hire for school elvis presleys wife cheap dissertation hypothesis ghostwriting for hire for university what are western religions top blog ghostwriting sites ca help writing best analysis essay on hillary cheap dissertation proposal writing for hire au help with custom admission paper buy shakespeare studies thesis top critical essay editor service online esl expository essay writers site custom personal essay editor service for school popular blog ghostwriter sites au type my professional critical essay on shakespeare custom persuasive essay writing sites us esl paper editing site us pay to write health speech cheap essays writers website usa esl university essay ghostwriting website for phd cheap best essay writer services gb cheap scholarship essay proofreading website for phd help with best literature review online custom creative writing writers service au professional annotated bibliography ghostwriter services ca dissertation chapter ghostwriter sites us professional dissertation proposal writer website for mba literature review writers services ca order classic english literature resume persuasive editor services us popular best essay writing for hire for university rhetorical analysis ghostwriter websites au top curriculum vitae proofreading service gb professional research proposal proofreading site for masters popular business plan ghostwriting site for college custom university essay ghostwriting website for mba type my women and gender studies creative writing best mba essay ghostwriters for hire us cheap phd essay ghostwriter service best dissertation abstract ghostwriting website for phd esl speech proofreading sites for school custom argumentative essay editing site for mba custom school letter assistance best dissertation conclusion editor websites for phd do my custom masters essay on shakespeare esl curriculum vitae editor service custom academic essay writing for hire au type my custom academic essay on usa professional critical thinking ghostwriters site for masters esl book review writers websites au professional creative essay ghostwriter websites for university pay to write investments admission essay physics writing websites top critical thinking writers sites ca case study ghostwriter site ca professional presentation ghostwriter site for school cheap argumentative essay editor websites for school popular course work ghostwriters website uk top course work ghostwriter service for school help writing statistics dissertation conclusion popular personal essay writing services online life science essay writers for hire custom thesis proposal writer services uk esl bibliography ghostwriting service cheap university business plan topic best dissertation results editor service ca cheap curriculum vitae editor sites for school best biography editor website au professional argumentative essay writing service top book review writer websites for school popular dissertation ghostwriter site usa custom phd essay ghostwriter website top college essay ghostwriter site online esl blog ghostwriter websites online best best essay writers services us buy logic cover letter professional scholarship essay ghostwriting for hire for university help writing film studies cv esl proofreading website au pay for tourism bibliography top annotated bibliography writing website uk business analysis paper popular rhetorical analysis essay writing websites for phd an image of africa meaning of true friendship cheap cover letter ghostwriters services popular dissertation ghostwriters site usa write me ancient civilizations movie review order world literature book review professional admission essay proofreading website uk popular course work ghostwriter sites for university biography proofreading for hire online ahab in moby dick nature vs nurture research paper custom college dissertation ideas cheap school annotated bibliography advice best course work ghostwriter for hire uk esl article review editing for hire for mba custom definition essay writing site for phd pay to write anthropology article review professional phd dissertation sample cheap book review writer websites custom dissertation results ghostwriter for hire us pay to write communication book review popular article ghostwriter sites online esl speech proofreading website for phd cheap essays writers services au professional masters essay ghostwriting service for phd top business plan writing services for university best curriculum vitae writing website au professional university admission essay advice popular expository essay ghostwriter websites pay to get theater studies dissertation results popular custom essay ghostwriter website for masters custom application letter editing websites for college symbols in the metamorphosis professional thesis proposal ghostwriter service for school popular mba term paper topic breathing underwater sparknotes great depression essay introduction earth science ghostwriters sites cheap personal statement writing services for college custom speech ghostwriting website us dissertation writing services gb popular home work ghostwriters services usa custom descriptive essay writing websites usa professional blog post writers sites for mba popular letter proofreading services for college pay to write custom academic essay on usa best blog editing sites for phd esl admission paper proofreading services uk professional dissertation chapter ghostwriting websites for masters cheap university essay ghostwriter site au custom papers editing site for mba top university essay proofreading website ca help with top dissertation conclusion esl dissertation conclusion editor site au popular blog post writer site for masters esl scholarship essay writers services custom business plan ghostwriter website online esl essays proofreading for hire for mba professional thesis statement writer site uk best article ghostwriters sites ca united methodist communion order earth science admission essay professional personal statement proofreading service for school custom problem solving writers services for school professional homework ghostwriter website ca college ghostwriting websites au logic writing site popular best essay editor services au cheap bibliography ghostwriter for hire uk best report editor site au cheap thesis proofreading site gb professional thesis statement ghostwriter services gb my personal philosophy professional report editing service for university custom ghostwriters website for masters popular scholarship essay proofreading sites usa help me write top blog online top thesis statement writer websites for university cheap assignment ghostwriter services top research paper proofreading site for college cheap research proposal ghostwriter websites online best academic essay proofreading services au pay to get english dissertation hypothesis cheap dissertation abstract ghostwriters sites professional phd resume assistance help with music thesis proposal buy human resource management admission paper professional blog post writer for hire ca best college curriculum vitae samples esl paper ghostwriter service best best essay writing for hire for phd write me best analysis essay online cheap application letter writer sites for mba custom rhetorical analysis essay editing site for college professional problem solving proofreading service for phd esl blog post editing site au reflective editing sites usa esl dissertation conclusion proofreading sites au help with my music home work communication writers services professional phd dissertation hypothesis advice help with my top masters essay on hacking best term paper ghostwriter service for school cheap curriculum vitae editing sites for mba pay to do popular school essay on trump help me write esl university essay on brexit custom research paper writing website gb esl academic essay proofreading for hire top argumentative essay writing services usa popular argumentative essay proofreading for hire for university pay to do history annotated bibliography