You've been plugged on Indiegames.com:

Discussion and feedback on Construct 2

Post » Wed Aug 01, 2012 8:28 pm

Don't get me wrong: I don't think construct should implement scripting, because I believe in the power of "eventing". However, construct "eventing" should be a bit more "object oriented".

[QUOTE=Arima]If you use lots of groups, sub-groups and sub-events well, I find it to be extremely organized, as an entire section of code can be described in a group name.[/QUOTE]
In other words: we have something akin to "named code folding".

[QUOTE=Arima]You can actually do A.I. with events as they are, and it's not almost impossible at all. You could do what you described above by combining some of the player's character's stats into a 'power level' variable that could be compared to the enemy power level, and to fight or run depending.[/QUOTE]
The standard way to implement AI in games is via a finite state machine. The example I mentioned is akin to one "state" of that machine (enemy). Things get a lot more complex when you have more states, and more complex behaviors. Sure, you can implement everything via events, but you can't easily go and change things once they're in place, and cascading states is also a lot more complex. Imagine your "power level" variable, now imagine 70 other variables like that, each used in a different context, by an enemy that already has to track things like distance to the player, current hp, current mp, max hp, max mp, list of available attacks, movement possibilities and tons of other stuff.

It quickly gets confusing, especially since we have no concept of "internal" variables - that is, variables that are specific to an instance, but that shouldn't be displayed in the editor, because they are used internally. A reload timer is a perfect example of this: you have the reload delay, which is a property of the object, and you have the reload counter, which the object uses internally to implement the reloading - you shouldn't see that second variable because you'll never want to mess with it in the editor.

Wouldn't it be easier to code everything up in blocks and call those blocks something meaningful? I.E: this section means "run away from player", this section means "kamikaze attack", this other section means "try to ambush the player", and this one "flank the player" or "gang up on the player", and so on - if we had custom ACEs we'd be able to do that.
[QUOTE=Arima]Containers are made for exactly that. :) They're not in C2 yet though.[/QUOTE]
I hope containers can include other containers, and those sub-containers can contain other sub-containers, and that we can mix objects in those containers (not hard to imagine such a situation: think of a tank with a body and a turret [2 sprites], a buffer for dead reckoning in multiplayer [array object], player name [text object], post-processing layer [canvas object], health bar [another sprite] and effects [particle object]), and that we can dynamically include and exclude objects from containers.

[QUOTE=Arima]Design patterns? I'm not quite sure what you mean by that?[/QUOTE]
Code reusability is the capacity to reuse elements of an engine. How many times did you have to code a platforming engine? Wouldn't it be a lot better if we could just design one with all sorts of fancy stuff like double jumping, wall jumping, jetpacks, powerups and whatever, then plug a game in it and tweak the values by enabling/disabling parts of the engine, or perhaps sharing such engine in the forums? It's doable now, but what if you have to work such engine into an already in-progress game, instead of building a game from scratch on top of an engine? This process should be easier.

As for design patterns, you'll have to read more on that, there are a ton of them.Fimbul2012-08-01 20:29:41
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Wed Aug 01, 2012 9:27 pm

Kind of a crappy article if you ask me. It's somewhat misleading and incredibly vague.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Wed Aug 01, 2012 9:31 pm

[QUOTE=Fimbul]The standard way to implement AI in games is via a finite state machine. The example I mentioned is akin to one "state" of that machine (enemy). Things get a lot more complex when you have more states, and more complex behaviors. Sure, you can implement everything via events, but you can't easily go and change things once they're in place, and cascading states is also a lot more complex. Imagine your "power level" variable, now imagine 70 other variables like that, each used in a different context, by an enemy that already has to track things like distance to the player, current hp, current mp, max hp, max mp, list of available attacks, movement possibilities and tons of other stuff.[/QUOTE]

I don't know, I've coded things using finite state machines in events before, and had no problem with it. The enemies in loot pursuit have 79 variables and the number of variables they have has never really been an issue that I can recall. What was an issue was my inexperience designing code properly, which is how it turned into a tangled mess. ^^ Subsequent designs have been much smoother.

I do something like this:

