ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all,
simulations are one of the most interesting apps. You have a condition (ex. The door is locked from inside), you program it and you watch how the computer reacts... Wonderful in theory, but in practice? I want to create a simple war simulator, with some AI. You give country, weapons etc. and the computer tells you the conlcusion and causulties. But how can I implement it? NOTE: I know C quite well, Java learning C++ and OpenGL. OpenGL stands in case of visualising the app.
Just a personal opinion here: What you're suggesting may be a whole lot more work than you anticipate. Just a warning...
The first thing you need to do is prepare and organize. Do not just sit down and start coding. You say you want a "simple war simulator", well how simple? Are you going to have a high-level outlook? Say, for instance, assign a "combat power" value to each side involved in the simulated conflict, where the higher the number, the more powerful? Or do you want to simulate all the way down to individual soldiers, vehicles, terrain, etc.? "Simple" can mean many different things: from numbers of "entities" involved to the equations governing interactions.
For simulations, detail is the key. The more accurately you model the situation (by taking into account as many aspects as possible), the more rational your results will be. The downside is, with greater detail comes greater programming complexity, and longer runtime. Think about it; if you want to simulate all the way to the soldier level, then the computer needs to take time to process every soldier in the simulation.
So start asking yourself questions. Put down what you want on paper, and start getting more specific. Once you think you have a workable, semi-final list, go through it again, and consider what it might take to implement it. I don't mean actually write code, but start thinking what it would require to accomplish. Say, for instance, you wanted to force the soldiers to obey line of sight. That implies your world has a coordinate system, and you'll be doing a lot of vector math. You'll have to calculate the line from soldier A and soldier B, determine how far away the soldiers are from each other, compare that distance with the maximum distance a soldier can see, decide what angle(s) determine field of vision, check that there are no objects between the two soldiers, etc. If you look at something you really want to include, but are afraid the implementation is way too complex, then compromise. To extend the previous example, maybe you'll say that soldiers can see an unlimited distance. Maybe you'll say that the battles will take place on a flat, 2D battlefield to make the math easier. Again, it's a tradeoff between rational results and complexity/runtime.
Once you've finally got a list of features you want that you think are realistically implementable, then start thinking about coding. It would probably do you some good to start planning out data structures and routines beforehand. Also, determining simulation milestones could help keep you focused as well.
Also, a note on AI. If you're not familiar with AI concepts already (like neural networks, genetic algorithms, etc.), you really need to do some reading. For starters, adding true AI requires "training" time to teach the AI structure(s) what is "good" behavior and "bad" behavior. Accomplishing that is a project itself.
I'm not trying to dissuade you from doing this, but to help you go in with eyes open. I've played around with the idea of writing a BattleTech simulator, but scrapped it when I realized how ridiculously complicated it would be (regarding AI). That doesn't mean it can't be done; I just don't have the time to devote to it. It is entirely possible you don't have the same constraints on your time.
I think they used a war simulator called Massive for LOTR, if you have the two towers DVD special edition, its on there somewhere. Check that out for ideas or whatever. Its pretty cool, they actually just use that program for a lot of the battles in lord or the rings
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.