Are you, in fact, a pregnant lady who lives in the apartment next door to Superdeath's parents? - Commodore

Create an account  

 
[SPOILERS] AlaePB1 - Furungy & C++

(November 29th, 2013, 17:17)Fintourist Wrote: ...did you have a reason why you did not settle 1 tile north in order to get gold into BFC too.. mischief
The only reason is that it will be too close to the city on desert tile (between two gold tiles). Pro for your placement is early lux resource, but because of future massive whipping I think, that I don't need it right now.
Reply

(November 29th, 2013, 17:22)Qgqqqqq Wrote: So when do you intend to settle for horses/get a galley out?

Great question! It is time to demonstrate my plans for the nearest future. It looks like my CivCalc app will be much helpful for that purpose. Here is a model for 3 nearest Amsterdam turns:
Code:
01 City amsterdamCity;
02 amsterdamCity.setPopulation(4);
03 amsterdamCity.setTiles({
04    Goods(2, 1, 9), // city
05    Goods(5, 0, 3), // fish
06    Goods(4, 2, 1), // cow
07    Goods(5, 1, 1), // wheat
08    Goods(1, 3, 1)  // riverside mine
09 });
10 UserEvents events;
11 events.whipTurn = 0;
12 events.whipCount = 2;
13 amsterdamCity.enqueueBuilding(Building("SETTLER  ", true,  100, 68));
14 amsterdamCity.enqueueBuilding(Building("WORK BOAT", false, 30,  6));
15 amsterdamCity.enqueueBuilding(Building("WARRIOR  ", false, 15));
16 amsterdamCity.enqueueBuilding(Building("WORKER   ", true,  60));
17 amsterdamCity.processBuildingQueue(events);

And the app output is the following:
Code:
T00:     02    00/00/000    07/63/013    SETTLER   (068/100)    WHIP      
T01:     02    00/00/013    07/41/013    SETTLER   (100/100)    COMPLETED
T02:     02    07/00/026    07/20/013    WORK BOAT (030/030)    COMPLETED
T03:     02    14/00/039    07/08/013    WARRIOR   (015/015)    COMPLETED
T04:     02    14/00/052    07/03/013    WORKER    (015/060)

Some comments for code listing:
  • Lines 01-09: City initialization, where I setted up its population and available tiles for working. Tiles ordering is important. The program knows that available tiles count for working is equal to city's population + 1. So after 2pop whip Amsterdam will not work the wheat and riverside mine. They will be move to the Utrecht citizens.
  • Lines 10-12: Events which impact on city's production. The only Amsterdam event is 2pop whip with almost maximum overflow.
  • Lines 13-16: Specifying city's building queue. For Amsterdam it is: SETTLER, WORK BOAT, WARRIOR, WORKER.
Here are Building class parameters:
Code:
Building(const std::string &name, bool eatsFood, uint8_t requiredHammers, uint8_t accumulatedHammers);
  1. name: self explanatory.
  2. eatsFood: specifies, that the program should convert gathered food overflow to hammers.
  3. requiredHammers: amount of hammers which city should gather to complete building.
  4. accumulatedHammers: amount of hammers which are already accumulated for that building.
So in the code above you can see, that SETTER which is building in Amsterdam now requires 100 hammers (68 accumulated already) and forces city to convert food overflow to hammers.
App's output format is the following:
Code:
[TURN NUMBER]: [POP COUNT] [GOODS ACCUMULATED IN THE CITY: F/H/C] [GATHERED GOODS: F/H/C] [PRODUCTION STATUS]

The roadmap for the island settling will be in the next post.
Reply

I said before all my efforts will be concentrated to settle city near the horses. I'll have 3 cities which will separate responsibilities as follows:
  • Amsterdam: SETTLER + WORKER + WARRIOR (city near the horses without a worker is useless).
  • Utrecht: WORK BOAT (city should have improved tile from the beginning).
  • Unknown city near the clam: GALLEY.
The major points, which I take in mind when coordinating their production are:
  • All units should be completed just in time to prevent wasting Settler turns. Galley should arrival to Amsterdam before or at the same turn when the Settler wil be completed.
  • Work boat should build fishing nets for the clam before or at the same turn when the city will be founded.
So, this is my 1st attempt to calculate production with these preconditions.

