Jump to content

What I'd like to see in Dune-2-inspired games (Links to various threads)


ant222

Recommended Posts

Hi all, and Happy New Year!

After a long time, I came back here. My friend had downloaded several Dune-2 mods/clones and had showed them to me. Most of that games were either simple clones of Dune-2 or clones with minor changes. That remembered me of FED2k, and, particularly, of some proposals that I had made for the games developed by Stefan.

I visited the forum and found that there were several posts like

Link to comment
Share on other sites

  • 4 months later...
  • 2 weeks later...

I am open for ideas to implement an inference engine for the AI; as the new engine should be 80 to 100% modable. Did you follow its progress lately?

No, now I am swamped with the exams... Passed two of them.

[quote author=MrFlibble

link=topic=19640.msg318175#msg318175 date=1181130418]

I understand that the AI is structured as a complex of "if-then-else" routines?

I think Stefan means abstract classes, function prototypes and all related stuff, which is called the interface (to the AI-engine).

Link to comment
Share on other sites

To be more exact, i was speaking of an *inference* engine. Which means, there is a situation (facts) which can be ran over a specific type of question, the question can raise other questions and so on. When all other questions are filled, it goes back (recursive!) and ends up to the main question and it will answer TRUE or FALSE.

All questions answer true or false. Compare it with a form one has to fill in for your taxes. ;-)

Anyhow, to make it concrete, lets say you want an AI that is very economic minded. You could say there is a perfect balance between a refinery and harvesters. Lets say, 1 refinery and 2 harvesters is the best setting.

In any given period (every second, minute, etc) you could run this:

1. Am i satisfied with my credits?

to Answer question 1, it could raise more questions. To keep it simpel i will add:

1.1 Do i have more then 2000 credits at the moment?

1.2 Did i have more then 2000 credits 5 previous moments?

When both are TRUE, then it seems to go fine for the time being, and 1 will be answered back with TRUE.

But, when it is false (ie, i spent a lot of money and my credits do not increase as much, so i am not 'satisfied'); one will add an action to this given situation (question), the action itself will be asking another question:

2. Do i have a ratio of 1 refinery & 2 harvesters?

2.1 How many harvesters do i have?

2.2 How many refineries?

2.3 Is harvesters == (refineries * <ideal amount of harvesters per refinery (2)>)

When 2 answers true (2.1 and 2.2 are fact questions, simply getting data, but mentioned here to clarify), then you could create an action based upon this answer , ie wait for 10 seconds or, build another harvester anyway. OR you could ask yourself another question:

3. Do i have carryalls?

3.1 Do i have harvesters == carryalls? (most ideal situation)

And, on top of this, you could also wonder:

4. Do i have enough refineries (refineries == ideal amount)1?

Etc etc.

This kind of engine could be build via XML files; there are various ways. You could search (use google) for "Inference engine" or "rules engine".

You could script quite a lot of 'ai' in there.

However, a rules engine is very hard to build. I thought about it some time, but i am still not sure how to code this properly. Since i want the game to be XML based , i have to store facts, questions and actions into them. Also think of some scripting language, and on top of that all make it perform.

Link to comment
Share on other sites

Ah-hah, the AI is dynamically-oriented, so to say, then. Sounds very good. And it also means the AI won't be cheating (like endless credits and such stuff), right?

And I see the possibilities already :) Customize the AI to one's own needs ::) Along with many other things to customize within a flexible scenario/campaign/world editor (hopefully) ;)

Stefan, does this also mean that the AI will be able to "adapt" to the player's strategies and effectively counter them, as well as seek out weaknesses and exploit them?

Link to comment
Share on other sites

I don't know if it will be able to adapt; because basically it is just a set of rules it will follow and it will only based on facts (and known information) act. So , there will be patterns you could discover. However, i can imagine that several acts/facts will happen parallel to each other. (i hope this is somehow understandable ;-)).

About finding weakness, i think that is doable. You could fill in a matrix with danger values. Ie, lets say an enemy turret has a score of 1 (from 0.1 to 1.0). And you fill in the radius with degrading danger, till 0.5. Meaning, when you are 'just in reach'  there is a danger of 0.5.

Now, once you fill in that matrix, you can find out what is 'weakly defended'  and what not. You could possibly make this count for 'air / land / sea' based units.

Once you know the danger, you  could make decisions about several actions. There has to be some balance / formula where you can say "with x amount of units i could penetrate through defense factor y". Meaning, even if someone has 10 turrets ready, when you have 1000 units you should be able to penetrate that defense, and the AIs hould not stay still.

A lot to think about, but doable. First things first though, building a nice engine full of modability.

Link to comment
Share on other sites

Well, a game like Dune 2 is a system with a limited number of basic elements that are combined according to a strict set of rules. With proper algorithms, it seems possible to have the AI "learn" to some extent, i.e. it behavior could be controlled by complex algorithms constructed from more simple, basic procedures or blocks of actions, depending on the current situation.

Basically, the idea is to describe playing strategies in terms of actions performed by the AI, and establish correlations between a strategy and a situation. Simple actions, like scouting, harvesting, base construction, attack and defense etc. could be presented as modules with variations, and the global strategy of the AI would consist of these modules. E.g. the AI gets low on credits -> concentrates on building additional harvesters whilst defending itself from the player's attacks -> simultaneously scouts with expendable units (if there are any) to find if there's a weak spot in the player's defenses (like an undefended harvester and the like).

