User loginNavigation |
Simulation language ideas?Hi, I am piecing together a scripting language for gaming applications(something that will help in adding details on top of a "core" existing game structure: ways to add tutorial messages, particle effects, tween HUD elements in and out...) and keep coming back to a particular model that I've seen in a few game scripting environments over the years: Bringing an explicit timeline into the language, so that lines of code represent events in a frame of simulation, rather than a computation that can happen at "any" time. The advantages of this model are easy to see: rather than maintaining the bookkeeping of a tiresome bundle of timers and event callbacks, the language becomes a descriptive storyboard for various actions. Both one-shots and tweened parameters(fades, bounces, etc.) can be defined beautifully in this way. What I'm struggling with - and have been struggling with for the past few days - isn't really this aspect of it, but how to implement it in a beautiful, powerful way within a game engine. Crude approaches that only let the language trigger externally coded events are limiting; I considered an approach with a set of named "channels" that could aid in grouping, starting, and stopping timeline scripts in a concurrent fashion, which added some reflective behavior, but this gradually led me towards bolting on a computational type system(including numbers, strings, lists, hashes) that could encompass the capabilities of the channel groups. In trying to add a type system, memory management reared its head; e.g., when one timeline instance ends, how should I destroy the variables it was using - given that there could be circular references? Garbage collection then comes into play as a possibility, and by this point I was getting way too complex to feel comfortable with the implementation. Ideally it should be possible to serialize the whole game state and recall it at any time; with such a large system the task becomes dire. The approach I'm starting on now returns to looking what the game engine is already doing for a domain model. It's an incomplete thought but I figured it might make good discussion: The state of the art currently is to use relatively lightweight entities and hook components to them. The components can "live" primarily in their own domain and exploit custom data structures, memory coherency, etc. The entity, meanwhile, only has to know which components/component instances it has. (in my own engine, I apply an id value that lives on both the components and the entity, hence lookups can be done from anything to anything on the same entity.) My current thought is to start building the language around access to the entity and component model, making the timeline scripts another kind of component, one where awareness of the other components is built in, and the access methods to traverse the graph of world state(looking up collision boundaries, searching indexes of actors or objects, etc.) are available, but computation in the traditional sense is limited. But I draw a blank once I start thinking of the details of how this system might work. My intuition says that computation is a secondary need since the host language can do it, but I find it really hard to break away and get new ideas. By James W Hofmann at 2010-07-02 08:32 | LtU Forum | previous forum topic | next forum topic | other blogs | 4502 reads
|
Browse archives
Active forum topics |
Recent comments
22 weeks 6 days ago
22 weeks 6 days ago
22 weeks 6 days ago
45 weeks 19 hours ago
49 weeks 2 days ago
50 weeks 6 days ago
50 weeks 6 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago