GDR Forum Index
Podcast Podcast
Dev Dev Logs
Search Search
RSS RSS
Register Register
Log in Log in
Reply to topic GDR Forum Index -> Game Developer's Refuge -> Development Log - Rogue-Opcode game framework Page Previous  1, 2
View previous topic :: View next topic  
Author Message
Madgarden
Contributor

Joined: 31 Aug 2005
Posts: 324
Location: Kitchener, ON, CA
PostPosted: Mon Jul 06, 2009 9:22 am    Post subject: Reply with quote

Sure, there's this (esp. stb.h): http://www.nothings.org/
And also this: http://www.willnaylor.com/wnlib.html
_________________
I know it sounds crazy, but it JUST MIGHT WORK
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Gil
Developer

Joined: 14 Nov 2005
Posts: 2341
Location: Belgium
PostPosted: Mon Jul 06, 2009 9:36 am    Post subject: Reply with quote

I really really REALLY hate STL. Welcome to the club?
_________________
PoV: I had to wear pants today. Fo shame!
View user's profile Send private message Visit poster's website
xearthianx
Developer

Joined: 28 Sep 2006
Posts: 771
Location: USA! USA!
PostPosted: Tue Jul 07, 2009 12:55 am    Post subject: Reply with quote

Madgarden wrote:
Sure, there's this (esp. stb.h): http://www.nothings.org/
And also this: http://www.willnaylor.com/wnlib.html

Have you actually used these, or did Professor Google just find them for you?
_________________
Ionoclast Laboratories - Scientia et Dominatia!
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Hard Rock
Contributor

Joined: 31 Aug 2005
Posts: 238

PostPosted: Tue Jul 07, 2009 7:35 am    Post subject: Reply with quote

Both Ogre and Irrlicht have their own container classes. Although Ogre is LGPL, Irrlicht is zlib so you can just rip out the code no problem.

Although to be honest, I don't know if it'll fix the problems.
_________________
Hard Rock
[The Stars Dev Company][Twitter]
View user's profile Send private message Visit poster's website
xearthianx
Developer

Joined: 28 Sep 2006
Posts: 771
Location: USA! USA!
PostPosted: Tue Jul 07, 2009 9:46 am    Post subject: Reply with quote

I dunno, there's something wonky going on with STL for me. For instance, I use strings to define matching patterns to map action rules to input states. I use a genetic algo to evolve new pattern:action pairs. The debug build throws std::length_error exceptions during this process.
The Horse's Mouth wrote:
Detailed Description
Thrown when an object is constructed that would exceed its maximum permitted size (e.g., a basic_string instance).

I looked at what it's doing, and at some point in the inheritance chain safe_iterator or safe_container or whatever was freaks out. The string in question was 7 chars. 7. I'm pretty sure the maximum permitted size of a string it substantially larger than 7. So I just caught the exception, printed an event message, and kept going. Guess what? It works perfectly.

This sorta shenanigans plus weird things like objects throwing exceptions from their destructors (how can a bitset cause an access violation ferfucksakes!?) have lead me to believe that perhaps a minimal kinda solution would give me less trouble. I've seriously never had this kinda trouble with STL before, which is why it was my goto guy for all my basic datastructure needs. And it seems like a lot of my issues are relaetd to the safe_xxx classes that the debug versions inherit from, but that's still not cool... I have a couple ideas of what I might do now, so that's looking up at least.
_________________
Ionoclast Laboratories - Scientia et Dominatia!
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
xearthianx
Developer

Joined: 28 Sep 2006
Posts: 771
Location: USA! USA!
PostPosted: Fri Jul 10, 2009 2:19 am    Post subject: Reply with quote

So I started whipping up my own STL replacements. I've got a container base class, a dynamic array and a double-ended circular queue with some pretty nice but minimalist features, all in under 250 lines of code. Compare to GNU's STL @ ~3000 lines of code for the same functionality. I am pleased with this result.

I haven't thoroughly tested everything, but initial results are good
Test Run wrote:
[Session started at 2009-07-10 00:23:53 -0700.]

Array:
------
container size: 4, capacity: 4
container contents: 1 2 3 4
container size: 5, capacity: 8
container contents: 1 2 3 4 5
container size: 9, capacity: 16
container contents: 1 2 3 4 5 0 0 0 0