AMSTERDAM CITY
Code:
T02: 02 00/00/000 07/03/013 WORKER    (015/060)
T03: 02 00/00/013 07/03/013 WORKER    (025/060)
T04: 02 00/00/026 07/03/013 WORKER    (035/060)
T05: 02 00/00/039 07/03/013 WORKER    (045/060)
T06: 02 00/00/052 07/03/013 WORKER    (055/060)
T07: 02 00/00/065 07/08/013 WORKER    (060/060) COMPLETED  - WILL BUILD MINE
T08: 02 07/00/078 07/03/013 WARRIOR   (008/015)
T09: 02 14/00/091 07/03/013 WARRIOR   (011/015)
T10: 02 21/00/104 07/03/013 WARRIOR   (014/015)
T11: 03 04/00/117 06/08/013 WARRIOR   (015/015) COMPLETED  
T12: 03 04/00/130 06/06/013 SETTLER   (014/100)
T13: 03 04/00/143 06/06/013 SETTLER   (026/100)
T14: 03 04/00/156 06/06/013 SETTLER   (038/100)
T15: 03 04/00/169 06/06/013 SETTLER   (050/100)
T16: 03 04/00/182 06/26/013 SETTLER   (062/100) CHOP      
T17: 02 04/00/195 07/33/013 SETTLER   (094/100) WHIP      
T18: 02 04/00/208 07/37/013 SETTLER   (100/100) COMPLETED  
T19: 02 04/00/221 07/03/013 WORKER    (044/060)
T20: 02 04/00/234 07/03/013 WORKER    (054/060)
T21: 02 04/00/247 07/07/013 WORKER    (060/060) COMPLETED
T07: WORKER COMPLETED
T11: WARRIOR COMPLETED
T18: SETTLER COMPLETED

UTRECHT CITY
Code:
T00: 01 06/00/000 05/02/002 WORK BOAT (002/010)
T01: 01 11/00/002 05/02/002 WORK BOAT (004/010)
T02: 01 16/00/004 05/02/002 WORK BOAT (006/010)
T03: 01 21/00/006 05/02/002 WORK BOAT (008/010)
T04: 02 04/00/008 04/05/003 WORK BOAT (010/010) SUSPENDED  
T05: 02 04/00/011 04/05/003 WORKER    (009/060)
T06: 02 04/00/014 04/05/003 WORKER    (018/060)
T07: 02 04/00/017 04/05/003 WORKER    (027/060)
T08: 01 04/00/020 05/32/002 WORKER    (036/060) WHIP      
T09: 01 04/00/022 05/15/002 WORKER    (060/060) COMPLETED  
T10: 01 09/00/024 05/02/002 WORK BOAT (025/030) RESUMED
T11: 01 14/00/026 05/02/002 WORK BOAT (027/030)
T12: 01 19/00/028 05/02/002 WORK BOAT (029/030)
T13: 02 02/00/030 04/06/003 WORK BOAT (030/030) COMPLETED
T17: WORK BOAT CLAM ARRIVAL

UNKNOWN CITY
Code:
T04:     01    00/00/000    04/21/004    GALLEY    (000/050)    CHOP      
T05:     01    04/00/004    04/01/004    GALLEY    (021/050)
T06:     01    08/00/008    04/01/004    GALLEY    (022/050)
T07:     01    12/00/012    04/01/004    GALLEY    (023/050)
T08:     01    16/00/016    04/01/004    GALLEY    (024/050)
T09:     01    20/00/020    04/01/004    GALLEY    (025/050)
T10:     02    02/00/024    03/06/004    GALLEY    (026/050)
T11:     02    05/00/028    03/06/004    GALLEY    (032/050)
T12:     02    08/00/032    03/06/004    GALLEY    (038/050)
T13:     02    11/00/036    03/06/004    GALLEY    (044/050)
T14:     02    14/00/040    03/06/004    GALLEY    (050/050)    COMPLETED
T15:     01    17/00/044    04/31/004    WORK BOAT (006/030)    WHIP      
T16:     01    21/00/048    04/08/004    WORK BOAT (030/030)    COMPLETED
T17: GALLEY AMSTERDAM ARRIVAL
Reply

(November 29th, 2013, 17:11)BRickAstley Wrote: I see on the scoreboard you've met Alexander, who/where is he?
You can see his purple borders on the NE corner of the minimap.
Reply

Very interesting thread! I've thought about doing something similar, where input is a city state, happy cap, what tiles it has available, and what it should build. (Along with anything else pertinent). And output would be:
- What tiles to work on any given turn to make it happen most optimally, including trading off growth vs production.
- When is best to whip (and maybe even chop). This needs take into account happy cap and also the lost population into the future.
- How many worker turns of input the city needs to make this plan happen, on which turns, for tile improvements and maybe roads and chops.

The devil is always in the details.

Problems are:
- A spreadsheet is already pretty good for some of this. It's not obvious to see where an arbitrary program can be more valuable.
- To actually calculate optimal choices, you could implement something a human could do easily (e.g. some greedy algorithm) or else something that would be computationally intractable (try every combination of working every tile set across every turn, pick the best). It's not easy to see if there's a point in between these two extremes where the computer program could be valuable and maybe even make discoveries.
- There are always going to be extra variables that aren't modeled, and the trouble is that these often end up being the dominating factor for decision making in an actual game. E.g. cities that share tiles, military needs that change extremely quickly, a need to shift gears often.

Is the choice of C++ because you're comfortable with it, or because you think you'll actually need some serious computation power? I'm extremely interested if the latter.
Reply

