Post news RSS Sugarmill : City builder : Dev Log 2: All Products In

The first 3 weeks of full time developing! Routing System, Products, Products Specs, Products Density. Now each product has its real density in KG/m3.

Posted by on

Sugarmill : City builder : Dev Log 2: All Products In


It's been a busy 3 weeks. My last post was 3 weeks ago and I was talking about the 20 weeks I had ahead. Well now I only have 17 weeks for the release. The release day of the Game is May 5th 2015. Obviously the game still has to go through Steam Greenlight.

The last 3 weeks have been crazy we had New Years eve, and the holidays and so on but I still managed to work as much as I could and I accomplished quite a few things.

The Routing system is awesome. It works flawlessly. I'm combining 2 routing systems in one. And it's based on crystals that I place in the terrain. I did some major research on how to do it and evaluated different options at the time. I even created a Reddit Post about it because it was though to do the Routing system nicely and softly on the CPU. Anyways I will further explain myself in a post I will dedicate only to the routing system of the game because I did it from scratch twice and I think the last version is worth a post on its own.

The last week I'm being basically working on finishing all the production and buildings that are left. I added all the products in the game. Also I added to their Density that way I will stack them in the Storage buildings by weight but they will occupy their volume based on the product specific Density.

For each Product I create a price, research their Density, and gave a factor of production

Below find all the products in raw C# code for the ones that like code. Below code is in the Production.cs class

    /// <summary>
    /// Will load the base price of each prod
    /// </summary>
    private void LoadBasePrices()
        _prodSpecs.Add(new ProdSpec(P.Bean, 90, 368, 100));
        _prodSpecs.Add(new ProdSpec(P.CoffeeBean, 100, 308, 100));
        _prodSpecs.Add(new ProdSpec(P.Cacao, 110, 250, 100));
        _prodSpecs.Add(new ProdSpec(P.Bean, 90, 368, 100));
        _prodSpecs.Add(new ProdSpec(P.Potato, 70, 380, 100));
        _prodSpecs.Add(new ProdSpec(P.Banana, 100, 350, 100));
        _prodSpecs.Add(new ProdSpec(P.Coconut, 100, 550, 100));

        _prodSpecs.Add(new ProdSpec(P.Rum, 100, 1000, 100));
        _prodSpecs.Add(new ProdSpec(P.Wine, 100, 990, 100));

        _prodSpecs.Add(new ProdSpec(P.Coal, 20, 180, 70));
        _prodSpecs.Add(new ProdSpec(P.Sulfur, 20, 1960, 70));
        _prodSpecs.Add(new ProdSpec(P.Potassium, 30, 862, 60));

        _prodSpecs.Add(new ProdSpec(P.SugarCane, 50, 200.2f, 100));
        _prodSpecs.Add(new ProdSpec(P.TobaccoLeaf, 50, 300, 90));

        _prodSpecs.Add(new ProdSpec(P.Corn, 60, 540, 120));

        _prodSpecs.Add(new ProdSpec(P.Chicken, 200, 881, 80));
        _prodSpecs.Add(new ProdSpec(P.Egg, 150, 400, 100));
        _prodSpecs.Add(new ProdSpec(P.Pork, 200, 881, 70));
        _prodSpecs.Add(new ProdSpec(P.Beef, 300, 881, 60));

        _prodSpecs.Add(new ProdSpec(P.Fish, 300, 932, 70));
        _prodSpecs.Add(new ProdSpec(P.Chocolate, 300, 600, 70));
        _prodSpecs.Add(new ProdSpec(P.Salt, 30, 900, 85));

        _prodSpecs.Add(new ProdSpec(P.Sugar, 50, 900, 70));

        _prodSpecs.Add(new ProdSpec(P.Tobacco, 200, 600, 90));
        _prodSpecs.Add(new ProdSpec(P.Henequen, 15, 400, 90));
        _prodSpecs.Add(new ProdSpec(P.Cotton, 40, 360, 120));
        _prodSpecs.Add(new ProdSpec(P.Leather, 70, 570, 20));

        _prodSpecs.Add(new ProdSpec(P.Ceramic, 10, 100, 10));//ceramic
        _prodSpecs.Add(new ProdSpec(P.Gold, 500, 19300, 5));
        _prodSpecs.Add(new ProdSpec(P.Diamond, 500, 3539, 5));
        _prodSpecs.Add(new ProdSpec(P.Silver, 450, 10490, 8));
        _prodSpecs.Add(new ProdSpec(P.Jewel, 450, 8490, 8));

        _prodSpecs.Add(new ProdSpec(P.Stone, 50, 2515, 20));
        _prodSpecs.Add(new ProdSpec(P.Ore, 70, 4200, 20));
        _prodSpecs.Add(new ProdSpec(P.Iron, 150, 7874, 15));
        _prodSpecs.Add(new ProdSpec(P.Nail, 200, 4874, 20));//for ship repairs

        _prodSpecs.Add(new ProdSpec(P.CannonBall, 500, 6874, 20));
        _prodSpecs.Add(new ProdSpec(P.Weapon, 150, 5000, 8));
        _prodSpecs.Add(new ProdSpec(P.Sword, 150, 6000, 8));
        _prodSpecs.Add(new ProdSpec(P.Axe, 50, 2500, 10));
        _prodSpecs.Add(new ProdSpec(P.GunPowder, 100, 1281, 60));

        _prodSpecs.Add(new ProdSpec(P.Resin, 10, 30));
        _prodSpecs.Add(new ProdSpec(P.Wood, 10, 500, 90));
        _prodSpecs.Add(new ProdSpec(P.HolyWood, 100, 700, 30));
        _prodSpecs.Add(new ProdSpec(P.Tool, 150, 3000, 15));

        _prodSpecs.Add(new ProdSpec(P.Brick, 50, 2000, 100));
        _prodSpecs.Add(new ProdSpec(P.Tonel, 60, 50, 50));
        _prodSpecs.Add(new ProdSpec(P.Cigar, 200, 700, 50));
        _prodSpecs.Add(new ProdSpec(P.Slat, 40, 600, 70));
        _prodSpecs.Add(new ProdSpec(P.Tile, 60, 2100, 90));

        _prodSpecs.Add(new ProdSpec(P.Fabric, 100, 400, 20));
        _prodSpecs.Add(new ProdSpec(P.Cloth, 120, 380, 20));
        _prodSpecs.Add(new ProdSpec(P.Sail, 150, 200, 15));
        _prodSpecs.Add(new ProdSpec(P.String, 120, 300, 15));

        _prodSpecs.Add(new ProdSpec(P.Paper, 150, 192, 30));
        _prodSpecs.Add(new ProdSpec(P.Books, 300, 500, 5));
        _prodSpecs.Add(new ProdSpec(P.Silk, 150, 1300, 5));

The first number in each row is the price, then the density in KG/m3 and then their production factor that I used to determine how much a person will produce of that product. In the class Profession.cs I'm setting that .

    /// <summary>
    /// Will set the ProdXShift Needs to account on:
    /// Age, School Years, Product to produce now, Genre, Tool
    /// </summary>
    private void SetProdXShift()
        if (_person == null)

        //was set already
        if (ProdXShift > 0)
        var age = AgeFactor();
        var genre = ReturnGenreVal();
        var yearSchool = _person.YearsOfSchool;
        var produceFac = GetProduceFactor();

        //Grown man will prod 4.5KG of wood with 10 year of school
        //              (10 + 10     + 30        + ) * 0.09         = 4.5KG of Wood per shift
        //              (10 + 10     + 30        + ) * 0.008         = 0.4KG of Weapons per shift
        ProdXShift = (age + genre + yearSchool) * produceFac/1000;

The formula is really trivial but I liked it and it made sense to me. As of now when playing the game I have found that all profession are fair. The only unfair one is the amount of work for the Builders, as it is now zero.

This week for the 1st time in a long time I found myself playing the game and enjoying it for a long time. So take that as a good sign. After more than 1 year and a half developing SugarMill it becomes hard to say if is fun or not. And since I have all the shorcuts I can spawn 10, 100 guys or do buidings right away.

All the Volume inventory relationship is done. Now as part of an inventory item, everytime the amount is changed it will recalculate the Volume of the item. Chunk of code from InvItem.cs

    /// <summary>
    /// How many KG of this Item 
    /// Everytime is set.
    /// Will recalculte the Volume
    /// </summary>
    public float Amount
        get { return _amount; }
            _amount = value;
            Volume = Program.gameScene.ExportImport1.CalculateVolume(Key, Amount);

And my GIT client is helping a lot. I have been using GITHub for basically school projects but for the 1st time I have included it in the game and I must say it's really helpful. Especially when you want to look back and see what code was changed in that moment. So I will stress that incorporating GIT in your projects is extremely helpful. Git Hub Client. One of my best teachers always said that not using Version Control was unprofessional. As a result I now love it.

The same teacher also said "as your code changes and your software matures your LOC (lines of code) grows". Mine is now scoring 19 358. I do try to do everything as clean as possible when comes to code. But at the same time it needs to be legible and understandable if you need to get back to any class or method.

Bill Gates says: “Measuring programming progress by lines of code is like measuring aircraft building progress by weight.”

Thanks for reading. Have an awesome day. And Happy New Year to all!

Hope this year brings to you all you deserve and want!


OJeskulke - - 94 comments

Thanks for the update. Glad your routing works fine, can't wait for the details :)
Thats a great idea with the density, if I understand correctly, so if one worker produces 10kg wood, you know how much space this will ocupy? So 10kg of feathers are bad for storage :D

Reply Good karma Bad karma+2 votes
AatlantisCode Author
AatlantisCode - - 27 comments

_prodSpecs.Add(new ProdSpec(P.Wood, 10, 500, 90));
So in 1 cubic meter you can store around 500 KG of wood.
The formula goes:
Vol = mass / density
Vol = 10 kg / 500 kgm3
Vol = 0.02 m3
So yea not a lot. Gold is one of the most dense in one cubic meter you can store like 19 000 kg crazy.

Yea the least dense they are, the more Volume they will occupy in your storage. I came with that idea because I grew up in a Dockers family and work my self in a Dock as an IT guys for a long time. The place was just right across were I lived. In that big dock they always were looking after they storage areas in busy times. Other times the dock was really inactive. I'm just reflecting all that in the game. :)

Reply Good karma+1 vote
OJeskulke - - 94 comments

Thanks for the clarification! Nice how events from our lives enter the games sometimes... :)

Reply Good karma Bad karma+1 vote
AatlantisCode Author
AatlantisCode - - 27 comments

Indeed the event from our lives shapes our games, no doubt. I'm looking for any kind of feedback on the game. I know is too early but I will appreciate all possible feedback when the game is on steam

Reply Good karma+1 vote
OJeskulke - - 94 comments

When I can find the time I will evaluate it and write my findings in detail. I will be very harsh of course, in the interest of the game ;)

Reply Good karma Bad karma+2 votes
AatlantisCode Author
AatlantisCode - - 27 comments

Thanks for that OJeskulke. Will be waiting for it.

Reply Good karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.