As a French person I feel like it's my duty to explain strikes to you. - AdrienIer

Create an account  

 
[pb46 spoilers] Hitru lurks again

Digging into the code

CacheObject (Actual name: CvCacheObject) 0 lines

Yes, you read right. 0 lines. This is one of the first times were we have to cheat a little bit. You remember that our first city ArtFileMgr is responsible for the art informations from the XML. Well CacheObject is similar to that, but it only holds the data from the other XML files. Or better phrased the data of any other XML file is translated to an CvCacheObject. It's just the pure data and no logic. Therefore you can fix any line amount on it. And yes because we don't have classes for every letter, we need to cheat from time to time. yup

But why do we need this translation? Well it's rather simple XML (1996) files are a rather new invention compared to C++ (1985). That's the simple reason why we need to translate the XML files into something C++ can work with. The other reason is that we don't want to parse the XML file everytime we need information out of it.

But why use XMLs in the first place you may ask. Well there are couple of reasons to do that:

  1. We could put all the info into the C++ file, but then we would need to compile a new DLL everytime we change a small balancing issue.
  2. XML is better readable for non programmers
  3. Modders
  4. It seperates logic from data, which is always a plus. Otherwise it gets messy when you look for something.
Mods: RtR    CtH

Pitboss: PB39, PB40PB52, PB59 Useful Collections: Pickmethods, Mapmaking, Curious Civplayer

Buy me a coffee
Reply

Turn 47

Things have been quiet, but Hitru's faith in the one true The Black Sword has been shaken by the lack of seafood for our northern tundra wastes.  please

We'll settle city 4 in five more turns, then 5 and 6 by turn 60. At that point our economy will explode with the extra happiness from fur and gold and the gold itself. We'll keep praying for something amazing on the island we're settling around t66.


Demos and power. Buddhism fell recently, not sure who to, Dark Savant built a very early Stonehenge and we've still only met Pindicator (and he's only met us if EP spending is anything to judge by). We're below average on gnp and food but netting crabs next turn should address both of those issues. We're joint-most-powerful civ in the world with two Quechuas, so is everyone quite spread out or just feeling peaceable?




Reply

Turn 51

I screwed up a workboat movement, delaying fish for city D by two turns. Fortunately it won't delay the terrace enough to delay the settler that city is tasked with whipping t64, but as penance I C&Ded Pindicator.

He definitely got Mining and Wheel in the first 3 techs. I'd guess the other was Hunting since he has a pig to hook, although it could be AH.

Then I'd guess he got Fishing, Bronze Working and Pottery, although the t45 tech could be him missing out on a religion or getting masonry.


The scout is revealing new tiles again. No sign of a south eastern neighbour just yet, so we'd really like to grab this stone. The city ESE of the clam should be ours, so it'll just be a little stretch to get this area too...


Demos and power.




Reply

Man, that's an impressive picture. how did you get the gridlines? Add 'em yourself?
Completed:  PBEM 34g (W), 36 , 35 , 5o, 34s, 5p, 42, 48 and PB 9, 18, 27, 57

Current:  PB 52.  Boudicca of Maya
Reply

(November 4th, 2019, 16:23)AutomatedTeller Wrote: Man, that's an impressive picture.   how did you get the gridlines?   Add 'em yourself?

Thanks. I used www.getpaint.net. It's a great little program.

By the way I've looked at GNP and decided that I'm more certain about Pindi's techs now - right up to pottery, which I'll confirm next time I log in as he should have a granary in his second city by now.

Started with Agriculture & Myst
T6 Hunting
T11 Wheel
T16 Mining
T17 Warrior #1
T23 Fishing
T35 Warrior #2
T36 BW
T45 Pottery (or a religious tech)

In other news Commodore just settled his third city meaning everyone has except TBW, Superdeath and Gavagai (who has the excuse of The Oracle).
Reply

Turn 52

We're first to a fourth city. smile Pindicator's scout is here to spectate, hopefully he'll be happy we aren't expanding towards him. Thanks to my mistake that fish will be hooked in two turns rather than straight away. banghead


In foreign affairs: as briefly mentioned last post Gavagai got The Oracle, we assume he's gone for Metal Casting to get his half-price 25%-maintenance-reducing forge UB built asap. This means he's going to be slightly slow on expansion, and on this map commerce doesn't seem as hard to come by as normal (edit: actually, it's maintenance which doesn't ratchet up as quick as on a smaller map, and possibly being FIN is making things feel easier too, which Gav doesn't have) so while it puts him in poll position it doesn't make him a runaway. It's the neighbour that he'll crush around t85 that'll do that. wink

Demos and power.




Reply

Digging into the code

DiploParameters (Actual name: CvDiploParameters) 270 lines

This is one of the classes controlling the diplomacy screen and deals in Civ 4. You might believe that this class holds and controls the actual items of a deal like cities, gold per turn or techs, but no. Actually it controls the "external" parameters of the deal like: Is this offer by a human player? Who is talking to whom? Is it my offering or theirs? Is it a renegotiation? Oh and it also holds the actual chat text.

As this class doesn't do anything else interesting it gives me a bit of time to talk about something else. By now you might have wondered, why all these classes have strange writing styles. Why not write the class as follows:

Cv diplo parameters

Well there are actually two topics in this. First the whitespaces between words. As you may know the code written by humans is not the actual code running on your PC. Instead this human readable code is transformed into bits and bytes, zeros and ones, the actual machine code. This translation is being done by a compiler. To simplify: what the compiler does is looking (parsing) the words in the human code and this is done by looking for whitespaces between letters and numbers. Everytime there's a whitespace the compiler knows that this is a new code element.

There's another topic about writing style, but I will leave it for next time. wink
Mods: RtR    CtH

Pitboss: PB39, PB40PB52, PB59 Useful Collections: Pickmethods, Mapmaking, Curious Civplayer

Buy me a coffee
Reply

Turn 59

Fifth city baby! We're first, but there's a 4% chance we lose the city to the barbarian warrior in a couple of turns. If we'd delayed a turn we'd have an archer for defence, but snowball uber alles!

This is as close as we'll settle to Pindi for a while, presumably he'll settle on the two green dots, but there aren't any good cities between us otherwise so hopefully that'll lead to a nice quiet border and let us focus on our other priorities. If he settles the red dot things could become very tense.


Our southern scout discovers that Pindicator and Elkad are our only land neighbours. A bit of camera flying makes me think the unseen land looks something like these blobs. The north eastern continent is going to be our highest priority for exploration/expansion.

The scout could go to investigate the land south of Pindicator next or uncover a coastal trade route to Elkad. We'll probably do the former as we'll soon have some boats that can uncover the coastal route.


Demos and power. Crop yield is the most important demographic, right? It'll improve again next turn too as we have one new city and three others growing thanks to gold and fur pushing up our happy cap.




Reply

Digging into the code

EventReporter (Actual name: CvEventReporter) 522 lines

You probably guessed it by now, but no this "Event"Reporter is not about the Events that pop up from time to time with more or less good outcome for the player. Events in the context of programming are things that happen inside a software that are triggered by outside sources, outside in the sense of not by this code itself. Classic events are mouse clicks or keyboard stroke, but it also includes stuff from the user like "game started" or "turn ended". Here in Civ the term is used a bit more loosely as it also contains events like "culture expansion" or "city growth". All the events I mentioned so far and many more can be found in CvEventReporter, or better phrased every time one of these events is fired, a similarly named method in CvEventReporter is called, which just pipes the event through to the python code.

While we already talked about events this might actually be a great time to write about design patterns. Throughout all of software development's history there were some problems that occurred time and time again. Instead of finding a new solution every time one of these problems came up, developers came up with more general solutions to those problems, that could be reused in every programming language. These solutions were called software design patterns. Think about them like recipes or repair instructions. There quite a lot of them by now and they are a common item you've been asked about in job interviews. One of those patterns is the observer pattern and it works like this: Think about an email newsletter. You can subscribe to it and in the future you will receive a newsletter at unspecified times. The observer pattern works just the same way in the code. A class (observer) subscribes to another class (subject). The subject holds a list of its observers, but is otherwise uninterested what exact class it holds on to. Every time an event occurs the subject calls a method in every observer class. The observer then decides what to do with this event.
Mods: RtR    CtH

Pitboss: PB39, PB40PB52, PB59 Useful Collections: Pickmethods, Mapmaking, Curious Civplayer

Buy me a coffee
Reply

Turn 60

This is the turn we've been anticipating. Our sixth city - Fractal - goes down (right now half the field still has three and the rest are only on four), we hook fur and gold and aside from a little barb issue in the west things look very good. smug

Unfortunately, while our cities look good now, as the game goes on bigger cities that can work more land tiles will start to make these look a bit puny. CacheObject is our best long-term city and is slated to become a bureau-cap at some point (unless we decide that vassalage is better for our finances), but even it only has 3 grass cottages, 3 plains cottages and the gold for commerce. We've done what we can with our lack of land by taking FIN to boost the coastal commerce and IMP to get spreading our tentacles asap, but we're going to need to eat at least one or two other players if we're to be competitive at the end of the game.


Once we get to Currency (around t80) we plan to grab Code of Laws for Confucianism and courthouses, then there are a few paths we could try to make gains along:

- Poly - Masonry - Mono - Monarchy - HBR - Feudalism - MC - Machinery - IW - Guilds and sweep through Pindicator or Elkad with knights (7 000 beakers).
- MC - Machinery - IW - Poly - Masonry - Mono - Priesthood - Philosophy - CS - Paper - Education - Compass - Optics - Liberalise  ASTRONOMY and find someone overseas (or Elkad) to take land from (16 000 beakers).
- Maths - MC - Machinery - IW - Compass - Optics - Bulb ASTRONOMY with 2 scientists and find someone overseas (or Elkad) to take land from (4 500 beakers).

This last option isn't so hot for a FIN civ that wants to work tiles wherever possible and the second option seems to take a long time before we get to do any smashing of heads. So do we go for the classic knight-rush-a-neighbour and then see if Liberalising Astronomy is still a realistic prize? Or is there another option out there?

Demos and power. Did Pindi just build a chariot? I need to find time to do another investigation...




Reply



Forum Jump: