Jump to content

  • Log In with Google      Sign In   
  • Create Account

Squared'D's Journal

What's up with Me and the Micro 3D

Posted by , 21 May 2014 - - - - - - · 961 views
micro 3d, 3d printer, m3d
I've been away for some time now. A lot has changed since my last update. As I've said before, I used to teach English in Korea, but in April, my wife and I moved back to America. Now I've been trying to get back into the swing of things. I want to spend more time coding my game, and for a month, I did that, but since I need money for things like food and a place to live, I decided to get a job. Before I came back to America, I started doing some heavy networking and a 3D artist and designer that I've work with put my name into at this company M3D LLC which makes 3D printers. I've been working there for about 2 and a half weeks so far and like the startup environment. Everyone is very motivated and wants to put together a good product, but some the atmosphere is very relaxed. I guess that's what happens when you like what your doing. We joke around, talk, and do startup things like have barbecues. It's fun. It sometimes feels like a University of Maryland alumni meeting because almost everyone either graduated from UMCP (University of Maryland College Park) or is currently attending. I graduated from there in 2003. There's also an engineer who went to Yale. Yeah. He's pretty smart.
In my spare time, I still do Squared Programming stuff and continue to work on Auxnet. I've gotten a lot of work done on my AI system. For now I've decided to use a finite state machine as a low level framework of the AI system. I want to use the FSM system to develop more complex behavioral systems like planners, hierarchical FSMs, and behavior trees. The initial FSM system is done. Next I want to work on a navigation system that can be expanded to work with different algorithms and different kinds of maps. Then I'll add an extension to the system to allow state logic to be written in AngelScript. Once these things are done, I'll have a solid base. After that, I'll move onto other parts of the game like the animation and weapons systems. Once those are out of the way, I'll revisit the AI system.


AI System Progress with Video

Posted by , 24 April 2014 - - - - - - · 967 views
ai, middleware


These days, I've been making a lot of progress on my AI engine. The basic framework is running now and you can see that in this video. The AI system is telling the little bot where to go. I'm still in the early stages of development so the path is still hard coded into the demo but I'm happy that I'm now at a place where I can concentrate on actual AI code more.

My goal going into to this was to build an AI system that would be useful for different types of games. As you can see in the video, the AI system is working on a simple 2D game. I also have a text based sample project and the main game that I am building this for will be a 3D multiplayer game. Internally, how does this all work? Games are so different that it's not easy to make a unified AI system so my goal was merely to provide the parts needed for AI that could be used in various game types and still allow the developer to build the AI by adding code directly to the system using C++ or by using scripting languages such as AngelScript or Lua. The AI system works like this:

Retrieve inputs from the game engine
- Entity health and location information
Process the current AI states
Send simple tasks to the game engine for each AI agent

The tasks that the AI system sends to the game engine should be very easy to complete. For example, if the AI system sends a "goto" command, the engine should be able to move to that location without worrying about obstacles. To navigate around obstacles, the AI system will send a series of "goto" commands marking points along the path.

Next Steps:
Currently everything is hard coded, but I want to provide a C++ interface so the AI programmer will be able to code custom behaviors. Then I want to expand that to include use a scripting language. After that, I'll start working on the navigation system. I'll continue to post information on my blog. For more videos, you can check out my YouTube channel. You can also visit ai.squaredprogramming.com.

http://ai.squaredprogramming.com/2014/04/ai-system-progress-with-video.html


Auxnet: Battlegrounds Progress

Posted by , in Auxnet 07 April 2014 - - - - - - · 897 views
game programming
I've been making a lot of progress these days. I've just finished most of a major renovation (hopefully the last until release) of the graphics engine. Before I had limited each model to one set of textures (diffuse, normal, effects map), but by artist request, I've added the ability to use a second set for added customizability(not a real word, but should be). I've also added the ability to change the colors of models in the engine. This will allow characters to be able to choose there colors. This isn't new earth-shattering technology, but it's a big deal for me.

I'll be moving back to the US tomorrow. Hopefully I'll be able to force my way back into the job market. I guess if things don't work out, I can always move back to Korea, but I'm going to try my hardest at becoming a successful indie developer.

Posted Image


Developing the AI Middleware's Interface

Posted by , in AI 28 March 2014 - - - - - - · 1,130 views
ai, ai engine, ai middleware
Developing the AI Middleware's Interface

As I explained in my last post, I've developed a text-based sample game that I'll use to build the initial version of the AI system. Then I'll get it to work on my 2D engine, and then finally on my 3D engine for Auxnet:Battlegrounds. I'm at the stage now where I need to develop the AI systems public interface.

The AI system is still very early in its development so things will probably change, but this is how I invision using the code in a real application.

// Startup
RootAI::Engine *ai_engine = RootAI::CreateAIEngine();

RootAI::WorldDesc worlddesc;
...
RootAI::World *world = ai_engine->CreateWorld(worlddesc);

RootAI::AgentDesc aidesc;
...
RootAI::Agent *agent = world->CreateAgent(aidesc);

...

// Shutdown
world->DestroyAgent(agent);
ai_engine->DestroyWorld(world);
RootAI::DestroyEngine(ai_engine);


I haven't decided if I want to force the developer to have to explicitly destroy the agents and the world or allow just destroying the engine and have that take care of cleaning up everything. My current thoughts are to let the engine take care of cleaning things up and returning a message if there are any AI objects that weren't properly destroyed before the engine.

Here's the preliminary code for the AI agents and their tasks. The task should be basic enough so that the AI system can tell the game engine what in a way that will be easy to implement.

struct AIAgentDesc
{
    // the initial position and orientation of the entity
    Pose initial_pose;

    // set to true if the agent can move on more than one
    // axis at a time
    bool diagonal_movement;
};

enum AITaskType
{
    TaskIdle, // The AI should wait in an idle state
    TaskGoto, // The AI should go to a point (path will be unblocked)
    TaskAttack, // The an attack
    TaskTurnTo  // turn to face a direction
};

struct AITask
{
    AITaskType type;
    union
    {
        struct
        {
            int animation_num;
        } IdleTaskOptions;

        struct
        {
            Vector location;
        } GotoTaskOptions;

        struct
        {
            int attack_number;
            Vector direction;
        } AttackTaskOptions;

        struct
        {
            Vector direction;
        } TurnToTaskOptions;
    };
};

class Agent
{
    public:
        virtual ~Agent() {}
        virtual void SetAgentPose(Pose pose) = 0;
        virtual void GetCurrentAITask(AITask &out) const = 0;
        virtual void SetTaskDone() = 0;
};
The task currently just use unions. The reason why I decided to do it this way instead of using inheritance was I want to be able to easily copy data back and forth between the AI system and the game engine without creating new objects task objects and I can process the task without casting.

Another design choice that I've made is completely separating the public interface from the implementation. That's why the agent class is an abstract base class. The same will be true of the world and engine classes.

Let me know if you have any questions or suggestions.


AI video for beginners and young programmers

Squared Game Engine Modular Architecture

Fun Indie Games In Development YouTube Playlist

http://ai.squaredprogramming.com/2014/03/developing-ai-middlewares-interface.html


AI System Progress and Auxnet development

Posted by , in Auxnet, AI 27 March 2014 - - - - - - · 1,042 views
ai, auxnet
AI - Progress
Things have been going well on the AI front. I'm still hoping to have a strong enough foundation in a few weeks to be able to put my source code up on GitHub. It'll still be very early in the process, but I think I should have more than just a skeleton before I allow others to see the code.

I've been looking at various middleware SDKs, namely RakNet, NVidia PhysX, and AngelScript, just to get a feel of what makes a good SDK. I've decided for now to go the RakNet and AngelScript route and have all of my samples be console applications and not graphics applications. I still will make a 2D version of the sample, but it won't be an official part of the Root AI SDK.

Here's a screenshot of the console based example game. The AI system isn't being used yet so the AI bot just uses simple code to move left. Soon it will still just move left, but it'll be the AI engine telling it to do so.


Posted Image

Auxnet: Battlegrounds - Update
As for the game Auxnet: Battlegrounds, I just received the base animations from our 3D modeller so now I have the needed test data to start working on enhancing the animation system. I want to get a video of the new animation up soon.


articles.squaredprogramming.com
ai.squaredprogramming.com


Building My AI Engine

Posted by , 20 March 2014 - - - - - - · 995 views
ai, ai engine, middleware, c++ and 3 more...
These days, I've been turning my attention towards AI. In the past, I spent so much time working on graphics components of the engine in the past, that I've never put the effort into building a good AI system. When I was developing Genesis SEED, I wrote a complex AI system, but it was too unwieldy and complicated so I decided to start from scratch when working on the AI system that would go into Auxnet. It’s still in its beginning stages but in the long term, I’d like to release the AI system as an open source project. I want to build a general AI framework that will work on many different game types.

How and why do I want to make a general AI framework? I want to build this game engine in a modular way to allow for future expansion. To achieve this modular approach, the code will naturally take a framework with attached plug-ins design. I know that AI is very game specific, but what I want to do is provide a collection of techniques that the AI agents can have to complete their task. After that, the main architectural design issues will come down to how to separation of responsibilities between the AI engine and the game engine. I'm not an AI expert, but I have experience in designing architectures and feel that I'll be able to put together a good system.

The AI system will have three main parts, the engine, worlds, and agents. The engine holds the worlds and is responsible for initialization and the destruction the system. Multithreading support will also be handled in the engine. Worlds contain agents and also the navigation system and world geometry. Keeping separate worlds will an application to use one AI engine to process the AI for agents in unrelated and unconnected areas. Agents are the actual AI entities and are connected to an entity in the game engine. There is no direct link between game engine entities and AI system agents in code so the agents will need to store copies of some of the the game engine entity's data such as position and health information. I've given a very simple UML diagram below with some of my current thoughts. This will grow by leaps and bounds by the time end of the project.

Posted Image
I want to model my AI system like other middleware SDKs. I've used many different kinds of middleware including, graphics APIs, physics SDKs, networking engines, and scripting languages. Of all of the different middleware libraries that I've used, which system is most like the AI engine that I want to build? Believe it or not, this system will be most similar to a physics engine. Think about it, in a physics engine, first, you should set up the world or scene, then add actors and physics bodies. After that you run the simulation, checking to see the new position and orientation of your actors and then updating them in the engine. An AI engine in many ways is quite similar. First you have to setup the world and tell the AI engine how the level is laid out and what potential colliders and dangers are in the world. Then you should create AI agents that are connected to game entities to populate the world. The AI engine will run the simulation, and then the entities in the game engine should check their AI components to see what state changes have been made. That's the entire system in a nutshell.
Posted Image
For this to work, I'll need a very simple interface. The AI engine will be responsible for all decisions. It will tell the game entity to do simple task like move forward, turn, or shoot, and then game engine should do task and tell that AI engine when it has completed the task. The task that the AI engine will relay to the game engine should be simple enough to not need any complex intermediary AI. For example, if the AI engine returns a "go to" command, the entity should be able to go to that point by walking in a straight line and without worrying about path finding. For complex paths, the AI engine should give a series of “go to” commands until that agent has reached its destination. In this way, the AI engine will be the brains and the game engine will act like the nervous system and make the agent's body move. So the game engine to receive instructions from the AI engine, and for the AI engine to receive position information and whether or not the instruction has been completed. This information will not need to be sent back and forth every frame, but either as needed or at set regular intervals as decided by the developer. Game engines that used a component-based entity system can add an AI component to process instructions from the AI engine and to pass on the entity's location information to the AI engine. The game engine should also be able to send events to the AI engine that are not directly tied to a specific entity such as level events, so the AI agents will be able to respond to those events as well.

There's no way I'll be able to program all types of AI algorithms so the AI engine will need to not only be flexible but expandable. I'll have to build it so it can take add-ons written in either C++ or in scripting languages such as AngelScript and Lua. The add-on system should not be limited to giving support for different types of levels and path finding. There should be a way to make add-ons that will affect how decisions are made so there should be add-ons for using Ad-hoc rules, finite state machines, behavior trees, neural networks, and so on. Once a large library of add-ons has been created, building complex AIs will be a matter of choosing the proper base AI architecture (Ad-hoc rules, finite state machines, etc), adding skills, and performing some game specific tweaking. These are my AI goals.

To help me build all of this, I've created a small 2D game with a little robot that should navigate through a simple maze. I'll develop this demo more and more and post updates on my blog and on YouTube.

Posted Image


This has been reposted from http://journal.squaredprogramming.com/2014/03/building-ai-engine.html


Starting to work on AI now

Posted by , 15 March 2014 - - - - - - · 1,534 views
beginner ai
Auxnet development has been picking up these days. Right now my main task is AI. AI has been a pain in my side for some time now not because I don't know how to do it, but because I haven't really had a lot of time to work on it. So I've been stuck in stupid AI land. I'm going to change that now. I'm determined to make AI agents that don't repeatedly bump into walls. I've been putting together a nice little AI framework. If all goes well, I'll try to give regular updates on my progress and even some code. I did some research on many AI topics and made this little video as a little summary.



