Forums » General
The Hive, code-level question
This post doesn't desrve much attention as it's just pure curiosity. In the Wiki, the Hive is described as a hierarchical assembly of bots. Does it apply to the actualy code as well? Like, do all changes and events happen in the Leviathan's main functions, and then call shared functions of it's subordinates, and then so-on down the line? Or is every entity just updated at once? (so like, does the Leviathan code make decisions which filter down, or are the decisions made elsewhere and then given to the Leviathan and all of it's related bots at once?) I think I made the question clear...
The way its written is actually unlike anything you would expect unless you've done expert-systems/rule-based programming before. Essentially, there are various fact templates and rules. Certain events within the previously-existing server code cause facts based on these templates to be asserted or modified. The rules have a left hand side and right hand side. The left hand side matches one or more facts, requiring certain slots within these facts to match each other, and when all conditions are met the right hand side fires. The right hand side typically asserts or modifies other facts and/or sends messages to the other server systems to cause things to happen in the game. Only high-level decisions are made by this code (not flying about or dodging/firing). Low-level stuff is still handled the way it used to be, but we're working on a new system for that realm as well.
To more specifically answer your question, "decisions" are made by rules which may apply to any bot or to specific bots. In some cases a rule is Leviathan or queen specific and causes facts to be asserted that fire rules which govern the other bots in that sector or the whole hive. So, in some cases, the decisions filter down, and in others they're made at the individual bot level, but none of the code is in a particular bot-object's methods as you might expect in an OOP style program.
The advantages of this style of programming are that, for cases that fit the paradigm, the code is naturally broken up into logical, readable chunks, and also that, behind the scenes, there is an efficient method of determining which rule's left-hand-sides to check when any fact is asserted or changed.
If you couldn't tell, I'm quite enamored with Lisp and rule-based programming. And I'm really psyched about the level of complexity it will allow us to achieve without making our code unmaintainable.
To more specifically answer your question, "decisions" are made by rules which may apply to any bot or to specific bots. In some cases a rule is Leviathan or queen specific and causes facts to be asserted that fire rules which govern the other bots in that sector or the whole hive. So, in some cases, the decisions filter down, and in others they're made at the individual bot level, but none of the code is in a particular bot-object's methods as you might expect in an OOP style program.
The advantages of this style of programming are that, for cases that fit the paradigm, the code is naturally broken up into logical, readable chunks, and also that, behind the scenes, there is an efficient method of determining which rule's left-hand-sides to check when any fact is asserted or changed.
If you couldn't tell, I'm quite enamored with Lisp and rule-based programming. And I'm really psyched about the level of complexity it will allow us to achieve without making our code unmaintainable.
I concur.
I'm always interested in this kind of stuff.
Can you post this kind of stuff in the devwiki? I've always thought that the most interesting part of the devwiki (last modified back in MAY) were the code guidelines for the hive bot's behaviors.
Can you post this kind of stuff in the devwiki? I've always thought that the most interesting part of the devwiki (last modified back in MAY) were the code guidelines for the hive bot's behaviors.
/me goes confused
the fun really starts when you let the lisp code you've written alter the rules you've defined.
give a few weeks and fun ensues!
(been there, done that, the bot stopped playing whatever game we were playing a few times, but it sure did it well!)
give a few weeks and fun ensues!
(been there, done that, the bot stopped playing whatever game we were playing a few times, but it sure did it well!)
thank you for the detailed response momerath42! as with LeberMac, I too am interested in the technical aspects of the game's development. and i think maybe a central place for this kind of info. wouldbe nice (obviously without giving away trade secrets though). thanks again!