Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#Actualwodinoneeye

Posted 26 August 2013 - 07:09 AM

The way I approached this problem is by having AI workers calculate the paths to all work opportunities, calculate the time it takes to get there, calculate the amount of time they could spend working there (spending their labour power, a resource like any other, used in transforming raw material into goods), how much they would get for the time spent, and comparing the options, choosing the most profitable (net profit over time). There need to be lots of competing work opportunities though for it to work and lots of buildings of the same type for competition to work. This is pathfinding-intensive and requires a modern computer. This makes it poor for mobile platforms or MMO. A problem is that it's hard to balance so that the entire economy doesn't break down. You might choose to implement it differently, but the way I made workers regain their labour power is by resting at apartments (which they pay rent for, forming a complete loop in the circulation of money). They also need to buy food at a certain rate to survive, another part of the loop.

 

https://github.com/polyf/corpstates/blob/master/labourer.cpp

https://github.com/polyf/corpstates/blob/master/job.cpp

https://github.com/polyf/corpstates/blob/master/transportation.cpp

https://github.com/polyf/corpstates/blob/master/transportation.h

 

I recall a game named Children oif the Nile  (an ancient egyptian game) which had a severe problem (and lack of a competant designer/programmer aparently ) where the workers were generated by placing houses on the map which attracted immigrants which then sought available work  -- you also placed various workplaces (effectively factories) on the map to provide those jobs.     Unfortunately the workers got locked into whatever job the first assigned themselves to and would waste huge amounts of time crossing the map  (some taking all day and then walking home without doing much of a work period) when similar work positions were nearby.    New housing placed adjacent to the factory went unused or attracted workers  which also often went across the whole map to work.  There were even administrative functionals who should have had the job to organize/straighten things out  but they were just as logic-less.

 

Dynamiting the housing and rebuilding was the only way to force it to fix itself.    Obtaining sustinance materials from support shops/temples etc customers were assigned the same dim way (wasting huge amounts of time getting supplies from across the city map when there was the same shop immediately nearby they never went to).   It was one of those city building games and you often added additional facilities (with a limited budget) in many places which the unit logic had a too simplistic a mechanism to handle units choices.  Building the facilities (factories houses/whatever ITSELF required materials and workers which had the same cluesless work assignment logic).

 

Consumers and shops similar dim scheme instead with a unit walking over to a distant shop and finding it empty walked all the way back even passing and ignoring the same kind of shop with the goods it needed (passed on the way TO that distant shop..)  

 

Rocket science for that company  would have had units walking home from Work which passed shops when there is an outstanding  buying list of needs/services and taking the opportunity to buy the stuff (thus double using the transportation time).

 

Anyway I explained on their forum a way to make this less idiotic (my line was if I was pharaoh and had overseers run their projects this way I would have had them executed)  by sorting the workers (if doing same jobs - some were huge projects with many different worksites) and assigning the ones with the nearest home to work paths first and filling jobs-unit matchups  that way from there.    Similar matchup for goods consumers and sources (shortest paths assigned as priority ).     Then closer placement by player would actually work (as planned) without bizaare illogical behaviors.

 

I understood that this might be a processing intensive calculation (for a semi real time game) but mentioned that the reassignments probably only needed to be done periodicly (to rematch a mutating cityscape) and possibly could be done in sub-parts for the different (independant) source-customer arrangements.   Once assigned, the units would keep those assignements unless something changed  (customer gone or source gone)  when the simplistic assignment method could temporarily be used until the next  'smart' reassignment cycle.

 

They never did fix it and left the game in a frustrating state where the player would often wonder why certain projects never got done as fast as they should have and various units were suffering (and wouldnt develope/advance) because they never got their quotas of needed goods/services.


#1wodinoneeye

Posted 26 August 2013 - 06:52 AM

The way I approached this problem is by having AI workers calculate the paths to all work opportunities, calculate the time it takes to get there, calculate the amount of time they could spend working there (spending their labour power, a resource like any other, used in transforming raw material into goods), how much they would get for the time spent, and comparing the options, choosing the most profitable (net profit over time). There need to be lots of competing work opportunities though for it to work and lots of buildings of the same type for competition to work. This is pathfinding-intensive and requires a modern computer. This makes it poor for mobile platforms or MMO. A problem is that it's hard to balance so that the entire economy doesn't break down. You might choose to implement it differently, but the way I made workers regain their labour power is by resting at apartments (which they pay rent for, forming a complete loop in the circulation of money). They also need to buy food at a certain rate to survive, another part of the loop.

 

https://github.com/polyf/corpstates/blob/master/labourer.cpp

https://github.com/polyf/corpstates/blob/master/job.cpp

https://github.com/polyf/corpstates/blob/master/transportation.cpp

https://github.com/polyf/corpstates/blob/master/transportation.h

 

I recall a game named Children oif the Nile  (an ancient egyptian game) which had a sever problem (and lack of competant designer/programmer) where the workers were generated by placing houses on the map which attracted immigrants which then sought available work  (you placed various workplaces (effectively factories) on the map to provide those jobs.  Unfortunately the workers got locked into whatever job the first assigned themselves to and would waste huge amounts of time crossing the map  (some taking all day and then walking home without doing much of a work period) when other work was nearby.    New housing placed adjacent to the factory went unused or attracted workers  which also often went across the map to work.  There were even administrative functionals who should have had the job to straighten things out  but they were just as logicless.

Dynamiting the housing and rebuilding was the only way to force it to fix itself.    Obtaining living materials from upport shops/temples etc customers were assigned the same dim way (wasting huge amounts of time getting supplies from across the map when there was the same shop nearby)

 

Anyway I explained on their forum a way to make this less idiotic (my line was if I was pharaoh and had overseers run their projects this way I would have had them executed)  by sorting the workers (doing same jobs - some were huge projects with many different worksites) and assigning the ones with the nearest home to work paths first and filling jobs that way from there.

 

I understood that this might be a processing intensive calculation (for a semi real time game) but mentioned that the reassignments probably only needed to be done periodicly and possibly could be done in parts for the different source-customer arrangements.   Once assigned the units would keep those assignements unless something changed  (customer gone or source gone)  when the simple method could temporarily be used until the next  reassignment cycle.

 

They never did fix it and left the game in a frustrating state where the player would often wonder why certain projects never got done as fast as thery should have and various units were suffering (and wouldnt develope/advance) because they never got their quotas of needed goods/services.


PARTNERS