Advertisement

Using runtime language modification to simulate evolved logic?

Started by December 10, 2005 12:34 PM
1 comment, last by GameDev.net 18 years, 11 months ago
This thought just came to me. I'd like to note first, that I've never researched any type of AI (well, just A* path finding and finite state machines, but never implemented either of them). We currently have the .NET framework which is reasonably unique with its reflection system. This allows us to create classes and so on at runtime. Well, what are your thoughts on a system that creates classes at runtime designed to solve certain problems. Here's a small example... We have a person, who is going from a-b, but there is a shallow river in between the person and point b. Upon reaching this river, the person is unsure what to do - because he (or she ¬_¬) has never been faced with a river, or water before. They caustiously enter the river, and notice that it seems to have no damaging effects, only that it reduces movement. They continue following there original path, reaching at point B. Now, what the system I spoke about above would do is the following. We have an abstract base class, for this example we could call it "InvestigateSurroundings" The system would then create (at runtime) a class that derives from this base, and fills it with knowledge that water only reduces movement, so it's fine to enter the water if they aren't in a specific rush. It then registers this "logic" (maybe could call it a Gene or something?) so the next time the person is faced wiht the task of crossing water they will not have to investigate it (until they go into deep water, mwahahaha). Now naturally, creating the logic to actually investigate surroundings could prove tricky, and I'm sure there are lots of flaws in this that I haven't got onto, I just thought this seemed pretty neat :) I might give it a shot and see what I turn out.
Ollie "It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
This idea has been around forever. Prolog programmers use this idea a lot, especially.
Advertisement
You should move away from trying to impliment this using the computer language's constructs and move to more symbolic data driven system.

Unless you are actually talking about generating source code on the fly and having it compiled or interpretted (which can have performance advantages), you are hamstringing yourself by tieing it to the 'lanquage'.


Think of it more in terms of attributes and sets of attibutes.

The attributes data can be a 'solution' -- a code chunk that manipulates data and calls actions to be done (really a generic virtual function) and data (simple or structured).

Think of an object inheriting a skill -- a set of solutions (ways of solving tasks or methods of analysing data) and/or data values that become parameters/coefficients that are used to control behavior (used by the solutions).

An object can inherit multiple 'skills' and have additional attributes assigned to itself (custom attributes attached directly to the object which override the same attribute that may be in one of the skill sets of attributes).



Im working on a project where the AI objects have a link list of skill 'classes'
which are each a set of attribute nodes (uses a hash table). Some of the attributes are callback pointers to code blocks and others are to data values (each attribute has a unique type ID which defines what it is and how it is used). The AI object also has a local hash heap with attributes attached.


Im using a planner mechanism to find solutions but you could more simply have only one solution for each problem type. The solution is found by looking first thru the objects attribute set (they override everything else) and if not found a seach is done on each class in the objects 'skill' class chain.
(Note -- I also have a mechnism to cache found values so searching isnt done all the time for frequently reused attributes). When found, the attribute is used in the way its caller requires (either as a function call or as data). Function calls in turn may access other attributes (making other calls from inherited functions and data).

Any object can thus inherit any functionality that is available and the 'skill classes' allow grouping of functionally related attribute sets. If a learned customization is needed, any attribute can be put into the AI objects local set of attributes to override/supercede what it previously was using.

All functions are predetermined (they are hardcoded in native c++) as yet. I may add a bytecode interpreter to it if I need to be able to change/add additional the functions 'on-the-fly'. Without that, I can still get a lot of variations via swapping different function (pointer) values in an AI objects attribute set and by modifying the list of skill sets that an object has).

Notice it is all data driven and I am not limited to an inheritance system of any specific cpmputer language...........

This topic is closed to new replies.

Advertisement