Two Stupid Kharkov Questions

Discussion relating to Kharkov: Disaster on the Donets

Moderators: Run5 Staff, SSG Staff

Postby Abwehr » Tue Feb 09, 2010 3:35 am

Like prolonged artillery barrages, carpet bombing by medium bombers was mostly effective for the shock value, not for the casualties caused. German casualty figures after the Cobra bombings show lots of "missing" individuals, which seem to have been mostly shellshocked troops killed or taken prisoner by the Allied, or people lost for days. It's difficult to estimate the impact of the bombing of the Cassino area, as the Germans were mostly not in the locations that were bombed. A comparison of the effect of the Soviet shelling tactics on the Eastern Front is even more problematic as the German units being target often simply evaporated following the attack after the bombardment.

If there's no attack to follow up on the artillery barrage or bombardment by aircraft, the effect will quickly go away. Massive shelling and bombardments are basically the early 20th century version of "Shock and Awe."
Abwehr
Colonel
Colonel
 
Posts: 1041
Joined: Wed Feb 13, 2008 5:23 am
Location: Arnhem, Gelderland province, the Netherlands

Postby hank » Mon Feb 15, 2010 12:22 am

two more stupid questions to keep things moving around here

What programming language is K:DotD written in?

(VB, C+ or ++, Java, etc etc etc etc)

If written in VB is it .Net (2005 or 2008)? ... and if so, what PRNG is used? or is that a trade secret? (PRNG = pseudo random number generator)

(i.e., Random or the VB6 Randomize / Rnd, etc.)

just curious if many games are written in VB since I have to re-acquaint myself with VB because of changes in my work responsibilities. Several years ago I had to program in VB.6 and Lisp.
User avatar
hank
Major
Major
 
Posts: 405
Joined: Thu Aug 28, 2003 12:09 pm

Postby Roger Keating » Mon Feb 15, 2010 8:12 am

All programming is C++. I am more than willing to answer any questions about the programming techniques or even discuss the code.

C++ is probably the fastest language used today so most companies use it for their core programs. The current technique to offer a way to get users involved in the UI is to place a lua layer that can be modified as it is a scripting language but certainly slower than C++. Programs written in this way are generally those that are at the top end of the development cycle so don't expect it around here anytime soon.
User avatar
Roger Keating
SSG
 
Posts: 1792
Joined: Sun Aug 03, 2003 3:32 pm
Location: Sydney, Australia

Postby hank » Tue Feb 16, 2010 12:14 am

Thanks for the reply. I took a C++ course at the local university about 6 years or so ago. I think it was ++ but it could have been +. The industrial controls systems we see at work mostly have VB working behind the scenes. If its not VB its some variation of C. AutoCAD stuff is mostly in Lisp but more and more is in VBA. ... now that's a different language (LISP = lost in silly parenthesis)
User avatar
hank
Major
Major
 
Posts: 405
Joined: Thu Aug 28, 2003 12:09 pm

Postby jjdenver » Thu Feb 18, 2010 10:27 pm

Hey Roger, thanks for the reply about the code. I was thinking of toying around w/ some game programming using C#. What's the usual way to get the map and hexes working?

Is it just a 2D array with some data structure as the array element that contains info about the hex such as what image to display for the hex, what type of terrain it is, etc? So array element 0,0 would contain a data structure about what to display for that hex etc?

Then is there some mapdraw routine that iterates through all of the array elements and draws them onscreen as hexes one at a time with predefined space between hex centerpoints?

If this question is too in-depth just ignore it.

Thx
jjdenver
Lieutenant
Lieutenant
 
Posts: 133
Joined: Wed Jul 22, 2009 2:37 am

Postby Roger Keating » Fri Feb 19, 2010 8:33 am

I can answer this one 'simply' and then let it evolve if you wish. The question is to broad for a complete answer at the moment.

The map is defined as
vector<vector<MapData> > map;
This essentially is a 2D array but in vector form, using the STL library, can be of any size and extended/contracted for the various maps.
MapData refers to the structure that defines what is defined in any one hex of the map and is made up of fixed elements (never change) and floating elements (ones that need to be saved for PBEM and saved games). These are seperated so I know that by looking at any element in the code I can tell if it is a saved type or a fixed type (this is important when debugging).
The old way of defining this was MapData map[TAO3_MAP_MAX_X][TAO3_MAP_MAX_Y]
where the size is defined and space allocated. This way you can't get overruns of the data and it is easier to work with. Most code in Kharkov is in vectors so that expansion is (relatively) easy.
When I access the map in the code it is usually by a statement such as
g.map[x][y].lmd.control
where the struture that contains map and all other unit data is called g and the structure that contains all the changable elements in MapData is called lmd and the element you are looking at is the control of the hex.
g.map[x][y].terrainType
would be the type of terrian in the hex and is fixed.

When dealing with vectors you can access them this way (sort of the traditional way) or using vector methods. I prefer the older way for the map as I know what I am doing at all times.

The map is unusual in being a 2D vector whereas the units etc. are simple vectors. I hope this answers some of your queries but as I haven't programmed in C# I can't comment on it.
User avatar
Roger Keating
SSG
 
Posts: 1792
Joined: Sun Aug 03, 2003 3:32 pm
Location: Sydney, Australia

Postby hank » Fri Feb 26, 2010 6:50 am

two more stupid questions ... and to keep things moving

Is C# the newer improved version of C++? (or maybe which one is more popular?)

(like Visual Basic.Net is the new improved Visual Basic 6; a lot of people still use VB6 but VB.Net is considered cleaner ... according to what I read)

And since K:DotD is written in C++, is the die roll calculation based on the simple method provided with C, srand() ... rand(); or is a more complex better method used like the Mersenne Twister?

(or another method like a Multiply With Carry or (which I doubt is used) the Blum Blum Shub, a cryptograpy grade PRNG)
User avatar
hank
Major
Major
 
Posts: 405
Joined: Thu Aug 28, 2003 12:09 pm

Postby Roger Keating » Sat Feb 27, 2010 9:35 am

I have been told that C# is closer to Jave than C++ but as I have not used it I can't really comment. The Die routine used in Kharkov is ...

short xDice(short a, short b, short c)
{
static BOOL firsttime=true;
int iret;
short i,tot=0,nret;

if (firsttime) {
xUINT uiSeed = xGetDiceSeed();
xSeedDice(uiSeed);
firsttime = false;
}

for (i=0; i<a; i++) {
iret = ((MY_RAND()*b)/(MY_RAND_MAX))+1;
if (iret < 1) iret = 1;
if (iret > b) iret = b;
nret = (short) iret;

tot += nret;
}
tot += c;

return tot;
}

So xDice(1, 6, 0) will roll 1 die and return a number between 1 and 6 with 0 added to the result;
If the system has not been initialiazed when first called it will randomize itself before proceeding. This seeding proceedure is used in network games to get different computers to produce similar streams of 'random' die throws.
MY_RAND() is a call to myrand() in the system and the maximum is 65535;

The dice routine is set up, obviously, to give human players bad results and the computer really great ones, as you can see and I can assure you I have been accused of.

I should be able to answer more of your C# queries shortly as I will look into it as I have the same questions. As you can see I don't mind sharing code segments, as long as they don't get to long. The AI covers a few thousand lines and calls routines which are themselves huge. I can summarize the way it works and am always willing to.
User avatar
Roger Keating
SSG
 
Posts: 1792
Joined: Sun Aug 03, 2003 3:32 pm
Location: Sydney, Australia

Postby jjdenver » Mon Mar 01, 2010 3:09 am

I can offer some comment on C# since I use it at work. I've also used C and C++ long long ago. C# is more similar to Java than to C++. It is very fast, faster than Java in my opinion although I can't back that up with empirical evidence, and a pleasure to use as a programming language.

I would recommend using C# over vb.net since I feel that it has a more concise syntax. It also allows use of pointers using the unsafe keyword - although I wouldn't recommend this without a very good reason.

.NET also offers C++ but that may not be the best choice. I'll quote from an article:
"Of course, there are other .NET languages available too. At first sight, C++ might seem the most attractive choice for programmers with previous experience of that language...however, the .NET version of C++ is best used for manipulating unmanaged memory. In most cases, C# would be a better choice of .NET language for a programmer with C++ experience. Unlike C++, the C# language was specifically designed for the .NET Framework. It benefits from a simple syntax, garbage collection and type safety to eliminate many potential bugs."
jjdenver
Lieutenant
Lieutenant
 
Posts: 133
Joined: Wed Jul 22, 2009 2:37 am

Postby hank » Tue Mar 02, 2010 7:54 am

Thanks for the info.

IMHO concerning die rolls, as long as everything uses the same PRNG its not much different from everyone using the same dice (or loaded dice). ... including Mr. AI.

I'm reading up on all the info I can about Java and C++ to figure out which one I want to spend time learning / relearning first. I played around with Java 2 or 3 years ago for a very short time.

Does anyone have a recommendation for a good inexpensive C++ compiler?
I used Borland for class several dozen moon's ago but I see there's several more to choose from.
User avatar
hank
Major
Major
 
Posts: 405
Joined: Thu Aug 28, 2003 12:09 pm

Postby Roger Keating » Wed Mar 03, 2010 8:02 am

I would recommend

http://www.codeblocks.org/

as it is free and open source. It is not Visual Studio but it will certainly get you started. There is also a good engine that you can run with it called irrlicht (use Google here) and as a library can easily get you into the creation of dialogs, worlds etc.

On the number generation system used in the game. I have always thought it would be silly to get the AI to cheat on the die roll as it would be easily picked up by players, some of whom are excellent statiticians. The computer needs some help around some points but these are very obscure to the average player and with our current AI system have been made almost irrelevant as the design of the AI is so detailed. The computer draws its basic strategy from the AI card, reads the current state of affairs on the map then makes decisions.

