Recent posts by Nolander777 on Kongregate

Subscribe to Recent posts by Nolander777 on Kongregate

avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Deeper Topic (part 2): Composition over inheritance

Originally posted by Elyzius:

I can’t help but notice the difference in approach taken by Drakim and Iain Lobb, who wrote the tutorial that Ace_Blue linked to in the previous thread. Drakim’s approach is to assemble different game entities by dynamically attaching components at run time. Lobb’s approach is to create specific entities by having them inherit from his generic entity class. All the components are created within the specific entity’s constructor.

I’d never heard of component-based programming until Drakim wrote about it here, but I’m guessing that his approach is the correct one, strictly speaking. On the other hand, it looks like Lobb’s approach runs a bit faster, which would amount to a significant advantage if the game has to spit out lots of entities in succession. Are there any serious consequences for taking Lobb’s approach?

There are variable implementations of composition. Drakim is explaining a completely dynamic design implementation. However, sometimes that is unnecessary. Lobb’s entity class contains embedded functionality because it makes the most sense to (atleast it might, I didn’t really analyze the whole thing) for his specific asteroids game. I doubt he plans on extending his asteroids program design much further.

I’m sure Drakim would agree that there is no universally correct way of program design. The ‘right’ method always depends on the specific needs of the developer and the program. Composition is a fundamentally different design paradigm than inheritance, but one is not inherently better than the other. In most cases, it seems that composition provides a more flexible, extendable, and dynamic program structure that eliminates interdependency between data structures (entities). In contrast, making functionality changes within a hierarchical program structure tends to demand a domino effect of change throughout.

Composition is also the only practical way of guaranteeing minimal sufficiency to data structure (entity) functionality. In other words, it easily allows entities to contain all the functionality they need and none of the functionality that they don’t. As drakim points out, inheritance can also achieve minimally sufficient functionality, but usually at the cost of a ridiculously expansive dependency tree.

But sometimes designing by inheritance makes the most sense, and sometimes the overhead involved with linking a thousand different components just isn’t worth it. Heck, even depending on the needs, implementing a god object might be the best design. It all depends. The most important part of design is planning. Ask yourself, “How can I design and develop this program in the most ideal way?” considering the importance of: flexibility, extendability, portability, memory allocation, optimization, deadlines, etc.

TL;DR When in doubt, implement completely dynamic composition.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Complete Object Clone [Solved]

Just store default properties in each object? Then give the object a reset function?

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Source Control (git)

Indeed. I was too lazy to use version control until one time I needed to go back to a several week old version of a project (so many hours worth of changes) to review changes and restore some things. Git saves lives.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / are there more multiples of 3 or 7?

Originally posted by someone93:

I can’t remember specifics. But we showed it in my Uni. intro math.

Originally posted by qwerberism:
Originally posted by someone93:
Originally posted by ErlendHL:

What’s infinity / infinity?

This is one of the cases where we can’t really say anything.

Other such cases include:
0*inf, 1^inf, inf – inf

can you explain why 1 ^ infinity is obscure? o-o

I think it’s similar to why 0*inf is obscure. 0 is similar to 1/infinity. so 0*inf is similar to infinity/infinity, which is obscure.
1^inf = (1+0)^inf = (1-0)^inf which is similar to (1-1/infinity)^infinity and (1+1/infinity)^infinity, which are obscure. Basically if you were to analyze infinity as some number x approaching infinity, then 1 is really some number y approaching 1. Then y^x isn’t necessarily 1 and is obscure.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Math problem (not my homework)

Suppose the range of numbers to chose from is a to b. Suppose there is a function, p(x), that defines the probability of choosing a number, x, from the range a to b. Let P(c, d) define the probability of choosing any number in a sub-range c to d. P(c, d) is the sum of all the probabilities of all the n different numbers in that range. That is, P(c, d) = sum(k = 0, n) (P(x[k])), where x0 = c and x[n] = d. Assuming there are an infinite amount of numbers (continuous domain; i.e, not simply integers), this is equivalent to P(c,d) = the integral [c, d] (p(x)n/(d-c) dx). P(a, b) = 1 because there is 100% chance that x is in the total range.

For example, suppose a number is being chosen from the range c to d, containing n possible numbers. Suppose each number has the same probability, P(x), of being chosen. Then P(x) is constant (it doesn’t depend on x). Intuitively, you can see that P(x) = 1/n in this case. So, P(c, d) = integral[c, d](1/(d-c) dx) = d/(d-c) – c(d-c) = (d-c)/(d-c) = 1, as we would expect.
Next, suppose we are looking for the probability of finding a number in only half of this range ((d+c)/2 to d), we get P(c,d) = integral[(d+c)/2,d](1/(d-c) dx) = d/(d-c) – (d+c)/2(d-c) = (d-c)/2(d-c) = .5, as we would expect.

In this scenario, the first number, z, is given to Todd, where z exists in the range c to d. The probability of a second random number, z2, being larger than z is equal to the probability of choosing z2 from the range z to d (the numbers larger than z) P(z, d) = integral[z, d](p(x)n/(d-c) dx). If we were given the probability distribution function, we could find the probability of z2 being greater than z. Since we don’t have p(x), we can’t find P(z, d). I don’t see how a solution can be found aside from finding P(z, d).

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Stack depth is unbalanced

Qwerber answered my question just fine. Thank you. Apparently, the verification error occurs when comparing the stack before and after a jump. So, the bug can only be traced back to where I called the function. The function in question is enormous, so I was just looking for a bit of help on where to get started, without wanting to reveal all of my code. Found the problem. Was fixed. Fin.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Stack depth is unbalanced

Originally posted by skyboy:

you want information on what in your code could cause it, but don’t want to post your code

My code is irrelevant. Pretend I don’t even have code. I am just curious if there are some common mistakes that could lead to an unbalanced stack. It’s a perfectly reasonable request. I’ve gathered that the problem is always due to ambiguous code (malformed, as UG put it). I gather from your responses that this problem can occur in many different intents, and that there may not be common solutions to it. Of course, you could have just told me as much.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Stack depth is unbalanced

I’m not asking for a fix to my code. I’m wondering if there are some other general causes for an unbalanced stack. Thanks for wanting to help, but it isn’t necessary.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Stack depth is unbalanced

I’m getting this error when trying to build my project:
VerifyError: Error #1030: Stack depth is unbalanced. 3 != 0.

I’ve gained some understanding from skimming through this link:
http://stackoverflow.com/questions/4003286/error-1030-stack-depth-is-unbalanced, but not really because I am too lazy to study it.

I am just wondering what kind of things can cause this problem. I know that syntax errors when accessing 2D arrays like a[1,2] instead of a12 can cause it. Do you guys know of anything else that could cause this issue? Not sure what else to look for. Simple question; too lazy to post my code. Thanks.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / How to store bunch of objects?

@Ace Blue
Sorry, I forgot to mention that the IDs are also in the range of 0-2000

Originally posted by BigJM:
Originally posted by Senekis93:

He means having [0,1,2,3...] instead of 0,,,,,,,,,1,,,,,,,,,,,,,,,,,2 as in… instead of storing elements by id from 0 to 1999, you’d store them based on something else, allowing them to have indexes as high as 4,294,967,294.
But actually, the used memory would be pretty much the same. An array with a length of thousands of millions, yet with only 2,000 of its indexes filled would use about as much memory as an array with length 2000, with every index filled.

That was the point I was trying to make in my rhetoric.

So you’re saying I should make it a vector instead of array, manually nulling out all the slots between the last entry and the current entry if necessary?

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / How to store bunch of objects?

@UG

That’s a good idea, thanks. But I need to decide if the memory saved by implementing that hash method is more important than the time spent searching through collisions.I’ll try to come up with a good hash algorithm. Anyway, it seems like the array strategy is better than the dictionary strategy in my situation.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / How to store bunch of objects?

@UG

The array option was to store the object in the index equal to its ID. Locating the object in the Array would be O(1).
But tell me more about this linked lists pseudo-Hash.

@BGM

The program will both create IDs in no particular order, and have to search for a random ID.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / How to store bunch of objects?

I need to store upwards of 2000 objects and be able to search for them in O(1) time. Each object already has a unique integer ID. Knowing this, should I store them in an Array with the ID as the key, or should I still store them in something like a Dictionary?

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / So yeah, beta testing time draws near!

i dumb

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Visual Studio, Running large amounts of single source files

this should help http://msdn.microsoft.com/en-us/library/x3eht538(v=vs.71).aspx

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Group's

I believe he wishes us to “like” or participate in Kongregate Fan Club, which I assume is some sort of group or page on a website called Powder Toy. He believes this social network will contribute to managing personal community of friends and or fans.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Collaborations / Team Up for "Epic Flash Game Contest"

I am going to enter. Whether or not I am with a team is a different question. Obviously, I would love to have others to work with. Six months is a lot of pressure for a solo developed fully-fledged multi-player game. I have an idea for an ariel-viewed RPG that looks like this: . I think it would be cool as an MMO, too, as far as that goes.

At any rate, with this competition, I would more prefer to join a competent team of developers on a different idea than to go solo on my own idea. I can handle anything client side, and can quickly learn server side if you need more hands on deck.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Collaborations / Programmer here

I need a partner if you’re interested in teaming up with me (programmer, artist) for a relatively large turn-based RPG. Feel free to ask questions.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Show us a screenshot of what you're working on!

Originally posted by truefire:

Is that a Golden Sun sprite Nolander?

Yeah, I found a full blitsheet for him (Isaac) on google images, so I played with it a little bit

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Show us a screenshot of what you're working on!

Originally posted by UnknownGuardian:

Lost Garden’s Wilderness tileset looks a bit out of place with the other graphics. Hopefully you can pick one or the other style and go with it. (Nothing is wrong with using a free graphics engine except some people might ignorantly call you out saying you stole some other game’s graphics. In this case, it might be Boxhead which used the tileset and is fairly popular)

Yeah, I plan on continuing with the tileset for my actual game, the other graphics are placeholders as of now.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Show us a screenshot of what you're working on!

A cleaner looking version of my whatever-you-want-to-call-it engine. The dynamic shadowing still needs work.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Collaborations / Looking for Programmer and Artist

I’ll code if the idea is good. Or if you want, I’m working on my own project at the moment that needs both art and music.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Recommended Resolution?

thats typically too big for most people’s browsers. The RPG I’m making is going to be set at 650 × 450 and that’s pushing it.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / Accessing methods of a base class

Remember, though, that private components are still extended and effectual, you just can’t reference them.

 
avatar for Nolander777 Nolander777 222 posts
Flag Post

Topic: Game Programming / matrix color transform

Ah. thanks i was accidentally adjusting the alpha values as well.