Just keeping up with the Firefox version treadmill. The XUL related pieces are a little off in 3.6 but not enough to do something about it.
It’s here! There’s nothing tremendously fancy in this version, but it does work in FF3.5 and the messages interface has now been integrated into the options/preference dialog. The messages interface has also been improved a bit, both behind the scenes and externally, in preparation for networked notifications.
Why the long wait? Well, things have been busy and it CNx hasn’t been a huge priority recently. Work stuff, travel, surfing the web, plus general burnout from the war. We may see things pick back up again as my next few weekends are free.
Also, the site died because I tried upgrading Wordpress and it failed horribly. The fix was simple but I didn’t have enough time to tackle it for a few days after I broke it.
After finally working out the entire income formula, I’ve improved CNExtend to the point where may be one of the most accurate calculators available for CN.
That’s a bold statement, but the truth is for certain improvements it’s enormously difficult to get within ~.5% accuracy. Let me give an example:
Let’s say we have a nation with 1000 working citizens, a gross income of 100, and a tax rate of 30%. They buy a clinic. What is the change in their collection, normalized for a single day?
Figured it out yet? Of course not, it was a trick question. You still don’t have enough information. For starters, you need to know how many other clinics they already have. Since improvements of the same type stack, adding one clinic when you have 4 existing clinics will yield a different result than if you had zero existing clinics.
So, let’s say we have a nation with 1000 working citizens, a gross income of 100, a tax rate of 30%, and two existing clinics. I’m sure you can guess given the size of this post that is still not enough information. We also need to know how many soldiers they have!
What do soldiers have to do with population? It turns out that after all modifiers such as clinics are added, soldiers subtract an absolute number of citizens. Specifically, the number of soldiers * 0.01 * (environment – 1). Since this happens after clinics have their effect, we need to re-add that population before we can start figuring out what impact this new clinic had. Since this impact involves environment we need to know their environment rating as well.
So, amongst our nations properties are such diverse elements as: 1000 working citizens, a gross income of 100, a tax rate of 30%, two existing clinics, an environment of 3, and 500 soldiers. Is that enough? Well, as it turns out that will get you pretty close. But it’s still not enough.
When you add population, you end up decreasing your income. It’s not generally a large amount for most nations, and the effect is hardly noticeable when buying infra because infra mitigates this effect. However, increasing population through land, wonders, or improvements will have a small but noticeable effect on your income. Since this effect includes infrastructure we need to know that. Oh, and we also need to know about any income modifiers at all since they all apply to this effect. Banks, Guerrilla Camps, etc.
(For those pointing out that you can’t have all these improvements with so few citizens, or that the infra vs citizens ratio isn’t right, I know, it’s just a simplified example)
1000 working citizens, a gross income of 100, a tax rate of 30%, two existing clinics, an environment of 3, 200 soldiers, 400 infra, 3 Banks, and a Harbor. Any of these things change and you get a different result. And this is just a clinic.
A border wall includes a population change, a happiness change, and an environment change. Environment changes on their own also cause happiness changes and population changes. Both the original and indirect happiness changes cause income changes, and so do both of the population changes. They are by far the worst, and getting them to within 1% accuracy has been quite a challenge. At this point population improvements are within .1% accuracy, and I believe that any further improvements will have to come from figuring out exactly where rounding is occurring. At some point it will be impossible due to the fact that the infrastructure numbers stored internally are more accurate than the ones displayed. For instance, you can buy .001 infra or .005 infra and it can have an impact on your population.
Fortunately, I don’t need an individual formula for each improvement. Instead, CNExtend extrapolates changes to your stats based on the improvement’s properties, which are generalized for things like population, environment, and how many if any existing improvements of that type you have.
Well, this update is long enough as it is. By the way, if you figure out the answer to the clinic problem, post it up in the comments. First person to get it right while showing their work gets 3mil, 50 tech, and a gold star.
Despite the last post about the intentional fragility of CNExtend, it looked like it just was not feasible to continue having the page parser break whenever unexpected rows were encountered. Two things changed this: the frequency with which people were starting to encounter the “Actions Taken” row, and the fact that “Alliance Seniority” now appears (and only when you’re in an alliance).
Now, instead of expecting a certain row order, CNExtend now just iterates through each row on the page and checks it against a hash of row “signatures”. If it doesn’t find it in either the hash or a lookup table, then it will throw an error. This means that CNExtend will no longer complain if a particular row is missing, but it also won’t break when rows that only sometimes show up appear. I may eventually add something that specifies that certain rows are always required to validate a view.
The layout editor also got some tweaks, with the addition of the ability to make custom headers appear only in the extended view. This was necessary because some headers only make sense alongside rows that only appear in the extended view. This was already present in the normal layout, but it was hard-coded and you couldn’t change it in the layout editor.
I did some profiling with Venkman, and optimized the drawing speed of layouts. There are probably a couple more optimizations I could do, but it is reaching the point where it’s as fast as it’s going to get. The improvements were pretty substantial, around 50%+, and I will reprofile it again next week to see if I can find any other hot spots.
There’s a new options tab called “Register”, but at the moment it does nothing. It’ll eventually integrate with tech and trade networking capabilities, but there are still a few things that need to be fixed up before that can go into production.
Looks like a javascript library I added in the latest version was causing problems with toolbar customization, and someone pointed out that the colors were wrong in CN:TE for the headers. Those issues were fixed, along with a few cosmetic tweaks to the layout editor.
CNExtend was built to be fragile in the sense that it would rather give you no data than bad data. When it’s parsing your nation view, it has very specific expectations about what it’s going to see. If it doesn’t see what it expects the default behavior is to just throw an error and stop. Even though this can cause it to annoyingly break for a few days, I’m still not convinced that there is a better alternative. I may put forward the pros and cons in a future post, but for now I’m just putting this update out there and taking steps to speed up fixes.
Also: I’ve completed the API and implementation of my network registration code and about 70% of the interface changes necessary to register with CNx. Registration will be a prerequisite to implementing a lot of interesting networked features which I hope to begin testing soon. The first application will most likely be one internal to Farkistan, and if that is successful general networked applications will become available. Of course, any capabilities which require contacting a server will be explicitly opt-in, and the extension will continue to be open-source for those who want to inspect what it’s doing.
Taking a second look at the layout editor, while it is definitely functional there are some sticking points which keep it from being truly great. When entering edit mode the height of the rows change so much that it’s visually disconcerting. I also don’t like how the “delete” buttons look, and it doesn’t warn you at all if you’re about to do something which will make you lose your progress while editing. The help text in the title of the editor tool window is unhelpful and distracting. If anyone has any suggestions or has had problems using it, please let me know so I can incorporate changes into its next revision.
It’s finally here! After months of work and cleanup the layout editor is usable enough to put into production, and while it could be prettier it definitely works. There’s a how-to at the bottom of the features page, and in addition next week I’ll see if I can get a 60 second video tutorial up as well. The layout editor isn’t the only improvement either; there’s a new options panel and numerous tweaks and performance enhancements as well thanks to Venkman’s Javascript profiler.
First, I have to give kudos to MindstormsKid, whose many exceptional contributions have been a great boon to this project. The new options panel was designed by him, as well as many of the internal code refactorings, interface improvements, and general ideas and enthusiasm all of which I am grateful for. He’s set the bar pretty high, but if you think you can hack it contact me here.
The last version (1.3.7) holds the title for longest continuous time as the latest stable version. While it was up, it was downloaded 1300+ times, making it the most downloaded version of CNx.
Even though we test things pretty extensively, there’s always things that are missed. If you come across a bug, report it!. Our turnaround is usually in hours or days, and you’ll be updated with the status of our progress as we fix it.
We’ve got ideas! Whether it’s existing features that need improvement, new features that you want, or you just want to give us feedback, we want to hear from you. We don’t have time to do everything we want, so feedback helps us prioritize.
There are almost always a slew of bugs after major releases like this, but within a week I expect we’ll have most of those worked out so expect a few more updates coming down the pipeline soon.
Really quick TL:DR on this update:
- Tournament edition now works for improvements and wonders. Extended view in TE is still broken but it’ll take a little more time to fix.
- Extended view in the standard version is now updated and working properly.
- Various bug fixes and code cleanup. All were minor, the largest one being that if an unpredictable change occurred after deleting an improvement, it wouldn’t notify you to view your nation again.
It’s not quite a feature, but it is an important development: the code is now hosted at Google Code. To mess with and build your version of the extension, check it out of SVN, install ANT, and run ANT in the root directory. That will automatically build an XPI file that you can install. The debugging directory has a file and instructions you can use if you want to debug code, and if you have bugs you want to fix or features you want to put in, let me know and I’ll review it and add it to the next release. There are at least two obvious outstanding issues, so have at it for your chance at fame and glory =P.
The new high GRL revealed a bug in the border wall calculations where an environment was 10.00 or worse. The nitty gritty detail was that it was doing a string comparison when it should have been doing a float comparison, so it worked fine up until it started comparing numbers with a different number of digits. So, if you’ve been seeing strange predictions for the border wall calculations, that’s why.
The layout editor has had continued enhancements but sadly still does not work. It now has a tantalizing but ultimately useless save button, the close buttons look better and appear in new rows too, and the layout and mechanics have been tweaked. The look and feel of new rows have regressed a bit due to layout changes which I haven’t caught up to yet. Things in RL are extremely busy at the moment which is why things are pretty slow at the moment.
This update accommodates the changes made yesterday, so that should all be working fine now. In the interim I had some unreleased fixes to the interface editor, primarily that it now it stays in the window when you scroll and the start of drop down box to jump right to a particular row. It still doesn’t let you save at the moment, but I have all the components to make that happen.

