Announcement

Collapse
No announcement yet.

StuporMan's Supply And Demand Calculator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • StuporMan's Supply And Demand Calculator

    I would like to announce the initial release of StuporMan's Supply And Demand Calculator! (version 1.013 now available).

    This program was designed to help the average Civilization 2 player to understand how Supply and Demand works and what changes the Supply and Demand lists in their cities so that they can manipulate these values. All you need to do is enter the information and then click Calculate Supply and Demand and it will do the rest!

    Before using please read my standard disclaimer:

    I take no responsibility for any damage this program does to your computer, data, programs, dog, cat, significant other, or any other person, place, thing, or imaginary entity. Use at your own risk!

    I take no responsibility for how you use the information provided by this program or the accuracy of said information. Again use at your own risk!

    I make no promises that this program will work on your computer or other device and make no promises to make it do so in the future. Likewise, I make no promises to make this program work correctly or any better than it does at the time of this posting.

    End Disclaimer

    Sorry about the disclaimer, but us programming types have to cover our behinds a bit! I did not make this program with the intent of harming you or your computer and I have every intention of completeing this project, but again I can't guarantee nothing bad will happen!

    Edit: This program is now very near to being 100% accurate. I have tested on several cities in several situations and all have worked properly. There still may be some inaccuracies and if you can help me track them down I would greatly appreciate it.

    Current Features:
    1. Lists Supply and Demand lists for the cities put in the calculator, assuming that the city receives a trigger.
    2. Lists the Top 3 Supplied and Demanded Commodities and the current wildcard, in addition to the Final Supply and Demand List.
    3. Lists the value totals for all Supply and Demand commodities for ease of manipulation.
    4. Ability to save the calculator data to a file and load it back again.
    5. Can Track up to 255 cities.
    6. Can store information about all civilizations.
    7. No longer need to click the Calculate Supply and Demand button, every change immediately affects the list.

    Tentative plans for future versions:
    1. Caclulate beaker costs for all civs.
    2. Caclulate Caravan Delivery Payments - Per Elephant.
    3. Make it platform independant.
    4. Template Creation for useful city conditions. - Per Ell_man
    5. Reading terrain (and other) data directly from the save file - Per Ell_man
    6. Highlighting SSC improvements - Per Ell_man
    7. Calculate Copper Dye Bug Commodities - Per Ell_man
    8. Display Solo Cycle Dates. - Per Ell_man
    9. Anything else I can think of later.
    10. Any other reasonable suggestions you may have.

    Thanks for your testing, suggestions, and (constructive) criticisms.

    Version History:
    Version 1.013
    Bug Fix:
    Corrected error that occured when loading a file with multiple cities that caused certain cities to not display properly.
    Version 1.012
    Bug Fixes:
    Corrected Small problem with "distance to" calculations being off by 1.
    Added Features
    Can track up to 255 cities.
    Can keep track of cities from All civilizations.
    Manual now included.
    Interface Changes:
    City Names now included.
    Entering Civilization information will store it for all cities owned by that civilization.
    Continents now store their sizes.
    Version 1.012
    Ver .91: Corrected error with Uranium Supply
    version 9.0
    New Features:
    Added a final Supply and Demand List to indicate exactly what the city will supply and demand.
    Bug Fixes:
    Fixed some problems with the way oil's supply and demand was calculated.
    Added the computation for secondary wildcards.
    Misc Changes:
    Moved the Wildcard commodity up to display just below the top 3 Commodities for both Supply and Demand.
    version 0.20:
    New Features:
    You can now Save the Supply and Demand calculator information to a text file and reload it later.
    Bug Fixes:
    Some miscellaneous bug fixes in supply and demand formulas and their supplementary functions.
    version 0.15:
    Bug Fixes:
    Fixed Error where certain values for terrain were behaving incorrectly. (IE. the value in Ocean Tiles was being used for Plains Tiles calculations)
    Fixed Several Errors in character string to number conversions.
    Fixed a few integer division errors.
    Enhancements:
    Darkened the font to (hopefully) decrease eye strain.
    version 0.10: Initial Release

    Acknowledgements:
    First of all I must thank samson, for without his intense study of trade and the formulas he created, none of this would have been possible.

    solo also deserves a lot of credit, both for helping samson develop and test his formulas and also for helping me to understand how the formulas worked. He also gets the Toasty Moth Award for all his help debugging this program.

    I would also like to thank Elephant and Ell_man for their suggestions on how to improve the calculator. They have given me goals to take this calculator to places I never anticipated, and hopefully their wishes will be granted (someday).

    Lastly, I would like to thank all of those who have bravely downloaded and tried this program. I know it is not easy to trust a complete stranger, especially with all the spyware and viruses running around these days. I appreciate your trust and confidence, and hope that you have and will enjoy this and all future versions of SMSNDC!

    Enjoy!

    StuporMan

    (Version 0.91 was downloaded 4 times and can now be dowloaded below)
    (Version 1.012 was downloaded 1 time)
    Attached Files
    Last edited by StuporMan; June 21, 2005, 12:24.
    Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

    StuporMan's Supply and Demand Calculator
    Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

  • #2
    This was something Samson himself was hoping for, i.e. someone who could put his formulas into a computer program.

    Your program's interface looks good, so I tried it on my 2000 BC save just posted in OCC #2. I think some of your calculations are in error and will check into this in more detail, later.

    Meanwhile you might want to download that save yourself and take a look.

    Comment


    • #3
      Thank you solo!
      [Edit:]
      This was something Samson himself was hoping for, i.e. someone who could put his formulas into a computer program.
      It is a pity that I did not find this site much sooner. I would have liked to have been able to talk with samson, as he is probably the best civ 2 player to ever to play the game. It is a pleasure to be able to put these amazing formulas into coded form. Samson truly was a genius to be able to figure out all of this information. Hopefully I will be able to do them justice, eventually anyway.
      [/Edit:]


      I knew that the formulas were not 100% accurate when I posted this, but knew if I waited it would never get posted and I would miss out on several opportunities to have others critique the program interface and possibly even help me figure out where my formulas are in error.

      I have one question in particular that I will need answered and that is about how wildcards work when they are already asserted in the supply or demand list, especially the conditions which result in this producing a secondary wildcard and how this wildcard is selected.

      Thanks for the input. Hopefully I will have some more time to work on this project fairly soon. I am really looking forward to getting the formulas corrected and getting ability to track multiple cities and the ability to save added to the program as these will make this program even more useful.

      Thanks again,
      StuporMan
      Last edited by StuporMan; May 31, 2005, 13:10.
      Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

      StuporMan's Supply and Demand Calculator
      Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

      Comment


      • #4
        Well I had some time on my lunch break today, so I fixed some of the problems that solo pointed out. The calculator now works properly for his 2000BC save in the Second OCC Challenge of 2005.

        Version 0.15 is now available for download. It and the change log are now in my first post. Assuming this version proves to be reasonable close to 100% accurate I will start working on additional features for 0.20. Again let me know your thoughts they are greatly appreciated.

        StuporMan
        Last edited by StuporMan; May 31, 2005, 13:04.
        Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

        StuporMan's Supply and Demand Calculator
        Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

        Comment


        • #5
          Much better, as that city now works correctly. I'd recommend some more checks on other cities from other games.

          Wildcarding can be tricky. Make tests in this order.

          1) The commodity calculated as the wildcard will be expressed in the middle position of its list.

          2) If the same commodity is calculated for the supply and demand wildcard, this commodity will appear as the demand wildcard and the supply wildcard will not be expressed.

          3) After the discovery of Industrialization, Oil can appear as a supply or demand wildcard if the regular wildcard is not expressed.

          4) After the discovery of Nuclear Fission, Uranium can appear as the demand wildcard if the regular demand wildcard is not expressed. Uranium can supplant Oil as this wildcard.

          Any wildcard assigned by the criteria above is not expressed if the commodity makes it onto either the supply or the demand list. I believe the demand list is finalized before the supply list is determined.

          Example:

          Supply Wildcard - Silk
          Demand Wildcard - Silver

          Top 3 supply commodities - Gold, Cloth, Silver
          Top 3 demand Commodities - Copper, Spice, Gems

          Industrialization and Nuclear Fission have been discovered.

          Silk does not appear on either list, so by criteria 1 it becomes the supply wildcard.

          Silver appears on the supply list, so it will not be expressed as the demand wildcard. Oil would take its place as the secondary wildcard if Nuclear Fission was still unknown, but this tech has been discovered, making Uranium the secondary wildcard on the demand list.

          Final lists would be:

          Supply - Gold, Silk, Silver
          Demand - Copper, Uranium, Gems

          I am not positive about this, but I believe that if a potential wildcarder appears in the middle position of a supply or demand list (as one of the top 3) and is covered by the regular wildcard or the other secondary wildcard, it may still act as a wildcarder. Had Silver and Cloth swapped places in the top 3 lists of the example above, Silver would have appeared as the demand wildcard since it will be covered by Silk on the supply list.

          Also be aware that a city must have a triggering event in order to display the most up to date list. For example, when a city changes to size 3, this may cause some list changes, but they will not take effect until the next cycle turn or other triggering event.

          Although Samson has been away for about 2 years, he may lurk around here from time to time, and may even start posting again if he finds this tool.

          (edited to correct an error and to include an example)
          Last edited by solo; June 1, 2005, 09:39.

          Comment


          • #6
            Version 0.20 released

            Solo,
            Thanks for the info on Wildcards. The "can" always confused me when dealing with secondary wildcards. "Can" is a very bad word when it comes to programming as it implies uncertainty, but you have cleared that up. As long as the proper tech has been discovered, the regular wildcard is not expressed, AND the secondary wildcard can be expressed (is not in either list), then the secondary wildcard will ALWAYS be expressed. (I like the word always much better!)

            It is also useful to know that Uranium replaces Oil as a secondary wildcard. I assumed that both the regular wildcard and Oil had to both be expressed before Uranium would become a sort of tertiary wildcard.

            I have done more testing and version 0.20 is accurate in almost all cases so far. I have, unfortunately run across one city where the formulas (as I have them working) do not appear to work properly. I have attached a zip file with the save file and the city's (Susa) supply and demand file. The supply of the city lists Dye, Coal, Copper but my program lists Dye, Copper, Gold. Now, my program would have the correct values for Supply were it not for the Demand for Coal being greater than the Supply of Coal in the city by 2.

            I have double checked my formulas and done the calculations manually but cannot seem to get any other numbers for the supply or demand for Coal. Is it possible that the Demand > Supply rule only applies to the top 3 commodities in each list? This would also result in both having the same lists.

            Edit:

            I am also having problems with calculating the demand for Gold, Gems, and Silver:

            Special Note: The Demand Quotients for Gems and Gold use the same formula as Silver. The remainder from the division by 3 of the sum of the city's map coordinates determines which commodity the formula is applied to. All cities demand Silver as CitySize x 8, but the Tech modifiers only apply to Silver if the location is 0 mod3. If the location is 1 mod3, the city demands Gems at the full formula rate. If the location is 2 mod3, the city demands Gold at the full formula rate.
            Does this mean that all cities that have a result of 2 will demand Gold and never Silver or Gems, or does this mean that only the modifiers for Chemistry, Economics, and Computers apply to Gold and not to the others? Doe this also apply to the City Improvements?

            My original assumption was that only Gold would be demanded, but I have seen places where this is not the case.

            Also, what happens in the event of a tie between two commodities on either the supply or demand list. Does the tie go to the higher or the lower numbered commodity?

            /Edit:

            Thanks for the help,
            StuporMan
            Attached Files
            Last edited by StuporMan; June 1, 2005, 13:37.
            Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

            StuporMan's Supply and Demand Calculator
            Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

            Comment


            • #7
              When I was helping Samson tests his formulas, city size was the factor most often involved in errors, as I am sure he did not test every formula at every possible size. I am sure many minor errors still exist in the final formulas that he presented. Had he had access to your program, more extensive tests could have been performed more quickly increasing formula accuracy.

              In the case of Susa, I believe part of the demand formula has been presented without a necessary parenthesis:

              Instead of:

              (Distance Equator+10) X (CitySize+2)/5

              I think Samson really meant:

              (Distance Equator+10) X ((CitySize+2)/5)

              Since integer division discards remainders, the added parenthesis makes a difference, in many cases lowering the value of demand enough to give supply the nod when choosing which list coal is to compete on. This certainly makes the difference with Civ II's Susa, which is wanting to supply Coal when your program refuses to.

              Using this adjustment, my hand calculations for city sizes ranging from 7 to 13 agree with lists depicted in Susa.

              So you might try it again using the extra parenthesis.

              During my tests I also noticed a new error in your program when testing it in Susa at size 9. Silver did not appear on either list, and this means it should have been expressed as the supply wildcard. Your program inserts Beads in this spot and omits silver from both lists.

              For tests I made at size 7 and at size 13, your program gave the correct lists.

              On to your other questions:

              1) I agree as a former programmer that "can" is not a very valuable parameter, equally as useful as "almost always"!

              2) If the calculated value for demand equals that of supply for a commodity, it becomes a competitor on the demand list.

              3) Silver always competes as a demand commodity, no matter what the remainder is. With a zero remainder, simply include the tech modifiers when calculating the demand for Silver, and discard Gems and Gold as demand candidates, which only compete when their remainders come up. Since Silver always competes, I like to find cities that supply it.

              4) In cases of a tie, the higher ranking commodity gets the nod. This is why Uranium can beat out Oil as the secondary demand wildcard.

              Comment


              • #8
                Thanks again for the information solo.

                I looked at the program a little before I read your post and came up with two possible solutions to the Susa problem. That either the extra set of parentheses was neccessary or that (CitySize+2)/5 was really supposed to be (CitySize+1)/5. It is good to now be more sure that the parens are the correct solution.

                As to your new problem, if you will notice the wildcard is listed below all of the other information in the Supply and Demand columns. I felt listing them in this way gave the player more information about what was going on in order to make better informed decisions. For instance, Let us say that the Top 3 supply commodities are Dye, Beads, and Coal and that the WildCard is Silver. Due to blocking both Dye and Coal the player may wish to shift the number 2 commodity either up or down so that it will be expressed. This allows the users to predict ahead of time which cities will be demanding the center commodity.

                Edit: I have added a picture to clarify where the wildcard is located.

                One thing I might do for clarity is to move the Wildcard up to the top and also include a finalized list where the wildcard is inserted properly. One reason I did not make a finalized list yet is that I was still unsure as to the status of secondary wildcards, which you have shown me how to handle.

                Finally, thank you for the information on Silver always being demanded. I have read samson's post many times and had not picked up on that yet. It looks like things are finally narrowing in on 100% accuracy. Hopefully there are not too many more bumps in the road.

                StuporMan
                Attached Files
                Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

                StuporMan's Supply and Demand Calculator
                Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

                Comment


                • #9
                  Okay, looks good and I look forward to putting this nifty tool to work in my games. Many thanks for making it!

                  Comment


                  • #10
                    Version .90 Released!

                    Version 0.90 is now released!

                    This version is extremely close to being 100% accurate at calculating supply and demand commodities. And it has some nifty new features as well.

                    Now the calculator will display the exact list the city should have for its supply and demand lists (assuming of course the city has been refreshed via commodity delivery, wonder bread, or solo cycle).

                    It also now computes the secondary wildcards for cities as well. These, however, will only be shown on the Final Supply and Demand Lists.

                    Solo,
                    Thank you for all of your help so far. Progress most certainly would have been much slower had it not been for your guidance.

                    Also, I believe I have found another interesting caveaut to secondary wildcards. If the secondary demand wildcard is expressed in the demand list, it is blocked. This is nothing new. However, if the supply secondary wildcard is expressed in the Demand list, the supply secondary wildcard will be expressed! This may have already been known, but it came as quite a shock to me.

                    Version 0.90 correctly computes this, but I have gone ahead and attached a zip file with the sav file and the supply and demand file for Shanghai (the city in question). As you will see, Oil has 0 supply and yet appears on the Supply list in the WildCard spot. Also note that it appears in the #3 spot for demand. Very interesting indeed.

                    Thanks again,
                    StuporMan
                    Attached Files
                    Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

                    StuporMan's Supply and Demand Calculator
                    Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

                    Comment


                    • #11
                      I like the final (err... latest!) version, which has more information. One thing I noticed was that the value calculated for Uranium's demand was not displayed. Maybe too big for the space allotted?

                      We have known that oil can appear on both lists at once, but had not concluded that secondary wildcards can be expresssed when they appear normally on the other list. In this way their behavior differs from the regular wildcards.

                      I will send Samson a message to let him know about your program. Perhaps he will appear to check it out!
                      Last edited by solo; June 2, 2005, 19:17.

                      Comment


                      • #12
                        Solo,

                        Thanks, I am quite proud of this latest version. I hope this is not the final version as I am hoping to add a few more features to make the calculator even easier to use.

                        Good catch on Uranium's value not appearing. I checked an you were correct, the value was just a little too long to fit in the space. I have uploaded a minor version change that takes care of that issue if you are interested.

                        My next goal with the calculator is to allow the user to track multiple cities simultaneously. Eventually I want to be able to track every city in a game! You can do that now by having multiple save files, but I would like to make this even easier.

                        Another feature I have been kicking around is calculating total beaker costs. Since the calculator, once it can store cities from multiple Civs, will be able to store all the necessary information this would be a simple, yet useful addition to the calculator. This would even allow you to calculate beaker costs for all civilizations, which may prove useful when trying to obtain techs from the AI.

                        Both of these additions will probably take a while to complete, so I will most likely not be updating the calculator for a while, unless an error in calculating the commodities lists is found.

                        Thanks again,
                        StuporMan
                        Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

                        StuporMan's Supply and Demand Calculator
                        Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

                        Comment


                        • #13
                          Don't forget the beakers that come from caravan/freight deliveries... Perhaps the program can calculate them itself given starting and ending cities and a bit of extra data, like existence of key road/rail and wonders/improvements?

                          Comment


                          • #14
                            Yes, let's make it do everything while StuporMan is still in the mood!

                            It's already great, and any extras will just be gravy.

                            Comment


                            • #15
                              Elephant,

                              I am glad to see someone else take an interest in the calculator! As to calculating caravan/frieght deliveries, that would be a nice feature. Unfortunately, it would also require more than a little additional information. It would require adding extra techs, extra improvements, extra flags for road/rail connections, and a place to enter the number of trade arrows for both cities.

                              While this could be done, I do not see me adding this feature for a while. It would just be a bit too much on top of what I am working on already. That doesn't mean I won't consider it for the future though. Maybe 2.0 I will add it to my list of possible future features.

                              Solo,
                              Yes, let's make it do everything while StuporMan is still in the mood!

                              It's already great, and any extras will just be gravy.
                              Thanks for the kind words. Yes this is an excellent time to ask for new features. I still have some free time to work on fun side projects. Unfortunately once summer is over, I will be back to Grad School on top of working full time and my time for fun projects dries up.

                              For non-M$ users,
                              I apologize that this program only runs on windows machines, but I am currently researching ways to make this program platform independant in the future.

                              StuporMan
                              Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

                              StuporMan's Supply and Demand Calculator
                              Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

                              Comment

                              Working...
                              X