(November 30th, 2013, 12:58)WilliamLP Wrote: ...
Is the choice of C++ because you're comfortable with it, or because you think you'll actually need some serious computation power? I'm extremely interested if the latter.
...

Thanks for reading, WilliamLP. I'm reading your detailed thread in PB13 too. Good luck you there.
There are several reasons, why C++:
  1. As you correctly assumed C++ is my primary programming language, so I can grow my app very quickly. It took me one evening to make the first version which calculates production turns and takes in mind population and such user events as chop, revolution, whip and its impact on a happy cap.
  2. C++ language is object-oriented language and that is why it is very easily to model complex domains with it.
  3. C++ is a cross-platform language. Now I use the app on both MacBook and Windows PC. At the same time I'm familiar with iOS programming, so when it will make sense I can adopt CivCalc for iPhone to make calculations and validate my latest ideas on the go.
  4. C++ is the best language for computation intensive algorithms.
Totally agree with you about the output which will be nice to have. I'm thinking in that direction, but first of all I need to build the precise domain model. So in that game even micro decisions are mine, the app only helps me to calculate different variants very quickly.
Reply

Some thoughts about my galley... I think it will bring much fun to the game. I did notice that human players hate to research Sailing. Even those who do this, prefer to delay this tech as much as they can. So I'm 99% sure, that my galley will be the only military naval unit in the World. The whole World will be open for pillaging water resources! First of all we'll see who is that unlucky guy in the East, which shares with me my continent.
Reply

T39 demos after 2pop whip.


Reply

...and the map


Reply

The game is paused for MYKI now, so nothing new there. At the same time my app keeps growing and I'd like to demonstrate its last features. The most important ones are the following:
  • Unlimited number user actions during the simulating period.
  • Modification of tiles income and their ordering during the simulating period.
  • Suspending and resuming builds in the city's queue.
  • Automatic calculation of whip population cost.
Below you can see, how all that look like. I don't remember current state of Utrecht City, so let's suppose, that all parameters are at zero progress:
Code:
01 City utrechtCity;
02 utrechtCity.setTiles({
03     Tile::create(2, 1, 1), // city
04     Tile::create(5, 1, 1), // wheat
05     Tile::create(1, 3, 1), // riverside mine
06     Tile::create(3, 0, 0)  // cows
07 });
08 utrechtCity.pushBuilding(Building::workBoat());
09 utrechtCity.pushBuilding(Building::axeman());
10 ActionQueue actionQueue;
11 actionQueue.pushAction(5, AnyAction::create([](City &city, Goods &turnGoods) {
12     city.setTopBuilding(Building::worker());
13 }));
14 actionQueue.pushAction(14, AnyAction::create([](City &city, Goods &turnGoods) {
15     city.tileAt(3)->setGoods(Goods(4, 2, 0));
16     city.swapTiles(2, 3);
17 }));
18 actionQueue.pushAction(9, WhipAction::create());
19 utrechtCity.processBuildingQueue(0, actionQueue);

So the city starts with work boat and an axeman in its building queue (lines 08-09). At turn 5 we insert a worker as actual building (lines 11-12), work boat will be suspended. At turn 14 the tile with cows will be improved with pasture (line 15) and it will be worked instead of tile with riverside mine (line 16). Line 19 simulates city's production.
Code:
T00:    01    00/00/000    05/02/002    WORK BOAT (000/030)    
T01:    01    05/00/002    05/02/002    WORK BOAT (002/030)    
T02:    01    10/00/004    05/02/002    WORK BOAT (004/030)    
T03:    01    15/00/006    05/02/002    WORK BOAT (006/030)    
T04:    01    20/00/008    05/02/002    WORK BOAT (008/030)    
T05:    02    03/00/010    04/05/003    WORKER    (000/060)    WORK BOAT (010/030)    
T06:    02    03/00/013    04/05/003    WORKER    (009/060)    WORK BOAT (010/030)    
T07:    02    03/00/016    04/05/003    WORKER    (018/060)    WORK BOAT (010/030)    
T08:    02    03/00/019    04/05/003    WORKER    (027/060)    WORK BOAT (010/030)    
T09:    01    03/30/022    05/02/002    WORKER    (036/060)    WORK BOAT (010/030)    WHIP (1)
T10:    01    03/13/024    05/02/002    WORKER    (060/060)*   WORK BOAT (010/030)    
T11:    01    08/00/026    05/02/002    WORK BOAT (025/030)    
T12:    01    13/00/028    05/02/002    WORK BOAT (027/030)    
T13:    01    18/00/030    05/02/002    WORK BOAT (029/030)    
T14:    02    01/01/032    07/04/002    WORK BOAT (030/030)*  
T15:    02    08/00/034    07/04/002    AXEMAN    (005/035)    
...

All bug reports are much appreciated : )
Reply



Forum Jump: