Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - requerent

Pages: 1 ... 7 8 [9] 10 11 ... 24
121
Programming / Re: Another Crash and Burn (But I'm cool with it!)
« on: April 22, 2013, 02:11:29 AM »
Maybe that's it...a problem specification thing. If there's no discrete problem to solve, such as "Write a fun game in seven days" there's just no direction. Right now it's merely, "write a game you would like to play." Too open ended.

As for solving other people's issues. My problem is not a design or programming issue, it's a FUN FACTOR problem. At first it was a problem of scope, but after cutting it down it just wasn't fun. It just wasn't looking like a fun game for me personally. So it's not a problem to be solved really.

As for my source, no problem. But it's a gamemaker file with just enough content for one to imagine the end result. Hardly a playable thing.

I just found and started reading this-
http://www.raphkoster.com/gaming/gdco12/Koster_Raph_Theory_Fun_10.pdf

It's pretty interesting. Just slides- there is a book- and it may be some nice food for thought. Gets into some of the psychology and talks about OCEAN and Flow.

Specification of problems is typically the hardest part.

122
Programming / Re: Another Crash and Burn (But I'm cool with it!)
« on: April 21, 2013, 11:45:32 PM »
I never have time to think of or design any projects I want to make myself, but solving a problem that is already specified is a lot of fun and helps me keep my sanity. Feel free to post your source >_<.

123
Programming / Re: pedantic object oriented question
« on: April 19, 2013, 04:17:09 AM »
Disregarding your experience/goals, Yea- I recommend a Database with no member methods/functions, with stateless routines acting on said database as an FSM of Systems.

The trouble is, with this particular project, to switch to such a radically different conceptualization would pretty much require throwing away all work done so far and starting over from scratch -- and I don't have any experience with the kind of architecture you describe. I suppose I could try it as part of a new project, though. What did you mean when you said "try something a little uncomfortable"? Did you mean "try something new so as to learn how to do it", and the "uncomfortable" bit is because you'd be starting without any previous experience with that new something?

I'd save it for a pet project if you're curious. It's my personal recommendation, but it won't be what is best for you (most people don't program this way, so there aren't many good references for it). You might try encapsulating a few of the ideas into what you already have-- breaking the logic of your game into component-systems is a very good idea whether you are OOP or DOP.

124
Programming / Re: pedantic object oriented question
« on: April 18, 2013, 11:40:10 PM »
@requerent: So what exactly is the kind of design approach you're suggesting? You have a big pile of data called "game state" with no member functions that various objects manipulate using their routines, and which has no routines associated to it itself? Also, you say stuff like "It's pretty standard nomenclature. Controller.Verb() queues a call to Actor.doVerb(). That's how Unreal does it anyway.". What's an "actor" in this setup? Is "Controller" a single monolithic object or are there many "Controller"s? Where's this queue? Who has access to it? Etc.
Ah- Naughty and I are going down a route of discussion that, honestly, doesn't remotely answer your question- but let me try and break some of it down.
Unreal Tournament 3, or the Unreal Development Kit, is a big 3d game engine that can do lots and lots of wonderful things. It uses a rather traditional OOP hierarchy, where all game objects (not data objects) extend from a base Actor class. Actors are any entity, static or dynamic (walls and monsters), that occupy or interact with the game space, or model. The 'state' of the game is a discrete configuration of the 'model,' which is the aggregation of data that describes the interactions/relationships of entities within the game (ie their current stats, positions, etc). When we talk about a 'game state' we're talking about a measurably distinct change to the model of the game. In a real-time game, like Unreal, the game state updates on every 'tick,' or game-loop. In effect, each 'tick,' or 'frame' is a state.
I wasn't being as specific as I should have been- Unreal uses a Controller-Pawn relationship, whereby both the Controller and Pawn inherit from Actor. The Controller is the decision maker and the Pawn interacts with the model. A Controller represent the player and handles input and the camera, but can also represent an AI that asks the Pawn what the model looks like from its point of view and then makes decisions for it. There is typically one controller per pawn- but for an RTS game, you may use Pawns to represent each unit and a single controller commanding them all. The 'queue' I'm describing isn't necessarily a universal action queue, but relative to how each Pawn.doAction() should be called. Controller.Action() is called on key press, whereas the controller then calls Pawn.doAction() where it is most logically appropriate. This can be as simple as setting a boolean 'performJumpOnNextTick,' so that the velocity of a jump is applied at the beginning of a tick, giving the Pawn an opportunity to manipulate it in some way before the physics engine updates the state, or so that the action can be replicated across a server.
Is this a useful architecture for a Roguelike? Yes. Pretty much every game can be thought of in terms of MVC, regardless of whether you use OOP or a Component system. A component system would hook a controller component into an entity, whereas OOP would represent the controller as an Object. I don't know any reference material off-hand, but the question is-- do you want to make Games or do you want to make Games and learn how to make games? If the former, do what you already know howt to do, otherwise, try something a little uncomfortable.
It also depends on what sort of features you want.

OOP vs DOP and Component Systems
Unreal, a heavily OOP game engine, uses components to unite all Actors in the game that share a property. The most mundane example are Collision Components. If an actor has a collision component, then it will be evaluated by the collision system. Unreal uses an event handler, where it calls something like 'CollisionComponent.Owner.onBump(actor bumpedActor,vector momentum, vector hitLocation)' whenever two collision components are interacting. There are other features built-in to the engine that will take care of displacement and overlapping issues, but that all depends on other values set in each Actor. In this way, Actors are performing all of the logic relative to their implementation, whereas the System isn't really doing anything except evaluating relational components and calling events on the Actors. Unfortunately, this tends to lead to a Monolithic Entity Superclass that has all of the possible events available to be overridden. Regardless, you are invariably using components even if you aren't using a component system- IE, the location of an entity is a logically discrete component of that entity that gets worked on at some point in the game-loop via the engine. Explicitly defining component-system relationships helps keep our logic succinct.
A 'pure' component system (DOP) looks at it from the other way around. Part of the value of using components have to do with meta-features like saving the game state, sending concise network messages, and some other things mentioned previously. This is where the 'database w/UI' idea comes in. Instead of having classes and objects relate to one another, we just have a Database and routines acting upon it in a Finite State Machine of Systems. This makes a lot of things easier- including Procedural Generation of bizarre items and monsters. Maybe a monster is equippable but can't be picked up, and there is a spell or ability that equips something from a distance. So very trivial to implement in DOP, but potentially very quirky in OOP.
The main problem I have with OOP is that you cannot predict all of the features you will want to implement. With DOP, it never matters.

If you're familiar with OOP already, then you should try a hybrid. It depends on what your goals are and what your experience is. I don't know of any good examples off-hand, but pseudo-code is available if you want.

Disregarding your experience/goals, Yea- I recommend a Database with no member methods/functions, with stateless routines acting on said database as an FSM of Systems.

125
Programming / Re: pedantic object oriented question
« on: April 18, 2013, 07:38:09 PM »
Quote
That should just be a part of the System that works with those components.

I can understand that standpoint for examples that require mutation of state (and you're following the rule that only the corresponding system can mutate a particular component's state) but for objects that have involved immutable queries (e.g. a graph with a some complex breadth first based algorithm) you may as well just put the method on it.

I'm a little confused about this. There is nothing inherent about DOP that makes AoS to SoA problematic. I mean, the whole idea of thinking of an application as a database is to optimally organize your data- in some minor cases AoS can perform better, but there is nothing preventing you from organizing everything in an SoA manner.

Sorry I was being a bit vague. If you do an AoS to SoA change all clients need to have their code changed. Use a few inlined getters and they don't. This has stung me in the past when micro-optimising a particle system update. The most memory efficient structure wasn't a pure SoA, e.g.

As long as components are only communicating with each other through a System, you're technically fine. I have mixed feelings on hybrid approaches though. I feel like components should only be storing data in a manner that is salient for their respective systems. You don't violate this by slapping methods into them, but why would you need to? That method is really just a sub-system of the systems using that component-type. If you're always going to be using those getters, why aren't you storing data in that way to begin with?


Quote
Code: [Select]
struct Particle {
    vec3 position;
    float turbulence;
    float timer;
    float saturation;
}

Particle AoS[NUM_PARTICLES];

struct SoAParticles {
    vec3 positions[NUM_PARTICLES];
    float turbulences[NUM_PARTICLES];
    float timers[NUM_PARTICLES];
    float saturations[NUM_PARTICLES];
};

// Cache-miss Optimised version.
struct OptSoAParticles {
    vec3 positions[NUM_PARTICLES];
    struct {
        float turbulence;
        float timer;
        float saturation;
    } p[NUM_PARTICLES];
};

The actual code was more complicated but it caused issues because other systems were reading some particle data. It would have been easy to hide the changes for most (read-only) clients if it had been hidden a bit.

That's kind of just an issue with using objects and messaging systems to begin with. I don't dispute that such methodologies are powerful and succinct- but in a component system you should just yield to another system to ensure data-consistency. The relationship of systems in a loop can be implemented as an FSM, through which we can easily ensure that data is accessed in a consistent manner. If we get a read request from a client, that request is only going to be processed in its own system, after changes are written to the model.


Quote
A System is a state-less procedure that evaluates and modifies the game-state/Model. However, each System only works with an explicit subset of Components- or more specifically values within subsets of components. This means that your data should be organized by components or the data within components, not by entities. You can further invert the relationship between keys and data so that everything is "perfectly" SoA if you want. Or only what would perform better that way.

Quote
Are you using the form of component system where entities are purely a unique id and you have no struct/object? Also do you follow the each component can only be written to by one system? There's quite a bit of variation in these kind of details.

Yes. I may have used the word 'pure' earlier, but if I didn't i meant to >_<.

edit: Though it can depend on how you store your data. If you want to split up the x,y,z components of your position because you are working with constraining planes and some systems only modify a micro-component, then you may want to have multiple system modifying data-- but I think this is usually a design oversight more than a necessity.

Quote
Putting an Attack() method on a controller just leaks the abstraction. If there's user input involved in should be handled in the LocalPlayerController or some such. Then again it's been a while since I was using UE2.5 so I could have got my wires crossed.

I guess I wasn't being clear. That's how it works. Model inputs and feedback are handled by the Controller that modifies the model as an Actor. Any Controller is hypothetically valid, whether its AI or a Player, so both would be using Controller.Attack() to call Actor.doAttack().

There are two reasons for this-- one, we want to queue actions up so that they happen in a way that is acceptable to the Actor or consistent with the game loop, and two we may want to change the Controller's state and modify what method of Actor Attack() calls.

States in Unreal aren't driven by data, but allow you to change the functionality of any given method. IE. If we're dead and don't have a pawn, we wan't to override Attack() so that it spawns a new pawn for us.

126
Programming / Re: pedantic object oriented question
« on: April 17, 2013, 09:27:38 PM »
Quote
If you take the database analogy, OO is useful in maintaining constraints and invariants on the database. For example you don't want an entity's health to get higher than the max health stat so instead of manipulating health directly you use methods or functions to ensure that doesn't happen.

That should just be a part of the System that works with those components.

Quote
From the DOP standpoint (which is really a component system with a focus on low-level performance) you
can encapsulate the details of an AoS to SoA transform in a class or module. Clients of your class don't
even need to know you made the change. Also the basic tutorials on DOP don't show the full picture on the
SoA situation. You really want to align the values in the arrays so that all cache misses happen at the same
time. This very fiddly work but causes far less issues if hidden behind an interface.

I'm a little confused about this. There is nothing inherent about DOP that makes AoS to SoA problematic. I mean, the whole idea of thinking of an application as a database is to optimally organize your data- in some minor cases AoS can perform better, but there is nothing preventing you from organizing everything in an SoA manner.

A System is a state-less procedure that evaluates and modifies the game-state/Model. However, each System only works with an explicit subset of Components- or more specifically values within subsets of components. This means that your data should be organized by components or the data within components, not by entities. You can further invert the relationship between keys and data so that everything is "perfectly" SoA if you want. Or only what would perform better that way.




Quote
Quote
I'm not sure why Attack() should be a method on the Controller, do you have a link to who would have said that?

It's pretty standard nomenclature. Controller.Verb() queues a call to Actor.doVerb(). That's how Unreal does it anyway.

Unreal is a nice enough engine with great tools but it's full of 90s throwback ideas. The controller should be calling Attack(), not having Attack() called on it. This is all IMHO of course.
[/quote]

That's what is happening. Controller.Attack() is bound to an input key which queues up the Actor.doAttack().

I will defend Epic for a moment- in that your entire game can be made up of 4 classes if you wish (camera, playerinput, actor, gameinfo). It isn't necessarily a complex minefield of inheritance. It actually uses some component-based systems, but the events are managed by classes, which I dislike- especially when working on a large team.

127
Off-topic (Locked) / Re: The Obscure Games Thread!
« on: April 17, 2013, 08:09:17 AM »
Star Control 2. GPL'ed and available to download for free http://sc2.sourceforge.net/.

It's a space adventure game. Typically rates in the top 10 of 'greatest games of all time' rankings, but very few people have heard of it.

Anyhow, the writing is impeccable and the gameplay is riveting. I doubt that it is possible to live a genuinely full life without playing this game through.

128
Programming / Re: pedantic object oriented question
« on: April 16, 2013, 11:50:57 PM »
Quote
The OOP that the component and 'Data Oriented Programing' guys are attacking is over two decades old, it's just a shame it's what is still being taught to undergrads.

Please elucidate. I need schooling >_<.  A game is really just a database with a UI. Any OOP we do just feels like fluff. You can, of course, program DOP-style in OOP paradigm, but is it not just extra work? If it's all you know- sure, go for it- but are there any strict advantages?

Quote
I'm not sure why Attack() should be a method on the Controller, do you have a link to who would have said that?

It's pretty standard nomenclature. Controller.Verb() queues a call to Actor.doVerb(). That's how Unreal does it anyway.

129
Programming / Re: pedantic object oriented question
« on: April 16, 2013, 01:00:44 AM »
Aye I've seen that in Quake3 (much cleaner in concept than implementation) and pretty much all games written in functional languages. Must admit it is a lot nicer to do the networking for that kind of structure.

Many of the modern game engines use a Controller-Pawn relationship to make a distinction between the AI/Player and how they interact with the state/model. This is conceptually simple to understand, but it's usually implemented within a complex hierarchy of entangling Objects, none of which are necessary to the logic in the game with the exception of a few with native hooks (typically for cameras and player input-- and in a general way collision detection, though not necessarily resolution).


That's why I like Component-based Entity-Systems. Your state is a database. Each key is an entity (or a state of an entity) that points to a table of components. Each component is a specialized set of data to be worked on by Systems, which are just state-less procedures that analyze a subset of the components and updates the data accordingly. Saving games, state space search, and networking is then super-trivial. Adding components or states dynamically to entities is trivial, as is creating new systems and components to expand the scope of your game. Easy to test and debug also.

Lua is especially well-engineered for this sort of design scheme (tables and local variable speed-ups are great), though you can accomplish it in any language.

130
Programming / Re: Most popular IDE and curses library?
« on: April 15, 2013, 06:48:44 PM »
I have an irrational hatred of MS, and yet I have to concede that Visual Studio really is the best general purpose IDE ever. Credit where it is due...

I hate how true this is. The engineers behind VS are very very clever. I use it for Python and UnrealScript mainly, but C# with LINQ is a joy to work with.


Oh, but FlashDevelop is as awesome if you work in Flash or HaXe- you can natively load libtcod or curses into HaXe and develop native Apps in a manner that is very 'C# w/out .NET'~ish.

131
Programming / Re: pedantic object oriented question
« on: April 15, 2013, 05:16:05 PM »
A game state is just a discrete representation of all salient data within the game. It's very useful to have these as separate data structures so that you can easily generate trees and search them, save them, or hash and mask them for networking.

requerent: by game-state do you mean something roughly like the 'model' in something like MVC? For example:

Code: [Select]
struct GameState {
    Entity entities[...];
    Terrain cells[...][...];
    Gas gasLayer[...][...]; // For area of effect spells or gases like in Brogue.
};

That's incomplete. You'll need the Tick number and you need the seed in there to accurately replicate the state in Brogue. We also need to know whose turn it is- since we may be using states to search the state space to analyze what the best moves for a group of enemies may be.


It is an MVC model so long as each entity has a controller.

132
Programming / Re: pedantic object oriented question
« on: April 14, 2013, 10:01:03 PM »
I think using the word 'Map' is kind of naive.
Have you looked at the source for many video games? Try Crawl, Nethack, Angband, Doom, Wolfenstein, or Quake some time.

Old games used naive nomenclature. So what? Are we talking about topology, game states, the systems that manages the relationships between entities, or just an arrangement of entities? A monolithic 'Map' object for doing all of those things is naive.

133
Programming / Re: pedantic object oriented question
« on: April 14, 2013, 07:18:29 PM »
I think using the word 'Map' is kind of naive. What you're talking about are game states.

  • Critter polls game state to determine which of its behaviors is ideal.
  • Critter informs game state of its behavior, game state provides available moves and heuristic weights.
  • Critter tells state where it wants to move and state updates to a new state.

Doesn't matter where 'move' is located, so long as information is passed and evaluated accordingly.

I think this gets silly though. I prefer that neither my entities nor my states have any methods at all- they're really just tables of data that get worked on by different systems. A system is just a procedure that reads and updates the state based upon a specific subset of salient properties among entities. A system can look at the game state and the state of an entity and evaluate which state it should be in without any silly messaging schemes.

134
Programming / Re: pedantic object oriented question
« on: April 10, 2013, 01:01:23 AM »
You can achieve all the power with significantly more elegance with a combination of C and Lua- Lua being programmed in C is a subset of C so... it's really all just a varied expression of C.

By that logic, we should all be programming in assembly, because C is merely a subset of assembly... ::)

By what logic? OR a lack of reading skills? I hope it's the latter, as inferences like that would make life very difficult.

135
Programming / Re: pedantic object oriented question
« on: April 05, 2013, 11:23:11 PM »


You can achieve all the power with significantly more elegance with a combination of C and Lua

I think this discussion is over. Grow up and learn more about programming. That's all I can say.

Or I just won't reply with an ad hominem.

Pages: 1 ... 7 8 [9] 10 11 ... 24