Entity state changes: functional reactivity with LuaGravity, Céu

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
Post Reply
Wael
Posts: 2
Joined: 2014-11-23, 20:16

Entity state changes: functional reactivity with LuaGravity, Céu

Post by Wael » 2014-11-23, 20:59

Indeed, our enthusiasm about component-based paradigm stems from the 'feeling' that fundamentally it's the more 'natural' way to describe the world, but at the same time we feel obliged to think about what Cartsen referred to as "meta-considerations" to make sound system design decisions.

My personal view on the issue boils down to the single most important consideration of Time; how do we componentize entities' individual functionalities along their inner states, reaction to world events, and synchronization with the world's state..?

Lua is a great language to experiment with such conceptual abstractions thanks to its extensibility. One particular example, which I think fulfills some of our requirements towards a powerful alternative to the rigidity of object hierarchies through "entity aggregation", is LuaGravity. LuaGravity is an extension to Lua that offered functional reactivity , effectively equipping Lua with powerful Dataflow capabilities. In fact, the language proved to be so "overly powerful as a research artifact" to its creator that he turned his academic focus to implementing his ideas in a pure C language implementation to establish whether "Céu can be defined in keywords as a reactive, imperative, concurrent, synchronous, and deterministic language."

In any case, I believe that the dataflow approach may provide answers to some of the more fundamental meta-considerations.

Here are the links:
http://files.catwell.info/code/deprecat ... avity/doc/
https://thesynchronousblog.wordpress.co ... uagravity/

Cheers!
User avatar
Carsten
Site Admin
Posts: 2145
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: Entity state changes: functional reactivity with LuaGrav

Post by Carsten » 2014-11-24, 15:26

Hi Wael,

thanks for your post!

As an administrative note, I have split your post, which originally was a reply to topic Article about entity component systems at Heise Developer, and moved it as a separate topic into the Coding and Scripting forum under new topic name "Entity state changes: functional reactivity with LuaGravity, Céu".
Best regards,
Carsten
User avatar
Carsten
Site Admin
Posts: 2145
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: Entity state changes: functional reactivity with LuaGrav

Post by Carsten » 2014-11-24, 15:38

Wael wrote:My personal view on the issue boils down to the single most important consideration of Time; how do we componentize entities' individual functionalities along their inner states, reaction to world events, and synchronization with the world's state..?

Lua is a great language to experiment with such conceptual abstractions thanks to its extensibility. One particular example, which I think fulfills some of our requirements towards a powerful alternative to the rigidity of object hierarchies through "entity aggregation", is LuaGravity. LuaGravity is an extension to Lua that offered functional reactivity , effectively equipping Lua with powerful Dataflow capabilities.
Thanks for posting these links, which were new to me. I had a glance at the LuaGravity website, but honestly, I did not quite understand how this is supposed to work, and more importantly, what does it buy us? (That is, how does it make implementing Cafu game worlds easier or better?)

At this time, our entities and their components are very simple and well understood (yet powerful) state machines, and it seems like I fail to see what value the "reactivity" mechanisms can add on top of that.

Can you describe a simple example? (In terms of a game world, not the artificial examples given at the LuaGravity page?)
Best regards,
Carsten
Wael
Posts: 2
Joined: 2014-11-23, 20:16

Re: Entity state changes: functional reactivity with LuaGrav

Post by Wael » 2014-11-25, 12:06

Hi Carsten,

Don't worry about rearranging things in your forum, it's your forum after all :) As a matter of fact it's good that you started this new thread as I think it will help focus the discussion.

First off, per your request, let's start with a game-related argument that is best articulated in this post from a few years back: "Why I switched from component-based game engine architecture to functional reactive programming" http://lambdor.net/?p=171

Now, I do not encourage the mindset of replacing something with another, rather we should integrate the best everything has to offer, hence my enthusiasm to the Lua programming language in general, Cafu engine, and your Lua API in particular.
At this time, our entities and their components are very simple and well understood (yet powerful) state machines, and it seems like I fail to see what value the "reactivity" mechanisms can add on top of that.
Sure, you componentize the entities state-fully, neatly and clearly, that is all fine; but what happens when an event takes place and triggers the chain effect? Do we have the most efficient strategy? I guess How to handle/manage events efficiently in entity component system is the main question, keeping in mind the timing discrepancies that occur between the native C++ code and the Lua script VM-driven implementation.

One method to increase the efficiency of event handling is Reactivity. The idea of the reactive method is akin to how spreadsheet cells update their states the instant a change takes place. It is this Dataflow (vs. Controlflow) strategy that enables systems like spreadsheets to poll events, not through call backs, but by self-updating events.

To delve even deeper, don't mind LuaGravity or Céu, for now they're just linguistics, but rather take a look at this link in which a method is described to extend Lua to accommodate the real-time event-handling performance requirements in LiveCoding environments; LuaAV implements LLVM (low level virtual machine) to spawn little kernels to achieve deterministic performance very close to that of native code.
http://lua-av.mat.ucsb.edu/about.html

So, take LuaAV backend + the semantics of LuaGravity + your entity component system = deterministic performance (theoretically).. now how would Cafu engine benefit from that?

Best,
Wael
User avatar
Carsten
Site Admin
Posts: 2145
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: Entity state changes: functional reactivity with LuaGrav

Post by Carsten » 2014-12-01, 00:52

Hi Wael,
Wael wrote: "Why I switched from component-based game engine architecture to functional reactive programming" http://lambdor.net/?p=171
I read this, but I wonder if the author has ever actually implemented what he is speculating about. Moreover, I think that this is actually wrong: His key statement seems to be that components should actually be mathematical functions, with the claim that functions can easier and more flexibly "communicate" with each other than components. However, this is obviously short-sighted, because components must be capable of a lot more than mere functions, and components can be implemented as functionoids, and thus, in fact, act as functions. This is very nice, because it in turn means that with components as implemented in Cafu, we already are on the better side of things. :cheesy:
Sure, you componentize the entities state-fully, neatly and clearly, that is all fine; but what happens when an event takes place and triggers the chain effect?
The event is handled. What else? ;-)
Do we have the most efficient strategy?
I don't know, but what makes you think that the existing strategy is inefficient?
I guess How to handle/manage events efficiently in entity component system is the main question, keeping in mind the timing discrepancies that occur between the native C++ code and the Lua script VM-driven implementation.
Uh, sorry, but what discrepancies? I'm not aware of any, and to the best of my knowledge, everything is well defined and orderly. Can you name any?
One method to increase the efficiency of event handling is Reactivity. [...] LuaAV implements LLVM (low level virtual machine) to spawn little kernels to achieve deterministic performance very close to that of native code.
http://lua-av.mat.ucsb.edu/about.html
Sorry, but it is still unclear to me if by "efficiency of event handling" you are referring to performance bottlenecks or software design issues that should be addressed?
Best regards,
Carsten
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest