Simple Python Things

excuse me :p I learnt from baldyr's teaching and tutorials as well as actually learning the python language (by tutorials!) and reading the API :) and now I have taken my skills to the C++ level :lol: don't shun the old ways :lol: still I learnt a lot from just reading some of baldyr's moe complex code ;)
 
Not necessary to read tutorials since dacubz and me both have programming backgrounds I believe :D

Just looking at the python codes you can pretty much understand what is going on, since it is still your usual for/while loops, usage of variables, define new functions etc

What is needed to learn is simply the Civ specific codes like what the heck is gc.getPlayer(i)???

That, is something none of the tutorials here teach anyway.
Even the API does not teach the effects of each of them.
They simply tell you, what should be the input argument types and the output type.

P.S.
I have A for C and C++ :bounce:
Just can't be bothered to download a compiler to do SDK...
 
nice :D I can kind of say (results pending) that I have an AS level A* in Java (well AS equivalent, you can only get A*s in the full A level. Also it's technically a qualification which has nothing to do with Java, you have to complete a project of your choosing, to which I made a program with Java then presented it (it just so happened to be taken up by a school recently to add to their computers and they want me to help somehow with the teaching of computer science :D:D:D) but I can use my Java as a path to success :D)

some tutorials do cover a little about those classes, I tried to at least... anyway let's run away and hide somewhere before The_J finds us :mischief:
 
Just submit your Rome mod as the project? :D
Anyway, The J already said he is buzy, and he will be kept buzy with those requests.
He won't have time to catch us chatting in his thread :D
 
Well, I sure could, but it's not really important enough.

J, the modcomp Keldath is talking about isn't to complicated correct? I beleive your's is triggered when a tech is discovered, all he wants is a transfer to when a civilization is destroyed. Your code already choosing the civ correct? So the only coding really that needs to be done is switch it to the civilization beind destroyed, and then place the units and buildings afterwards

Complicated is relative. With comments and empty lines included, the related .py has 400 LOC, some of the pseudo-XML loading would have to be changed, automatic placement of units and buildings (which isn't in at all) has to be done, has to be adjusted to tech level, has to be adjusted to difficulty level.
It's not *that* much, but will with testing certainly take longer than 5 minutes.

Yeah, tutorials are a waste of time.
Hands on practise much more efficient.

That's an overexaggeration, but partially true.
Both can be useful, depending on how you learn (some learn better with tutorials, some learn better with directly trying), and what you want to do.


------
attachment unrelated to above text.
 

Attachments

  • events_minipack_merged_files.zip
    58.8 KB · Views: 241
Just curious though,
Wouldn't something simple like this do the job?

When that civ is dead, loop through the map and select a random plot.
Build a city and assign to them.
Give it 2 conscripts which will be already based on tech anyway.
Loop through building list and grant whatever should be free based on free start era
 
as much as I would have liked to, there are some problems:

a) baldyr's work was included, I would need to get him to sign an agreement (good luck finding him :p)
b) it is an incomplete piece of work
c) you have to write a production diary, from start to finish
d) as I am not actually studying computer science I need the project to tie in with a subject at college, which I used french (I wrote a conjugator) and, as I don't do history it's hard to make it relevant!

anyway on topic:

your method plat has some performance issues if I understand correctly. as I did with my storms feature in JRM (in order to make it less bias as well, speed didn't matter, I was in C++ :p) was to simply pick a random index and use it to collect a plot, encapsulated in a while loop. If the plot meet's conditions break the loop, build a city and give them the units and buildings (this presumes you want to go through every map plot and separately check if a plot should be chosen). of course you are forgetting something here, you need to transfer some technologies, maybe you should take a random civ in the game and copy over all their techs to the new civ?
 
Why bother.
The dead civ still keeps all information it has, including war status, attitude, open borders, techs gained etc.
Just give it a new city, and it is revived, with all those things intact.

He wanted the dead civ to respawn in random empty location.
The only reasonable way to me to do this is loop through all plots, and add those suitable ones to an array and then pick a random plot from the array.
 
doesn't he want a NEW civ to take it's place?!

and looping through all plots finding suitable ones and then adding those to an array that you randomly select from is waaaaay more taxing than randomly picking a plot until you find a suitable one, believe me, I've done it and felt the difference :lol: you are essentially dealing with (and no lower than) 4293+ plots. where as mine is most certainly LESS than 4293 plots, considerably less in fact, as there is most likely a one in 20 chance to pick a good plot. so lets say I might only handle around 500 plots on a bad run... soooo much faster
 
If he wants a new one to take its place, then it is totally a bad idea.
A new one requires a new ID, which means
1) There is a limit to how many times this can happen
2) In fact, it cannot happen at all if you start a full game
3) When the new civ is revived, it can be dead pretty soon since I believe it only has 1 city whereas others are fully developed. This means (1) will be reached fast which means you can no longer split colonies since there are no ID available.

As to your suggestion, it only works when you are in the starting part of a game.
As the game progress, most of the map is filled up, beside the oceans, which means suitable plots will be less than 5% of total map plots.

You will end up looping 1000000 times and still getting non suitable plots.
In the worse case scenario, where there is not even one suitable plot, you end up with infinite loop.
 
I hadn't though about the late game... a compromise, until turn 200 (or something sensible) do it my way and then swap to your way, that way you always have the best possible performance!

and for the changing civs, I see your point. unless The_J has any ideas on it... if only there were DLL functions to change a leaderhead, player colours, and CivilizationInfo midgame :p
 
I won't bother to write 2 codes to serve one purpose.
1) Chance of a civ dying in early game is pretty negligible, unless you are playing in easy difficulties.
2) In advanced start games, if the AS points granted are high enough and many civs, the whole map is already filled at turn 1.

Because of the infinite loop, I will give you a B grade at most :D
 
:mad: you will pay for that in time :satan:

well, it's a nice system if there are lot's of tiles that are available :D
 
Logic thinking is another thing that cannot be learnt from tutorials.
You can only gain this by experience.
After doing many projects then you will automatically know, when you want to do a certain feature, what are the tests necessarily, such as change of hands of wonders, liberation of colonies, team games etc
Logic error is most fatal error because they occur without error messages giving you a false impression that codes are running fine when your codes will fail in unexpected situations.
 
hey! I'm a master of logic :) I can solve the computer science entry test bits for oxford university, and they are all based on logical problems, like who has what hat on :lol:

and in any case I have plenty of experience as well :D and I tried your method first for my storms feature but in that case mine worked nicer :D
 
It works because storms can pretty much occur anywhere, well maybe not in the desert.
So there are plenty of available plots, depending on what are the conditions you set for unsuitable plots.
If these unsuitable plots can increase overtime such as global warming turning more plots to desert, then it will become more and more inefficient as well and in the extreme case, infinite loop again.
So unless you are sure the number of suitable plots will always be majority, it will fail overtime
 
Thank you very much for all that you've done already, The_J, and it will encourage to experiment a bit - always fun!
 
Top Bottom