Target prioritizing could be more complex. In Dune 2, the target #1 for the AI is the Heavy Factory (if there's any). In a more versatile way, the AI could "guess" which structure is more important for the player (like if a player wishes to build lots of trikes and quads, and has constructeds some already), and take it out first.

Of course this is all speculative now, but that's what could make the AI more challenging. I'm sure that with proper analysis of the game's balance and structure, a smart AI can be coded.

Link to comment
Share on other sites

I think there should be some basic rules to follow at all times. Ie:

- the spice must flow (economics)

- important structures (const yard, etc)

- defense related structures (power)

Economics:

When your harvesters are dead, you'll be dead soon. So , there must be some defense (sense) about the harvesters.

Important Structures:

You have to defend the most important structures, else you will not be able to construct any defenses, or expand your base (and entire growth in the game).

Power:

Without power, no defenses. Without power, degrading structures, and less productivity.

With these in mind, an AI could:

- attack powerplants

- attack harvesters

- attack const yards / war factories, etc.

i think it is doable to make a good scheme, and give several options a score to determine what the best action should be.

Link to comment
Share on other sites

I think it has always been your goal to create a cheatless AI, right? So I guess it'll have to do scouting frequently to keep it's info about the player's actions up-to-date (there's going to be fog-o'-war, I presume?). Just to make the AI's activities more diverse, sort of ::)

And traps! using a cheap unit to lure an unsuspecting player into heavy resistance... nasty... :D Decoy attacks and the like? Possible? I think yes (at least I hope so) ;D

Maybe start a separate thread for the AI proposals? I believe ant222 (and other people who do programming stuff) can also provide some ideas on practical implementation of the AI's features.

As a more basic note, a the making of good AI should start with assessing the strategical possibilities the game's mechanics provide. Once these are described, the AI will be able to choose from ready solutions to more-or-less predefined situations, i.e. strategies and counterstrategies, attack and defense, etc.

Link to comment
Share on other sites

Stefan: what kind of AI was used in RealBot? How did it work?

This was more per bot / class. There was some code who would glue the bots together, but it was mostly coded from a vision per bot. Therefor each individual bot was aware of itself, but not entirely aware of the team. It only used friendly bot entities nearby to influence its decisions in certain combat situations.

The very latest source has some sense of teamming, where one has a number of a team assigned and a team leader. Basically the team leader is the goal of the bot; i never had the time to finish it though.

why OOP is better than PP (procedural)? In what ways in particular? Does it really make things easier to design/modify?

I don't think OOP is 'better' than PP in general. But i think it more has to do with 'how do you solve the problems in your mind'. Therefor thinking in OO makes it easy to split problems into sub-problems and so on.

For the new engine i surely think it will be a benefit to write it in C++ using OOP; why? Since it forces me to think of the engine as a sum of sub-problems. Normally i would hard-code things and i would just write another function to solve my problems. But now i force myself to truely distinguish code and their functionality.

Since i want moddability in the game, it also needs some extend of flexibility. Ofcourse, i could write an interface and glue things together. But in the end it would not make the code prettier.

I am not experienced enough to determine what is actually best; but for the time being it will do. Let me explain how i coded the previous engine, and how i do it now:

Previous engine:

I had written a few engines before, and as i grew in experience, so grew the engines. I basically devided the game into a few main parts but actually they were not devided at all. The drawing routines contained logic, and so forth. It made the code messy in my opinion. Especially when i did not work on it for a while, and i came back, i noticed my code was far from logical. True, i had seperate files, and i had some sense of sub-problems handling, but still all things were tightly coupled. Later when the mentat came in and the map world (select your conquest part) , it became a real mess. I was programming on steroids, but at the same time it felt like hacking it together.

I bought a mac and wanted to code d2tm on that. I noticed some people could run d2tm on Linux, so there has to be a chance to run it on Mac. Well, it turned out to be a bummer. I relied on non-mac-compatible 3rd party libs and begun the think of this project as a house of cards.

New engine:

Unlike the previous engine, i started this one on paper. And i mean, i drew things a few weeks before i wrote  a single line of code. Normally i would just re-use code of the previous engine and optimize it. But this time, i wanted to build from the ground up , a fresh start.

I tried to handle it like a real project; like i have some requirements beforehand and i build the engine with those in mind. This is more strongly done than any version before, where the only requirement truly was "make it look like dune 2 with C&C controls". This time, my requirements where:

- extreme modability

- run it on linux, mac, windows and if possible other devices (psp and the like)

- use a true cross-platform lib (and extentions)

With my gained Java experience i wanted to go into the world of C++ more deeply, since the benefits of code-reusage would surely help me out (Strings, lists, etc). At the moment it turns out i am not quite there yet, but the code is so flexible, i can change one thing in class A without breaking things in class B.

I have drawn sketches, diagrams, relations and thought of sollutions of several problems which i encountered in D2TM, and how i would solve them in an abstract way.

But to answer your question

OOP is not nescesarily better then PP in my opinion. It is just another way of solving problems.

Link to comment
Share on other sites

Thanks for the reply, Stefan!

What I have made from your explanation, it is competent planning of architecture that has made the code divided into modules the right way (gfx not containitng unrelated logics, etc):

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.