Help support TMP


"Which s/w or language to build my game simulation?" Topic


8 Posts

All members in good standing are free to post here. Opinions expressed here are solely those of the posters, and have not been cleared with nor are they endorsed by The Miniatures Page.

For more information, see the TMP FAQ.


Back to the Computer Moderated Rules Message Board


Areas of Interest

General

Featured Hobby News Article


Featured Recent Link


Featured Ruleset


Featured Showcase Article

GF9 Fire and Explosion Markers

Looking for a way to mark explosions or fire?


Current Poll


Featured Book Review


1,001 hits since 17 Jul 2009
©1994-2026 Bill Armintrout
Comments or corrections?


TMP logo

Membership

Please sign in to your membership account, or, if you are not yet a member, please sign up for your free membership account.
Chortle Fezian17 Jul 2009 11:35 p.m. PST

I'm writing a set of rules for the War of the Spanish Succession. I want to write a simulation to test out my combat rules. Basically I will have a "world" consisting of a grid on which the blocks that make up battalions/regiments (and from them commands) are placed.

The whole project lends itself to object orientation. I'll code everything in either Java/C++ (same difference for me).

What I'm wondering about is what to use for the graphical user interface. I will want to display my "battle grid" each turn.

Any ideas?

John D Salt18 Jul 2009 2:02 a.m. PST

C++ would probably be my last choice of language unless I was to be menaced by a zombie Fortran compiler, and maybe not even then. Java is not a favourite of mine, but clearly a better bet than C++ unless you can find some really nice free packages to do what you want. If you're going to use Java, then there's no shortage of GUI things, and in any case the basic libraries had enough primitives to do an adequate job when I started using it over a decade ago.

I would have thought that the thing you needed to determine first was the time-advance mechanism you intend to use.

If you are going to write a discrete-event simulation, you might want to save yourself the effort of writing all your event-scheduling primitives. Last time I looked there were quite a few freebie Java D-E simulation packages available, but I would urge you to consider writing in Python and using SimPy.

If you are going for a fixed time increment, then I would suggest one of the freebie multi-agent system packages might be a better place to start. Google up Repast and Mason for a start; Mason I seem to recall is written in Java.

Oh, and make sure your PRNG is the Mersenne Twister (which it will be if you choose Python).

All the best,

John.

The Black Tower18 Jul 2009 2:09 a.m. PST

Java has GUI tools built in!

If you use Python check out Pygame
pygame.org

But most of all just use a language you feel comfortable programming in

Chortle Fezian18 Jul 2009 3:05 a.m. PST

Thanks for the suggestions. After I posted the message I quickly spotted pygame and started downloading that and python.

I will also download SimPy.

Cheers

Neil

John D Salt18 Jul 2009 5:01 p.m. PST

I have found PyGame very useful, but one limitation you may want to consider is that it does not get on at all well with the basic CPython GUI package, TkInter. If you go with PyGame, you are pretty much limited to a single window, which may not worry you, but if you are going to need multiple windows, getting your head around TkInter may be the best way to go. "Thinking in TkInter" is a useful freebie extended tutorial to help out here. A drawback of TkInter (or anything that isn't "pure" Python -- TkInter is Python bindings around the Tcl/Tk GUI library) is that you can't use pickle() and shelve() with it, and if at any time you are going to want to save the state of a game, or restore it from a file, pickle() and shelve() are a godsend.

Another Python-related beast that may be worth investigating -- in this case if you are going for a continuous rather than a discrete-event approach -- is Stackless Python. This extends Python with tasklets, a kind of continuation that gives a conceptually simple and computationally efficient way of tackling parallel programming. The MMPORG Eve is written in Stackless Python, and as theirs is a "pure" implementation, game state can be saved and recovered, even in mid-game, using pickle() or shelve(). You can't do this with SimPy, because SimPy's process class depends on Python generators, which are not pickleable.

Anyhow, there's a lot of good stuff available for free in the Python world. Do let us know what you finally settle on, and how the program goes.

All the best,

John.

Chortle Fezian18 Jul 2009 8:30 p.m. PST

Hi John and TBT

I downloaded and installed Python and SimPy last night. I didn't manage to get pygame running (some problem with tk or tk bindings.) BTW, I did this on Linux (I have both Linux and Windows).

I went through the SimPy tutorial (the Bank). SimPy is very interesting and has facilities which could extend my simulation. For example, I can see how a Waaaaay out idea I had could be implemented: I want to measure cognitive load for different rule system variants. As I'll be using dice rolls etc., rather than just doing everything in the computer, I want to balance utility against hassle. This could be done in SimPy (or other systems) by assigning a "brain ache" factor to each player activity, like rolling dice, calculating something etc. Of course SimPy has facilities for logging this sort of thing.

I don't actually need much of what SimPy provides at the moment. But it may be good to get on board early and save myself a difficult port later.

Since Python is object oriented I will kick off by using it to develop my sim, if only as a process to learn more about my idea. I can always switch to something else later, and can go with pygame or SimPy or Stackless Python.

I want to bring test players on board eventually which will give me a fan base for testing my rules when they are ready for the table top. If I have to get players to install Python, and other applications, that is going to cut out a significant number of potential players of my game. This pushes me towards using a web based interface, so that players just have to go to a web page, perhaps upload XML files for their game specification (or whatever), and have everything done for them on a server. I am sure this would be fine with a Java application. I can only guess it would be OK with a python app.

I don't know if any of you have played, or are aware of, the game "Austerlitz". It is about 20 years old but still quite popular with certain geeks (I've played it!) Austerlitz has a battle sim where players lay out their armies and give individual units objectives, contingencies etc. It is very simple. I'd quite like to make a more elaborate battle simulation available online. This could be a byproduct of my wargame rules sim.

