City Optimiser Development Thread!

Ok I hit a snag with the mod compatibility. While looking into it I found my enumerations are constants, that is no new ones can be created at "runtime". In order to make this mod compatible I am gonna have a lot of code to write to implement a less sophisticated form of enum which can have new enumerations created while the program is running ie: loading a mod. From stratch :D Certainly challenging :p

I submit that loading terrain/improvement/cheese data from a plaintext file would avoid this difficulty and let you get something reasonably useful out the door quickly.
 
it would, however the way I think you would do it causes the program to constantly be reading the text file, whereas I intended to add the things into the programs internal data from the file. I still will but it is going round the long way (couple of hundred lines of code :p) but the program doesn't depend on the file being open continuously during runtime (correct me if I'm wrong :p).

Though I am gonna be using a text file to define the types (as you say, it's the best way :D). But, I am just going to read the file once :p
 
it would, however the way I think you would do it causes the program to constantly be reading the text file

I cannot imagine how you got that idea, frankly. Read it once at startup time.
 
where does the data go? :p

as I suspected, there is a slight misinterpretation between us. In order to read it once at startup it needs to be put into my primitive enum class. So both our comments said the same thing :p

I thought you meant only to use the file, which means it needs to be opened every time a variable is read.
 
I'm not a programmer, so forgive me if I'm wrong. Don't all the improvements have to be listed in the same place somewhere? Same thing with mods, right?

Just have the txt file list each of the improvements from the base game, followed by the improvements from each mod and a toggle to let you know which, if any, mod is loaded.

As per my question earlier, sorry. Somehow, I thought that your calculator would show totals after X years. Actually, that might be nice to have, if it's not too much trouble.
 
would be nice, indeed. Would be difficult to do but I'm sure it's possible.

Essentially thats whats happening, except the default BtS improvements, terrains, resources plot types and features are stored inside the code like this:

Spoiler :
Code:
public enum Improvements
{
	// iFood, iCommerce, bRiver, iHammers, bWater, bRequiresBonus, sPath
	NONE              (0,  0, false, 0, false, false, "/Transparent.png"),
	CITY              (0,  0, false, 0, false, false, "/Town.png"),
	
	//Independent Improvements
	COTTAGE           (0,  1, false, 0, false, false, "/Cottage.png"),
	HAMLET            (0,  2, false, 0, false, false, "/Hamlet.png"),
	VILLAGE           (0,  3, false, 0, false, false, "/Village.png"),
	TOWN              (0,  4, false, 0, false, false, "/Town.png"),
	LUMBERMILL        (0,  1, true,  1, false, false, "/Lumbermill.png"), //+1 H rails
	FOREST_PRESERVE   (0,  1, true,  0, false, false, "/Forest Preserve.png"),
	WATERMILL         (0,  0, false, 1, false, false, "/Watermill.png"),
	WINDMILL          (1,  1, false, 0, false, false, "/Windmill.png"),
	WORKSHOP          (-1, 0, false, 1, false, false, "/Workshop.png"),
	
	//Semi-Dependent Improvements
	MINE              (0,  0, false, 2, false, false, "/Mine.png"), //+1 H Rails
	FARM              (0,  0, false, 0, false, false, "/Farm.png"),
	
	//Dependent Improvements (all yields to 0 as can differ in application)
	CAMP              (0,  0, false, 0, false, true,  "/Camp.png"),
	PLANTATION        (0,  0, false, 0, false, true,  "/Plantation.png"),
	WINERY            (0,  0, false, 0, false, true,  "/Winery.png"),
	PASTURE           (0,  0, false, 0, false, true,  "/Pasture.png"),
	FISHING_BOATS     (0,  0, false, 0, true,  true,  "/Fishing Boats.png"),
	WHALING_BOATS     (0,  0, false, 0, true,  true,  "/Whaling Boats.png"),
	QUARRY            (0,  0, false, 0, false, true,  "/Quarry.png"),
	OIL_RIG           (0,  0, false, 0, false, true,  "/Oil Rig.png"),
	OFFSHORE_PLATFORM (0,  0, false, 0, true,  true,  "/Offshore Platform.png");


and the mods stuff will be done like this:

Spoiler :

Code:
#Terrains
marsh; 1, 1, false, 1, false

#Types
gorge; -1, 0, 1, false, true

#Features
?; 0, 0, 0, 0.0f, false

#Resources
apple; 1, 1, 0, 1, 0, 0, false, ?

#Improvements
orchard; 0, 0, 0, false, true

#end


the above spoiler some my first idea of what the mod support looks like and the syntax it follows. not sure how this will change in the future though just so you know :p
 
That is a great idea. I will try to follow and give some ideas/advices :)
 
Thanks! Any support is always greatly appreciated!
 
ok an update on the sate of the program itself. It's getting pretty close to completing the first release (the original one without the great input from you guys). I had a few thoughts though,

apart from touching up the interface and sorting out the city buildings and adding graphical options I am becoming stuck on the implementation of working plots.

At the moment the program assumes that all plots that can be worked are being worked, of course this this means that when the city isn't max working population the values are inaccurate (the program will tell you this). So I came up with the idea of working plots but when the city can work all plots (max working population) it ignores what plots you have told it to work and works them all. Should I do this or make the user select all plots to be worked even if the city can work them all (this allows the user to leave population "free" that is to make it work specialists)?

Of course I can always add an Alt + W shortcut or something to work all plots simultaneously if the population is big enough to support it!

also I still need ideas for the program icon :p
 
also quick question, will anybody want me to upload the source code for this? or are people happy with just the executable jar?
 
also quick question, will anybody want me to upload the source code for this? or are people happy with just the executable jar?

I suggest you upload the source code (under GPL or another free license) so that it can remain useful even if it needs changes at a time when you have moved on to other things.
 
This may not be all that relevant here, but something I've always wanted is a in-game mod/tool to tell me how much various city sites can generate, or what features they have. For example, by placing a spot in dotmap (or even dynamically by moving the spot across the land), the mod will show me how many hills there are, how many grassland, how many plains, how much water, how many forests, etc, and ideally also something about yield potential for the city.

This would make it much easier to place cities without counting up hills and food and such while planning where to put the cities.
 
well, in a sense this program does that, it won't count up the hills but it will give the yield. You could always save your game via worldbuilder and import it into the program at the right coords and the program will have generated the city for you and will be able to tell you the yields!
 
I suggest you upload the source code (under GPL or another free license) so that it can remain useful even if it needs changes at a time when you have moved on to other things.

Ah thanks! So what sort of protection does the GPL actually provide to the program?
 
Ah thanks! So what sort of protection does the GPL actually provide to the program?

The GPL allows anyone to use the program (indeed, there's none of the EULA nonsense which commercial software loves, and which may or may not be legally binding in your country; you don't have to agree to the GPL to use a GPLed program).

It also allows anyone to modify and/or distribute the program, under what is essentially one condition; that the recipients enjoy the same rights. I can sell you a copy of a GPLed program if I like (and if you're daft enough to pay), but I cannot deny you the source code, or stop you from immediately giving away what I sold you to the entire world (so in practice GPLed programs are not sold).
 
ok an update on the sate of the program itself. It's getting pretty close to completing the first release (the original one without the great input from you guys). I had a few thoughts though,

apart from touching up the interface and sorting out the city buildings and adding graphical options I am becoming stuck on the implementation of working plots.

At the moment the program assumes that all plots that can be worked are being worked, of course this this means that when the city isn't max working population the values are inaccurate (the program will tell you this). So I came up with the idea of working plots but when the city can work all plots (max working population) it ignores what plots you have told it to work and works them all. Should I do this or make the user select all plots to be worked even if the city can work them all (this allows the user to leave population "free" that is to make it work specialists)?

Of course I can always add an Alt + W shortcut or something to work all plots simultaneously if the population is big enough to support it!

also I still need ideas for the program icon :p

Again, I don't know what's possible. That said, I'd suggest a couple measurements as possibilities: top four tiles (assuming that you're whipping at the most efficient size city), up to your :) cap, and/or up to your :health: cap. The health cap is kind of a throw-in because there are times when it's worth growing past it, but it's rarely a great idea.

If caps aren't reasonably easy, what about starting at four and letting the player increment by two's?

For an icon: how about a picture of a policeman? I was thinking that you could call the program the "City Optimizer Program", or COP.
 
hmmm interestingly metaphorical icons :lol:

as for the happy caps, I haven't implmenented anyway of monitoring health (as it is all about buildings and whether OTHER cities have resouces). The only way it seems feasible to allow working plots is to allow one plot per pop (assuming that the city can balance it's pop) and allow the user to work all plots overriding this rule to see the max potential of the city. not sure I understand what you mean by the second idea? The way I understand it wouldn't it cause the program to become somewhat unrepresentative of the city?
 
ok I am ready to release version 1.0 :D Hopefully the help window will make sure people understand correctly how to use the program :D any questions/bugs/comments don't hesitate to post.

Soon after now I will set up the actual thread for this :p

Updating the first post with the download soon!
 
Back
Top Bottom