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.


cheap mba speech example professional essays ghostwriter site ca pay for best reflective essay on founding fathers help writing world literature book review top critical essay on usa popular creative essay editing site for phd popular biography ghostwriters services for mba top college biography ideas help with business paper best term paper editing sites us buy best admission essay on hacking help me write professional cheap essay on hacking cheap cover letter editor for hire for college content editor service usa custom speech writing websites write me theater studies thesis proposal professional papers ghostwriter website custom application letter ghostwriter services for school cheap cv writing websites us professional critical thinking writer websites ca custom university book review topic top dissertation writer site best case study ghostwriting website usa top article review editing services for university top annotated bibliography ghostwriter services online popular dissertation proposal editor site ca professional biography writer website ca popular cv writing site for phd help with custom creative essay on shakespeare professional cv ghostwriters service understanding eskimo science resume ghostwriting websites ca help me write philosophy dissertation hypothesis best literature review ghostwriters website us order best blog online custom college essay ghostwriting website for masters popular university essay ghostwriters for hire au order human resource management argumentative essay a sorrowful woman top thesis proposal writers services online do my english as second language dissertation abstract eli and clare pay to do dissertation results online plunkitt of tammany hall summary popular resume editing sites for masters cheap blog post writers service ca university essay on political science help with my family and consumer science dissertation proposal popular rhetorical analysis essay writing websites for phd help me write english as second language essays custom mba essay ghostwriter sites uk cheap scholarship essay editor website for college reflective essay writer sites gb esl dissertation writing site for masters best term paper proofreading website usa persuasive essay gay marriage custom masters home work samples buy accounting speech order economics blog professional best essay editor websites for mba custom definition essay ghostwriter services best definition essay writing for hire for masters content writers for hire online irony in my last duchess esl annotated bibliography editing website for university popular admission paper writers service us cheap scholarship essay editing for hire for masters type my women and gender studies dissertation methodology esl business plan editor for hire for university top book review writing for hire for masters professional blog writers sites for phd top admission paper editor websites gb cheap university essay writing sites buy earth science resume top papers writers websites for school professional creative essay writers service for school esl blog post editing websites custom curriculum vitae ghostwriter websites for phd cheap college essay writing website for school research proposal ghostwriter for hire us top college essay writers service for university cheap writers site online professional phd creative essay samples popular home work writer websites for mba esl curriculum vitae ghostwriter sites for masters best definition essay proofreading site iago essay best blog post ghostwriters services online admission essay writing site uk best literature review writer for hire uk best presentation writers websites for college best dissertation conclusion ghostwriting site for masters overview of the declaration of independence cheap book review editing site for university university essay ghostwriter website au esl case study editing service for university best rhetorical analysis essay ghostwriter for hire online esl literature review writer services online popular admission paper ghostwriter for hire au ww1 reasons for us involvement deaf again cliff notes buy engineering thesis yellow wallpaper characters top term paper writing site for college popular thesis proofreading services for mba cheap personal statement writers website for university esl thesis statement writing for hire for college best home work writers websites ca best phd essay ghostwriters for hire for phd best college essay writer website usa help with popular phd essay on lincoln help me write custom descriptive essay online best phd essay ghostwriting services top presentation writing sites usa help me write cheap personal essay on hacking best dissertation introduction ghostwriter services au university essay ghostwriting services critical proofreading for hire us industrial revolution literature popular dissertation conclusion proofreading for hire for university founding brothers summary professional descriptive essay ghostwriters service for university do my history course work popular university essay writer sites ca best curriculum vitae proofreading service online top curriculum vitae ghostwriters service for mba best thesis proposal ghostwriter site for mba best dissertation introduction ghostwriting site online best essay proofreading website for masters best dissertation results proofreading website for school cheap definition essay ghostwriters websites for mba cheap dissertation chapter ghostwriters for hire online professional mba blog popular report ghostwriting sites us esl content ghostwriters sites gb esl thesis editor sites for masters cheap critical essay editor sites usa best application letter writer websites for masters custom report writer for hire us order argumentative essay on shakespeare argumentative essay editing services gb esl essay proofreading sites for university custom university essay writers service usa write cheap presentation professional thesis proposal writers website for masters charlie marlow heart of darkness professional school essay ghostwriting for hire gb help with my world literature blog admission paper writers websites gb professional creative writing writing website for college popular article writing service au professional thesis proposal editor for hire usa pay to get reflective essay on brexit best mba best essay topics definition essay ghostwriting for hire professional curriculum vitae ghostwriter services top college speech example music writing websites best problem solving proofreading site esl dissertation abstract editing for hire for phd top masters essay ghostwriting websites esl papers editing sites for mba custom presentation writers websites gb dissertation introduction editor services ca professional report editor site for mba popular creative writing editor sites for mba topics about racism best personal statement ghostwriters service uk professional course work writer service for school help me write social studies letter dissertation hypothesis writer service usa esl dissertation introduction ghostwriter for hire for university write me popular descriptive essay on hillary clinton do my custom creative essay ugly ways cheap university essay writing site online summary of the birthmark help with ecology dissertation hypothesis pay to do cheap creative essay on pokemon go best research paper writing website ca popular application letter ghostwriting sites for masters custom persuasive essay ghostwriters sites us professional analysis essay editor site who is responsible for the death of romeo and juliet popular blog post ghostwriters services usa buy argumentative essay online popular masters curriculum vitae examples top resume ghostwriter services uk top annotated bibliography ghostwriting service online esl rhetorical analysis essay writers services for college should cellphones be allowed in school essay cheap academic essay ghostwriters for hire for school custom thesis proofreading services us rhetorical analysis essay writer site ca top personal statement writer services uk popular descriptive essay editor service for mba type my professional university essay on donald trump research paper writers site uk custom admission paper writing service for mba popular phd blog post help professional cover letter writing for hire for college cheap homework editor sites for mba expository essay writing website usa type my drama resume professional descriptive essay editing websites uk custom resume editor website for masters help writing esl persuasive essay on civil war college essay editor sites online order top masters essay on brexit popular cheap essay editor service esl university essay editing for hire for university custom dissertation conclusion writers services critical essay ghostwriter website online write my popular critical essay professional masters essay ghostwriting website for masters pay to get film studies research proposal popular dissertation methodology ghostwriters site for masters top blog post writing services for university professional report ghostwriter websites au esl university dissertation introduction sample best speech ghostwriter service for college top business plan ghostwriters site top thesis editor websites uk popular cheap essay ghostwriter sites ca cheap blog ghostwriter service online popular reflective essay editing sites au cheap personal statement editor service for university best analysis essay writing services online custom university custom essay samples write my masters essay on usa best custom essay editor sites for masters beowulf theme cheap school essay writers sites for mba best assignment editor services for college esl article review writing services usa top university dissertation methodology examples cheap blog post editor services for college professional admission essay editor site online esl college curriculum vitae popular assignment ghostwriters sites for university professional content ghostwriters service esl papers editor services for university top masters annotated bibliography esl school essay ghostwriting site for school esl dissertation conclusion ghostwriting service au cheap essays writer service us pay to write cheap critical essay on shakespeare professional ghostwriters sites for masters top business plan proofreading website for college business plan ghostwriters norma rea cheap dissertation conclusion ghostwriter site for university best dissertation chapter proofreading site for phd type my earth science letter top college cv help custom school admission essay example esl cheap essay editing services for college best analysis essay proofreading websites gb custom dissertation abstract writer services order human resource management research paper custom book review writer website for masters order world affairs content top assignment ghostwriting website for masters esl admission paper writers site uk top resume ghostwriter services us best thesis proofreading websites au top problem solving ghostwriters website gb popular blog post editor sites us esl research proposal ghostwriters website dissertation results ghostwriting services au sadie and maud poem popular home work writer for hire for masters literature review editing for hire au write me math article review esl scholarship essay editor services au popular annotated bibliography writers services for phd custom admission essay writers sites for school esl university scholarship essay advice custom presentation writing services for phd cheap blog ghostwriter services for masters help with history dissertation introduction help me write best college essay on shakespeare speech proofreading service ca custom personal essay ghostwriter service uk esl definition essay editor service for school cheap masters admission paper assistance cheap descriptive essay ghostwriting sites for school top analysis essay ghostwriters service uk best business plan writing service au esl academic essay writing service for mba popular rhetorical analysis essay editor for hire for mba pay to do professional school essay on lincoln professional phd essay writer services online setting of frankenstein write mathematics term paper popular annotated bibliography ghostwriters websites au cheap university term paper topic custom application letter writer services online cheap argumentative essay writers services write speech curriculum vitae professional essays ghostwriting website for college professional literature review writers websites popular papers writing site au custom blog ghostwriter services marketing essay ghostwriters service buy custom analysis essay online professional custom essay writers website professional application letter editor website for school top research proposal editor site for masters cheap argumentative essay ghostwriting websites for phd popular report editing websites usa argumentative essay writing website au buy marketing personal statement cheap personal essay ghostwriters websites usa professional masters essay ghostwriting website uk top application letter proofreading services online top dissertation hypothesis proofreading site for phd cheap research paper editing websites pay to write esl scholarship essay on founding fathers term paper writers site uk esl research paper editing site usa cheap dissertation methodology writer services ca top personal statement ghostwriting services ca simon death lord of the flies popular phd essay on brexit custom masters term paper advice top literature review writer websites us esl paper editing site for college cheap essays writing site for mba best definition essay ghostwriters services for mba esl university critical thinking example research paper writers services dissertation conclusion writer site ca esl descriptive essay proofreading websites gb cheap home work ghostwriter service ca assignment writing site online cheap admission essay ghostwriting websites ca cheap rhetorical analysis essay writing sites for mba best reflective essay ghostwriting services for college professional critical analysis essay writers service ca popular research paper writer service uk top definition essay proofreading websites for masters top masters essay on hacking cheap admission paper ghostwriter services for university popular university essay editor website us write my psychology report professional phd essay editor websites online custom problem solving ghostwriters site au type my best admission essay on hillary help with economics article review type my human resource management cv top research proposal writer for hire ca buy professional home work online esl annotated bibliography editing website utopian society essay type my popular scholarship essay on hacking best dissertation hypothesis editor websites usa write me custom personal essay best dissertation introduction editor for hire au scholarship essay editing service uk best paper editing websites us top article review editor services for masters custom business plan ghostwriter service for mba custom papers ghostwriting sites help me write professional rhetorical analysis essay on brexit top literature review writers service for mba esl argumentative essay proofreading websites online popular reflective essay ghostwriting for hire for university esl research paper ghostwriter site uk write me top persuasive essay on pokemon go buy remedial math admission essay custom resume editing for hire for college best college essay ghostwriting site au custom personal statement proofreading service uk scholarship ghostwriting service usa professional phd business plan topic top literature review writers services online popular phd essay ghostwriting website for college article of confederation vs constitution custom dissertation chapter editing site gb custom personal statement editor services for mba do my top creative essay on hillary professional persuasive essay proofreading website for school custom thesis proposal ghostwriter site for university professional cover letter writers website au help with my popular personal essay on founding fathers cheap bibliography ghostwriter services usa pay to do professional best essay esl phd research proposal assistance cheap dissertation methodology writing for hire au help writing best argumentative essay on trump help with my government creative writing esl paper editing websites for masters esl curriculum vitae ghostwriters website for college book review ghostwriting services gb help me write world affairs blog post pay to get personal essay on presidential elections cheap mba blog advice top dissertation proposal editing services usa professional ghostwriters sites for school esl admission essay writing services for school pay to write custom school essay on donald trump esl dissertation results editing for hire au popular personal statement editor service for school custom homework writing sites usa top cheap essay writers sites for school do my leadership dissertation proposal esl personal statement writing sites for university best mba custom essay samples biological functions of water cheap paper writing sites ca best thesis proposal writing website us do my cheap course work popular papers writers service for college cheap expository essay writing services for mba top presentation writer service for college esl scholarship essay writing for hire usa custom essays writing sites gb popular dissertation conclusion writers websites ca top critical analysis essay proofreading sites for school professional dissertation abstract ghostwriters websites online esl course work proofreading service for phd popular analysis essay writer website uk cheap cover letter ghostwriting site for phd esl content writers websites for masters popular essays editor for hire uk top custom essay editor service for school custom scholarship essay editor websites for masters academic essay editing service ca astronomy ghostwriters for hire best dissertation introduction writer website for phd pay to get theater studies critical thinking best dissertation abstract writing websites for phd help writing earth science literature review custom writers site us top dissertation conclusion editing services usa essays about christmas top critical analysis essay writing website ca best critical essay editor for hire gb write my top rhetorical analysis essay on hillary professional dissertation methodology writer for hire gb esl creative writing proofreading site for masters custom university dissertation conclusion examples top blog post editor site gb custom cheap essay writers websites for university custom papers writers sites for mba popular research proposal editing websites for university order popular admission essay on pokemon go report ghostwriter for hire ca top masters essay ghostwriting service gb order best phd essay on donald trump help writing technology cv buy cheap academic essay on donald trump professional dissertation hypothesis writer website us who is to blame in romeo and juliet cheap creative essay editor site ca cover letter writing website usa write technology report write me cheap dissertation abstract popular college essay writer websites for phd custom reflective essay editing service ca pay to do professional reflective essay on lincoln custom bibliography ghostwriters site top university essay writing services au esl paper editing services for school literature review writing website usa turbo and nitrous cheap academic essay writing for hire for university custom essay writers websites au professional best essay editing sites for university professional resume writing site for school cheap scholarship essay writers sites for masters popular blog editing site for university buy custom phd essay on hillary clinton pay for popular business plan online write my thesis pay for ancient civilizations resume popular thesis statement ghostwriters website for college type my geology case study school ghostwriter sites au cheap essay on history best university scholarship essay topic best article review editing websites best research paper writer sites for phd custom annotated bibliography ghostwriters for hire for college best homework writing site for university top critical thinking ghostwriters website for college esl movie review editing services for mba cheap mba dissertation proposal topics professional creative writing editor site online pay to do culture literature review esl cover letter writing for hire for college pay to get classic english literature curriculum vitae top mba essay writers service gb criminal law ghostwriting websites top term paper ghostwriter website au professional university masters essay help type my science essay best book review writing for hire gb curriculum vitae proofreading sites