enemies
     wandering
          If enemy variable 'mode'="wandering"
               Code for wandering about randomly
               If distance(enemy.x, enemy.y, player.x, player.y) < 500, check angle for field of view
                    If player variable 'powerlevel' > enemy.powerlevel
                         set enemy.mode to "running"
                    If player variable 'powerlevel' < enemy.powerlevel
                         set enemy.mode to "chasing"
     chasing
          If enemy variable 'mode'="chasing"
               chasing code, pathfinding, etc
               If distance(enemy.x, enemy.y, player.x, player.y) < 100, no obstacle in way
                    set mode to "attacking"
     attacking
          If enemy variable 'mode'="attacking"
               Code for charging towards player
               If enemy overlaps player
                    Set player variable 'mode' to "hit"

Which collapses to:

enemies
     wandering
     chasing
     attacking

Etc. Using this method I can make behaviors as complex as I want and still find it easy to work with.

[QUOTE=Fimbul]It quickly gets confusing, especially since we have no concept of "internal" variables - that is, variables that are specific to an instance, but that shouldn't be displayed in the editor, because they are used internally. A reload timer is a perfect example of this: you have the reload delay, which is a property of the object, and you have the reload counter, which the object uses internally to implement the reloading - you shouldn't see that second variable because you'll never want to mess with it in the editor.[/QUOTE]

I'm afraid I'm not familiar with the term (even after several minutes of googling), and don't understand. What if you change your mind about what you want the value to be, or edit out that feature using that variable entirely, or change the variable name to something else? The variable has to be editable somewhere. Why not simply have it in the same list? It seems the most logical place for it. I think doing it some other way would be highly confusing.

[QUOTE=Fimbul]Wouldn't it be easier to code everything up in blocks and call those blocks something meaningful? I.E: this section means "run away from player", this section means "kamikaze attack", this other section means "try to ambush the player", and this one "flank the player" or "gang up on the player", and so on - if we had custom ACEs we'd be able to do that.[/QUOTE]

Isn't that exactly what groups are? That's how it works the way I do it with my example above. Though I'm not arguing against custom ACEs, those would be awesome too.

[QUOTE=Fimbul]I hope containers can include other containers, and those sub-containers can contain other sub-containers, and that we can mix objects in those containers (not hard to imagine such a situation: think of a tank with a body and a turret [2 sprites], a buffer for dead reckoning in multiplayer [array object], player name [text object], post-processing layer [canvas object], health bar [another sprite] and effects [particle object]), and that we can dynamically include and exclude objects from containers.[/QUOTE]

At least in construct classic, containers cannot include other containers (which is a great idea), but all the rest of what you said as possible regardless (dynamic ones could be created with the pairer object), having a tank with the two piece turret, etc. It works better if the health bar isn't part of the container though - all you need to do is create an instance of that for each instance of the tank, place it to the tank's position and set it to the tank's hp and it'll automatically place itself to the right instance.

[QUOTE=Fimbul][QUOTE=Arima]Design patterns? I'm not quite sure what you mean by that?[/QUOTE]
Code reusability is the capacity to reuse elements of an engine. How many times did you have to code a platforming engine? Wouldn't it be a lot better if we could just design one with all sorts of fancy stuff like double jumping, wall jumping, jetpacks, powerups and whatever, then plug a game in it and tweak the values by enabling/disabling parts of the engine, or perhaps sharing such engine in the forums? It's doable now, but what if you have to work such engine into an already in-progress game, instead of building a game from scratch on top of an engine? This process should be easier.[/QUOTE]

I know what code reuseability is, that... wasn't what I asked. I asked about design patterns. ^^Arima2012-08-01 21:39:09
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Wed Aug 01, 2012 10:36 pm

[QUOTE=Arima]What was an issue was my inexperience designing code properly, which is how it turned into a tangled mess.[/QUOTE]
My point is that everything that's complicated enough soon gets turned into a tangled mess.

[QUOTE=Arima]
enemies
     wandering
     chasing
     attacking
[/QUOTE]
The problem with that is that you have little reusability. For instance, this "If distance(enemy.x, enemy.y, player.x, player.y) < 100" could be compacted to a custom condition called "is within attacking range?" - you'll obviously need to repeat that all over your code.
You also have similar cases, such as "is within field of view" and "no obstacles between me and player" which could be abstracted away.

Similarly, if you have more than one condition that triggers "chasing code" or "pathfinding", you'll need to copy+paste the chasing/pathfinding code again at those positions, violating the "DON'T REPEAT YOURSELF" principle of software design - either that or you make a huge OR block with all the possible conditions that trigger pathfinding/chasing.