Deq:
----
container size: 4, capacity: 4
container contents: 1 2 3 4
container size: 5, capacity: 8
container contents: 1 2 3 4 5
container size: 6, capacity: 8
container contents: 6 1 2 3 4 5
container size: 7, capacity: 8
container contents: 7 6 1 2 3 4 5
container size: 7, capacity: 16
container contents: 7 6 1 2 3 4 5
container size: 16, capacity: 16
container contents: 7 6 1 2 3 4 5 0 0 0 0 0 0 0 0 0
Popping back: 0
Popping front: 7
container size: 14, capacity: 16
container contents: 6 1 2 3 4 5 0 0 0 0 0 0 0 0

The Debugger has exited with status 0.

Coming up next, an associative array (either a hash or a sorted map of some sort). I could go with a sorted binary tree for speedy index lookups. Hashing would give constant time lookups, but it can take a lot of memory to build a decent hashtable, and you have to make sure the keys play nice with your hashing function... I may dabble with both, and see which looks like it'll be harder to do. Or maybe actually fully implement both, so I'll have the option to pick the tradeoff between memory overhead and access speed...

After that, a "bit array" to replace STL's bitset. I think implementing this one will be pretty straightforward, if a little tedious. Mostly just some basic functionality to make accessing specific bits easier. Maybe give access to ranges of bits... We'll see. The main guiding principal will be simplicity and ease of use over breadth of features and sheer power. I always hated how STL will let you do fancy things with sequences, but you have to juggle 3 or 4 iterators to make it happen. Funk dat.
_________________
Ionoclast Laboratories - Scientia et Dominatia!
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Gil
Developer

Joined: 14 Nov 2005
Posts: 2341
Location: Belgium
PostPosted: Fri Jul 10, 2009 9:02 am    Post subject: Reply with quote

You need finger trees. It's the trendy thing to do...
_________________
PoV: I had to wear pants today. Fo shame!
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Fri Jul 10, 2009 9:54 am    Post subject: Reply with quote

Not to sound like a dbag, but wouldn't such probelms with STL likely indicate there is some issue with the structure of your classes and how you are using it? I would try to determine what the root cause is because that could be something that could help out your overall structure. Granted, I'm not saying there are no bugs in STL, but it's more likely you've just done something it doesn't like and it has no good way of explaining what is *really* wrong.

Sorry, I'm just not a fan of reinventing the wheel, and in my experience this kind of thing is usually *Me* being a bad developer in one way or another.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
xearthianx
Developer

Joined: 28 Sep 2006
Posts: 771
Location: USA! USA!
PostPosted: Fri Jul 10, 2009 11:07 am    Post subject: Reply with quote

Ya know, I thought about that. I didn't lightly jump into doing this. But what it comes down to is that I don't understand the internal workings of how the STL classes are implemented well enough to really know what the problem actually is. <stl_vector.h> alone is over 1000 lines, not including the base classes and macros and routines and other data types it references in the 15 or 20 headers it includes.

And then I'd get weird issues that just didn't make any sense at all, like bitset throwing exceptions from its destructor. I figured out it was some "safe_sequence" issue the debug version derives from. When I switched to release builds, no errors, no bugs, no crashes...

Additional benefits to this over STL are that my stuff should be faster and lighter. And in the end, if it turns out that the flaw is in my logic or general architecture, by using such small, simple data structures that I am intimately familiar with, I should be able to more easily figure out what the problem really is.

(And yes, I'm sticking with that split infinitive.)
_________________
Ionoclast Laboratories - Scientia et Dominatia!
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
PoV
Moderator

Joined: 21 Aug 2005
Posts: 10892
Location: Canadia
PostPosted: Fri Jul 10, 2009 11:24 am    Post subject: Reply with quote

STL is just a lot of compile time fat. Using the vector actually results in simple pointer de-references and stuff, as you'd expect. It's just done in a really complicated not self sufficient way.
_________________
Mike Kasprzak
'eh whatever. I used to make AAA and Indie games | Ludum Dare | Blog | Tweetar
View user's profile Send private message
xearthianx
Developer

Joined: 28 Sep 2006
Posts: 771
Location: USA! USA!
PostPosted: Sat Jul 11, 2009 1:18 am    Post subject: Reply with quote

Yeah, it's that "complicated and not self sufficient" part that was giving me trouble. Heh. Aside from faster compiles, the main advantage of a simpler data structure set is that I can actually figure out what's going on and fix problems.

PS
Iterators: fuck you. You know what you did.
_________________
Ionoclast Laboratories - Scientia et Dominatia!
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
xearthianx
Developer

Joined: 28 Sep 2006
Posts: 771
Location: USA! USA!
PostPosted: Thu Jul 16, 2009 4:30 pm    Post subject: Reply with quote

Two things to say at the moment, really:

1) I'm finding coding trees to be very tedious. This is a little surprising to me, because trees are the most interesting of the simple data structures, to me. I think a lot of this is because I spent a long time making some pretty fundamental design decisions, and now I just want it to be over with. I'm pretty happy with what I've decided on, with a good compromise between simplicity and efficiency.

2) I should have known better than to start watching a new series in the middle of a project. I'm now starting on season 2 of Battlestar Galactica, and I can feel my will to be productive waning... Heh. I find, "You can't watch an episode until you get XYZ done," to be an effective motivator, but it's pretty easy to spend more time enjoying your bribes than you did earning them.
_________________
Ionoclast Laboratories - Scientia et Dominatia!
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
xearthianx
Developer

Joined: 28 Sep 2006
Posts: 771
Location: USA! USA!
PostPosted: Thu Jul 16, 2009 6:35 pm    Post subject: Reply with quote

Code:
    // Creates the following initial tree
    //     5
    //   3   7
    //  2 4 6 8
    BinTree<int> tree;
    tree.Insert(5);
    tree.Insert(3);
    tree.Insert(7);
    tree.Insert(2);
    tree.Insert(4);
    tree.Insert(6);
    tree.Insert(8);

    // yank the root node
    tree.Remove(5);

    cout << "Tree size is " << tree.Size() << endl;
    for(int i = 0; i < 15; i++)
    {
        if(tree.Search(i))
            cout << "Found " << i << endl;
        else
            cout << "No "<< i << " in tree" << endl;
    }
    cout << "root is " << tree.Root()->data << endl;
    cout << "root's right child is " << tree.Root()->right->data << endl;


stdout wrote:
Tree size is 6
No 0 in tree
No 1 in tree
Found 2
Found 3
Found 4
No 5 in tree
Found 6
Found 7
Found 8
No 9 in tree
No 10 in tree
No 11 in tree
No 12 in tree
No 13 in tree
No 14 in tree
root is 6
root's right child is 7

_________________
Ionoclast Laboratories - Scientia et Dominatia!
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
PoV
Moderator

Joined: 21 Aug 2005
Posts: 10892
Location: Canadia
PostPosted: Thu Jul 16, 2009 7:55 pm    Post subject: Reply with quote

xearthianx wrote:
2) I should have known better than to start watching a new series in the middle of a project. I'm now starting on season 2 of Battlestar Galactica, and I can feel my will to be productive waning... Heh. I find, "You can't watch an episode until you get XYZ done," to be an effective motivator, but it's pretty easy to spend more time enjoying your bribes than you did earning them.

Man, BSG is dangerous. It starts out "not bad" and "pretty good". Then it get's fraking great and before you know it it's Tuesday.
_________________
Mike Kasprzak
'eh whatever. I used to make AAA and Indie games | Ludum Dare | Blog | Tweetar
View user's profile Send private message
xearthianx
Developer

Joined: 28 Sep 2006
Posts: 771
Location: USA! USA!
PostPosted: Thu Jul 16, 2009 9:38 pm    Post subject: Reply with quote

Oh gods, I know...
_________________
Ionoclast Laboratories - Scientia et Dominatia!
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Madgarden
Contributor

Joined: 31 Aug 2005
Posts: 324
Location: Kitchener, ON, CA
PostPosted: Fri Jul 17, 2009 9:21 am    Post subject: Reply with quote

Get the frak back to work, nugget!
_________________
I know it sounds crazy, but it JUST MIGHT WORK
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Reply to topic GDR Forum Index -> Game Developer's Refuge -> Development Log - Rogue-Opcode game framework Page Previous  1, 2
Game Developer's Refuge
is proudly hosted by,

HostGator

All trademarks and copyrights on this page are owned by their respective owners. All comments owned by their respective posters.
phpBB code © 2001, 2005 phpBB Group. Other message board code © Kevin Reems.