Anyway, I had a lot of fun with this last night.

Cheers

Neil

John D Salt19 Jul 2009 4:59 a.m. PST

Chortle wrote:


I downloaded and installed Python and SimPy last night. I didn't manage to get pygame running (some problem with tk or tk bindings.) BTW, I did this on Linux (I have both Linux and Windows).

PyGame uses SDL, and I fear that SDL hates TkInter and TkInter hates SDL. Bear in mind that the IDLE environment works in TkInter, and so you might be using TkInter even when you aren't (if you see what I mean).


I went through the SimPy tutorial (the Bank). SimPy is very interesting and has facilities which could extend my simulation. For example, I can see how a Waaaaay out idea I had could be implemented: I want to measure cognitive load for different rule system variants. As I'll be using dice rolls etc., rather than just doing everything in the computer, I want to balance utility against hassle. This could be done in SimPy (or other systems) by assigning a "brain ache" factor to each player activity, like rolling dice, calculating something etc. Of course SimPy has facilities for logging this sort of thing.

I found the Tally and Monitor classes in SimPy very handy. However, much as I love SimPy, unless you are intending to use a discrete-event approach as opposed to a fixed time-increment, the whole thing is probably not worth the bother.


Since Python is object oriented I will kick off by using it to develop my sim, if only as a process to learn more about my idea. I can always switch to something else later, and can go with pygame or SimPy or Stackless Python.

I think Python should prove to be an excellent choice for this sort of approach. As I am used to static strictly-typed languages, it took a while for me to get used to it, but it does mean that you can get on with "suck it and see" programming without a whole bunch of type declarations up front. It's also a mercy that Python implements multiple and repeated inheritance properly.


I want to bring test players on board eventually which will give me a fan base for testing my rules when they are ready for the table top. If I have to get players to install Python, and other applications, that is going to cut out a significant number of potential players of my game.

You might have a google for Py2exe, a tool which lets you create Windows .exe files from Python programs. I don't know if there is an equivalent for a real operating system like Linux, but I imagine that Linux bods may on average have less objection to installing Python anyway.


This pushes me towards using a web based interface, so that players just have to go to a web page, perhaps upload XML files for their game specification (or whatever), and have everything done for them on a server.

If you're going to be mucking about with XML, I can't recommend Beautiful Soup too highly.


I am sure this would be fine with a Java application. I can only guess it would be OK with a python app.

There's always Jython, although I have no experience of it.


I don't know if any of you have played, or are aware of, the game "Austerlitz". It is about 20 years old but still quite popular with certain geeks (I've played it!)

Was that one of the games by Peter Turcan? I used to have his "Borodino", I think it was, for the Atari ST, but couldn't spare the time to get into it as it seemed to deserve. If it's the kind of game I'm thinking of, the loss of control for the player, in that he can't move his pieces instantaneously, seemed very interesting -- indeed the player doesn't necessarily even know where all his own units are, never mind those of the enemy. This struck me as a really useful and intelligent use of computers for wargaming, rather than the much more limited idea of computerising a boardgame or a miniatures game where all the toys (or counters) are visible on the table.

All the best,

John.

Chortle Fezian19 Jul 2009 7:38 p.m. PST

Thanks for the tips on a potential conflict with SDL. I've download Beautiful Soup for a quick look.

Will let you know how I get on with the coding.

This is the Austerlitz PBEM:

link

Sorry - only verified members can post on the forums.