I hope this helps out. There are so few questions asked here that get into areas that I feel confident to answer, being a virtual historian.
User avatar
Roger Keating
SSG
 
Posts: 1792
Joined: Sun Aug 03, 2003 3:32 pm
Location: Sydney, Australia

Postby hank » Thu Mar 04, 2010 1:15 am

thanks many times over

After much reading I decided to go with C++ over Jave (for now anyway). I'm going to parallel learn C++ with VB (since VB is part of work now). Based on what I've read, C++ still has a long future ahead of it even though Java is really making big advancements. I'm looking forward to see what the next release of C++ 0x has to offer.

I went ahead and downloaded Virtual C++ Express since its free plus I already had VB Express on my machine. It all loads up kindof together in the same set of folders.

I'm going to download codeblocks too and take a look at it.

regards
User avatar
hank
Major
Major
 
Posts: 405
Joined: Thu Aug 28, 2003 12:09 pm

Postby hank » Tue Mar 09, 2010 3:14 am

More ?s ...
Let me know if you're getting tired of these questions in this forum. I'll stop (no harm done ... I understand).

I've loaded CodeBlocks. I like it!!

I was having troubles with Visual C++ compiling basic console and windows form apps from tutorials and stuff on the internet. I'm sure there were things about VC++ and its environment I was unaware of. I got several small apps to work in VC++ but it was a struggle.

So far CodeBlocks takes on everything I've thrown at it and works (so far so good). I can type code in the main.cpp file and it works. We used Borland in school back in the early millinium. I thought about using it but so far CB is good for me.

So, the other questions are: Do you work in basic C++ or do you use Visual C++ for SSG games?

For games, which is preferred or most used, VC++ or plain C++? (or does it matter?)

thanks for you patience. Hopefully there are one or three word answers; I know you busy getting AtD2 out the door.
User avatar
hank
Major
Major
 
Posts: 405
Joined: Thu Aug 28, 2003 12:09 pm

Postby Roger Keating » Tue Mar 09, 2010 3:41 pm

Don't mention Borland ... it just sort of fell out of the picture and never reappeared.

There is little difference between VC C++ and CodeBlocks C++, just the IDE that takes a little getting used to.

The main thing to note is that all my coding, I think that should be ALL my coding, revolves around the STL or Standard Template Library which basically means that vectors are used for everything.

A simple for loop for units, old style, would be;

for (short k=0; k<MAX_NUMBER_OF_UNITS, k++) {
//do somehting to the units
}

which is now
for (UnitIterator iter = g.unit.begin(); iter != g.unit.end(); ++iter) {
// do something to units
}

Everything is written in vectors which means that adding, subtracting and playing with units becomes much more flexible. In the early versions if you ever reached the MAX_NUMBER_OF_UNITS you went and got a bottle of Vodka. Now it is absorbed by the code.

CodeBlocks handles STL calls as does VisualStudio so there is no problem there.

Never feel bad about asking me questions on code ... it happens so seldom and I like to think someone is interested.
User avatar
Roger Keating
SSG
 
Posts: 1792
Joined: Sun Aug 03, 2003 3:32 pm
Location: Sydney, Australia

Postby hank » Sat Mar 13, 2010 3:37 pm

more fun stuff ... while learning c++

I built a "test stand" for playing with PRNG calcs so I can run as many iterations of single or double die rolls as I want. I pieced together the single die routine from internet forums but made my own mods for the dbl die rolls so it would give me summaries of how many times each combination is rolled.

rollDie() // calc for rolling one die
{
int N = 6;
int result;
result = (int)(((double)rand() / ((double)RAND_MAX + 1) * N)) + 1;
// or // result = (rand() / (RAND_MAX / N + 1)) + 1;
return result;
}
srand(static_cast<unsigned int>(time(NULL)));
// seeded up in the top of the routine

these routines (which I assume are pretty normal PRNG calculations) get pretty close to the probabilites seen with die rolls. ... especially with over 10,000 rolls

2 (1 possible variation) - 2.78%
3 (2 var.) - 5.56%
4 (3 var.) - 8.33%
5 (4 var.) - 11.11%
6 (5 var.) - 13.89%
7 (6 var.) - 16.67%
8 (5 var.) - 13.89%
9 (4 var.) - 11.11%
10 (3 var.) - 8.33%
11 (2 var.) - 5.56%
12 (1 var.) - 2.78%

next I'm going to try to integrate the Marsenne Twister ... my next c++ project

I did notice one funny thing; when I compile the same code with Visual C++, it runs noticeably slower than when its compiled with the Codeblocks compiler.
User avatar
hank
Major
Major
 
Posts: 405
Joined: Thu Aug 28, 2003 12:09 pm

PreviousNext

Return to Kharkov Discussion

Who is online

Users browsing this forum: Rosseau, Yahoo [Bot] and 1 guest