Violating the DRY principle is bad for obvious reasons.

[QUOTE=Arima]I'm afraid I'm not familiar with the term (even after several minutes of googling)[/QUOTE]
I'm sorry about that part - they are known as variable visibility - there are public variables (what we have at the moment) and private/protected variables, which are related to inheritance (we can already do multiple inheritance via families, which is cool).

The point about hidden variables is that I don't want to clutter the editor with tweakable properties (public variables), which are things I need to adjust to balance/polish my game, with internal stuff (private variables) which are just small storage bins that allow the object to do its work.

You can edit/rename/delete/make public those hidden (private) variables, of course, it's just that they're hidden out of view in your normal workflow, similar to how you can lock a background object in the layout editor so that you can click your objects easily.

It's weird having a ton of internal variables mixed with normal variables, and having to resort to prepending "__" or similar to internal stuff.

[QUOTE=Arima]Isn't that exactly what groups are? That's how it works the way I do it with my example above. Though I'm not arguing against custom ACEs, those would be awesome too.[/QUOTE]
I wasn't very clear there - although you can encapsulate the "kamikaze attack" in a group, you can't say "there you go, enemy! time to do your kamikaze attack!!!"
You can't do that without using weird workarounds like "is group active?" and "disable/enable group". It feels like a hack.

[QUOTE=Arima]At least in construct classic, containers cannot include other containers[/QUOTE]
I know you didn't ask, but I'll give an example: I could have a sprite representing the turret body, another representing the beam (I'm thinking of a beam cannon), a particle object, a post-processing layer, and then have a big spaceship composed of other stuff, with multiple beam cannons across its surface. (the spaceship on the whole is a container composed of the hull, shields, hp bar, and then multiple copies of the "beam cannon" container).

[QUOTE=Arima]I asked about design patterns. ^^[/QUOTE]
I'm thinking specifically of the Factory Pattern and the Strategy Pattern
I expect custom aces should make design patterns implementable.Fimbul2012-08-01 22:40:05
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Wed Aug 01, 2012 10:36 pm

That article is quite low leveled.. It is clear, that the author of the article didn't used C2 for enough time to get it's potential.
B
103
S
27
G
15
Posts: 1,147
Reputation: 17,216

Post » Wed Aug 01, 2012 11:54 pm

[QUOTE=Fimbul][QUOTE=Arima]What was an issue was my inexperience designing code properly, which is how it turned into a tangled mess.[/QUOTE]
My point is that everything that's complicated enough soon gets turned into a tangled mess.[/QUOTE]

I guess we'll just have to agree to disagree here then. I'm not sure I communicated it properly, but since learning how to design code properly, I don't find things turning into a tangled mess anymore.

[QUOTE=Fimbul]The problem with that is that you have little reusability. For instance, this "If distance(enemy.x, enemy.y, player.x, player.y) < 100" could be compacted to a custom condition called "is within attacking range?" - you'll obviously need to repeat that all over your code.
You also have similar cases, such as "is within field of view" and "no obstacles between me and player" which could be abstracted away.[/QUOTE]

I'm not sure how that would benefit in this example, as a custom condition called "is within attacking range" would actually be more complex than a condition "If distance(enemy.x, enemy.y, player.x, player.y) < 100" as the definition of the custom condition would need to be defined somewhere else, and it would still be one condition.

For more complex situations though, having a custom condition that has multiple conditions defined elsewhere could be handy I suppose, but personally I think it would actually be often harder to follow then just having the conditions laid out there instead. That's a matter of personal preference tho.

Except when you're referring to instances such as:

[QUOTE=Fimbul]Similarly, if you have more than one condition that triggers "chasing code" or "pathfinding", you'll need to copy+paste the chasing/pathfinding code again at those positions, violating the "DON'T REPEAT YOURSELF" principle of software design - either that or you make a huge OR block with all the possible conditions that trigger pathfinding/chasing.[/QUOTE]

That's what functions are for, which are in CC but not officially in C2 yet (there is a third party plug in). That basically takes the place of custom actions as well. Basically they allow you to run another event inside an action list or expression.

[QUOTE=Fimbul]The point about hidden variables is that I don't want to clutter the editor with tweakable properties (public variables), which are things I need to adjust to balance/polish my game, with internal stuff (private variables) which are just small storage bins that allow the object to do its work.

You can edit/rename/delete/make public those hidden (private) variables, of course, it's just that they're hidden out of view in your normal workflow, similar to how you can lock a background object in the layout editor so that you can click your objects easily.[/QUOTE]

Hmm... Instance variable groups?

[QUOTE=Fimbul]I wasn't very clear there - although you can encapsulate the "kamikaze attack" in a group, you can't say "there you go, enemy! time to do your kamikaze attack!!!"
You can't do that without using weird workarounds like "is group active?" and "disable/enable group". It feels like a hack.[/QUOTE]

Maybe I'm communicating wrong, because I don't have to use "is group active" or enable or disable groups using my example. I leave the groups all active and the instance switches between groups on its own based on the 'mode' variable. The code to define a behavior is going to have to be somewhere - in my example it's in the "attacking" group.

It sounds like what you want are custom behaviors defined by events? Which are an awesome idea which has been mentioned before, and I'm hoping they are on the to do list. :)

[QUOTE=Fimbul]I know you didn't ask, but I'll give an example: I could have a sprite representing the turret body, another representing the beam (I'm thinking of a beam cannon), a particle object, a post-processing layer, and then have a big spaceship composed of other stuff, with multiple beam cannons across its surface. (the spaceship on the whole is a container composed of the hull, shields, hp bar, and then multiple copies of the "beam cannon" container).[/QUOTE]

Yeah, you can do that stuff already, though it's not the simplest thing.

On spaceship created
     for "loop" 1 to 10
          Create turret
          set turret.turretnumber to loopindex
          set turret.spaceshipid to spaceship.uid
For each spaceship
     If turret.spaceshipid=spaceship.uid
          Place turret at spaceship action point turret.turretnumber
For each laser
     if turret.uid=laser.turretid
          Place laser at turret

[QUOTE=Fimbul]I'm thinking specifically of the Factory Pattern and the Strategy Pattern
I expect custom aces should make design patterns implementable.[/QUOTE]

At least for one of those links, I think functions are what you want.Arima2012-08-02 00:02:30
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Aug 02, 2012 12:03 am

@Fimbul
@Arima

FSM (finite state machine) architecture could be implemented in plugin.
I thought plugin is a good way to reuse events, since reuse-able events is a function-like structure, it has parameters and return values or some actions.
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

Post » Thu Aug 02, 2012 12:05 am

@rexrainbow - yeah, there was a finite state machine plugin for CC, but personally I find a simple variable easier to use. Each to their own, though.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Aug 02, 2012 12:48 am

[QUOTE=rexrainbow] FSM (finite state machine) architecture could be implemented in plugin.[/QUOTE]A behavior would be better, I think, because it would allow you to have many objects in different states simultaneously.
[QUOTE=arima]a custom condition called "is within attacking range" would actually be more complex than a condition "If distance(enemy.x, enemy.y, player.x, player.y) < 100"[/QUOTE]I can think of more complex examples, I'm sure you could too...
My reasoning is this: you said that you don't want to repeat actions, and bundling them in functions would be the way to go. I call functions a "custom action" (they're synonymous right?).

Why not apply the same thought to conditions? You can bundle a complex condition in a "custom condition".[QUOTE=arima]Hmm... Instance variable groups?[/QUOTE]Know what? That's actually better than what I proposed. As long as you could collapse the groups (both in the code editor and the layout editor), this should work fine.[QUOTE=arima]Maybe I'm communicating wrong, because I don't have to use "is group active" or enable or disable groups using my example[/QUOTE]Nah, I'm the one communicating wrong, I understood your example... I just meant to explain how I'd go about doing custom actions with the current system.

On a similar note, you can define custom conditions using boolean variables, but that feels like a hack as well.[QUOTE=arima]Yeah, you can do that stuff already, though it's not the simplest thing.[/QUOTE]I follow your logic, but this feels like it would get really complicated really fast, especially if you had to come back to your project after a month. I'm really anxious for those containers!Fimbul2012-08-02 00:49:54
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Thu Aug 02, 2012 1:10 am

@Fimbul

Yes, for me, "behavior" is one kind of plugin.

But the question is, many users does not know what is fsm, so I had not release this plugin.
B
97
S
22
G
176
Posts: 4,109
Reputation: 103,021

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: newt, shinichild and 11 guests