It took a long time to make this and it's either programmer art at its finest or at its worst. Who would have thought making bad animations would be so complicated? I hope the animation is entertaining and informative--well as entertaining as AI can be. The order of the topics is from an article that IADave wrote but all of the explanation is from my own head. I give brief info on using simple rules, finite state machines, behavior trees, planners, and neural networks. I some had serious flashbacks from my college AI class. Sadly that was the most boring class I took during that four and a half year period.

For a more complete synopsis of what I plan to build, you can check out journal.squaredprogramming.com .


Experimenting with Engine Design

Posted by , 02 March 2014 - - - - - - · 842 views
c++, game engine and 1 more...
Graphics-wise, I don't plan on changing my current 3D engine much. I've mostly been working on gameplay and AI related stuff. As I make more progress on the AI code, I'll share it here and on my main page. Currently the 3D engine, Squared'D, has too many parts to use it as a simple testing platform so I stripped out it's core 2D elements (these were mainly used for the GUI) and built it into a smaller game engine that doesn't require much set up. I'm using the 2D engine for experimentation with new concepts.

I've been trying to leverage more C++ features to make development easier. One big design decision was to limit the use of pointers and to use handles and C++ references as much as possible. I want to avoid using shared pointers and limit my code to only a few unique pointers when absolutely necessary. So far so good. I've gotten a component-based entity system working already. Entities only store handles to there components, and all components are stored in an std::vector inside their respective system classes. As I've been playing around with the system though, I think in the future, entities will not even need handles to their components. Entities will eventually just morph into position orientation with the components knowing which entity they belong to, but not the other way around. If it goes well, I'll incorporate these ideas into the next version of the 3D engine. Hopefully I'll be able to simplify things enough so that the next 3D engine will be good for testing and able to run on the PC and Android, but all this will happen after 6 months or so.

If you'd like some more details about the 3D engine's modular design, you can check out the video below. Let me know if you have any questions. Even critiques are welcome.





The Latest

Posted by , 13 February 2014 - - - - - - · 788 views
indies
I've been living in Korea for the past 6 1/2 years, but my wife and I have decided to give the US a try and we'll move back there this spring. So I'm now in job hunting mode. I've also been taking some time to develop my personal website www.squaredprogramming.com . I've been posting a lot of things there. I've added the articles that I've published here on Gamedev.net as well as some new ones. On my journal page, I've posted the article, "Indies--Stop Treating Your Ideas Like Classified Secrets" (http://journal.squaredprogramming.com/2014/02/secrets.html) which goes over why I think indies should be open about sharing there ideas.

I've been studying a lot, trying to prepare myself to reenter the US work force. I'll move back to Maryland at least in the beginning. I'll see how it goes.

If you have time, check out my new site. Good suggestions and comments are always appreciated.

www.squaredprogramming.com


Fun with Modern C++ and Smart Pointers

Posted by , 13 February 2014 - - - - - - · 6,772 views
modern c++, smart pointers and 3 more...
This has been re-posted to http://articles.squaredprogramming.com/2014/02/smartpointers.html

_________________

This is a journal entry not an article so I feel like I can ramble a bit before I get to the main point. I have been programming for some time now and got my CS degree way back in 2003, but in 2007, I decided to take a break from programming, moved to South Korea, and have been an English teach ever since. I started to program again and with the help of an artist friend of mine, made this for last year's IGF. We obviously didn't win and haven't decided whether or not to continue with the project.

Anyway, because of my long hiatus from programming, quite a few things have passed me by, namely modern C++ and all of this smart pointer stuff. I've decided to start writing code not just for myself, but code that others could use so I want to update my knowledge of C++ and explore smart pointers. In this journal entry I want to share what I've learned. I don't claim to be an expert, so if you have any useful insights or corrections, I'd appreciate a "friendly" comment.


Raw Pointer Primer
There are two basic ways to create a variable in C++: stack variables and heap allocations. Stack variables are defined inside a certain scope and as long as you're in that scope, the variable will exist. Heap allocations (dynamically allocated memory), variables typically declared with new or malloc, aren't not defined within a scope and will exist until the memory is freed.

Here's an example:
void foo()
{
    // Object A of class CSomeClass has been declared inside the scope of foo
    CSomeClass A;

    // do some stuff
    ....

    // you can even call other functions and use A as a parameter
    Func1(A); // This could be pass by value or pass by reference depending on Func1's declaration

    Func2(&A); // Passes a pointer to A

    // at the end of this  function, the scope will end and A will automatically be destroyed
}
Now with this function, every time another function calls foo, A will be created and then destroyed when the function exits. Not bad right. What about this?
void foo()
{
    // Object A of class CSomeClass has been declared inside the scope of foo
    CSomeClass *A = new CSomeClass; 

    // do some stuff
    ....

    // you can even call other functions and use A as a parameter
    Func1(*A); // This could be pass by value or pass by reference depending on Func1's declaration

    Func2(A); // Passes pointer A of CSomeClass (Edited)

    // MEMORY LEAK
    // at the end of this  function, the scope will end, but A was created on the heap
    // delete should be called here
}
So with dynamic memory allocations, you must free the memory. So why you might ask do we even need dynamic memory allocations? Well one, to declare variables on the stack, you need to know exactly what you'll need at compile time. If you want to be able to create arrays of various sizes depending on user input, or if you're making a game and want to load variable amount of resources, you'll need to use dynamic memory allocations. Take this example:
int num_students;

// First get the number of students in the class
std::cout << "How many students are in the class?"
std::cin >> num_students;

// Create a dynamic students array
CStudent *student_array = new CStudent[num_students];

// Do some stuff with the data
....

// call the array version of delete to free memory
delete [] student_array;
In the previous situation, you must use dynamic memory because the size of the array is determined by the user. How can smart pointers help?

Smart Pointers
(chief reference: Smart Pointers (Modern C++) on MSDN)

Smart pointers allow you to create dynamic memory allocations but defined them inside a scope or an owner. This way, when the owner goes out of focus, the data will be automatically deleted. Smart pointers have been implemented using templates and to use them, you must include the header <memory>. Smart pointers are in the std namespace. I will only discuss unique_ptr's here. Later, I may talk about the other types of smart pointers in between updates to "A Complete Graphicsless Game"

So how do you create a unique_ptr?
std::unique_ptr<Base> apples(new Base(L"apples")); // Where Base is the class type
You create a unique_ptr like a typical template and then pass the raw pointer to initialize the variable. After that, you can use the unique_ptr, just as you would any other pointer.
class Base
{
    public:
        Base(const std::wstring &string)
        :m_string(string)
        {
        }

        virtual void Display() const
        {
            std::wcout << L"Base:" << m_string << std::endl;
        }

    private:
        std::wstring	m_string;
};

int main()
{
    // declare some unique_ptrs. This pointers can have only one owner and cannot be copied. Only moved.
    std::unique_ptr<Base> apples(new Base(L"apples"));

    apples->Display();
}
unique_ptr's can also be passed to other functions, but you must pass by reference. Passing by value will result in a compiler error. With unique_ptr's, only one can own the pointer, but if you pass by value you will make a copy of the unique_ptr which in essence makes two unique_ptr's that own the same block of memory.

You can also use unique_ptr's with derived class and virtual functions and get the typical C++ behavior.
class Base
{
    public:
        Base(const std::wstring &string)
        :m_string(string)
        {
        }

        virtual void Display() const
        {
            std::wcout << L"Base:" << m_string << std::endl;
        }

    private:
        std::wstring	m_string;
};

class Derived : public Base
{
    public:
        Derived(const std::wstring &string)
        :Base(string)
        {
        }

        virtual void Display() const
        {
            std::wcout << L"Derived:::";
            __super::Display(); // __super is MS specific. Others should use Base::Display();
        }
};

int main()
{
    // declare some unique_ptrs. This pointers can have only one owner and cannot be copied. Only moved.
    std::unique_ptr<Base> apples(new Base(L"apples"));
    std::unique_ptr<Base> oranges(new Derived(L"oranges"));

    apples->Display();
    oranges->Display();
}
This is very useful when dealing with vectors as the next example show.
std::vector <std::unique_ptr<Base>> test_vector;

test_vector.push_back(std::unique_ptr<Base>(new Base(L"apples")));
test_vector.push_back(std::unique_ptr<Base>(new Derived(L"oranges")));
In the above example, you can use the vector of unique_ptr's in the same way you would if it was a vector of raw Base pointers, but there is one nice benefit. If this vector had raw pointers, you'd have to make sure you manual free the pointers before you clear the vector or erase an element, but with unique_ptr's, all of that is handled for you.

Conclusion
I hope this information was helpful. I am in no way an expert so if you anyone sees something glaring that I missed, feel free to leave a "kind" comment. If you would like to know more about smart pointers, I suggest checking out the like on msdn.






Recent Comments

December 2016 »

S M T W T F S
    123
456 7 8910
11121314151617
18192021222324
25262728293031