Now I was thinking maybe I'd code a market

Need help testing contributed art or code or having trouble getting your newest additions into game compatible format? Confused by changes to data formats? Reading through source and wondering what the developers were thinking when they wrote something? Need "how-to" style guidance for messing with VS internals? This is probably the right forum.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

So , my opinion :

A good starting point to setup a virtual industry .
It's less some maths applied to a strategy ( i don't think low level maths are used here ), but a kind of framework , made dynamic , like a 3d engine , you have a tick() fonction
that can ba called per rendering frame . ( Same apply for a physics engine ) .

I like this design :
void Economy::tick() {
for (std::vector<Base>::iterator iter = this->bases.begin();
iter != this->bases.end(); ++iter) {
iter->Process();
}
}
Each tick then executes for each bases in the economy :
void Base::Process() {
for (std::vector<Factory>::iterator iter = this->factories.begin();
iter != this->factories.end(); ++iter) {
iter->Produce(this->cargoStore);
}
}
Each factory of one base is updated :
void Factory::Produce(Cargo& cargoStore) const {
if (!this->canProduce(cargoStore)) {
return;
}
this->productionPlan->Produce(cargoStore);
}
So at the bottom of the industry , we have a factory that use a productionPlan
to produce a cargo .

:!: Cargo is something that i would better define in the actual API . :!:
It seem that Cargo and CargoHolder are just the same :
/** A collection of individual amounts of different CargoType's.
* This class should represent any random pile of stuff an entity
* (player, ship, base) happens to have.
*/

class Cargo {
public:
/** Create an empty Cargo container */
Cargo();
...
...
It's confusing , and i plan to change that in
class CargoContainer:public Cargo
Because say i have a cargotype of ganja :
CargoType ganja("Ganja","Contraband",10,25,1);
My cargo will be only ganja ( my brother' cargo is already rhum ) .
My brother asked me to deliver some rhum barrels in the moon's station .
mmm...ok but ...

What is the container for my 2 different cargos ?
Cargo contrabandcargo;
contrabandcargo.addCargo(ganja,myvesselCapacity-thespacefortherhum);
contrabandcargo.addCargo(rhum,thespacefortherhum);
Actually , Cargo is used as container .
So i will load cargos in my Cargo ...
I would have prefered to load my cargos in one or more Containers :
Container contrabandcargo;
But i just realized that i can now simply rename :
Cargo Container;
I suppose it's the way intended to be used .
:wink:

:idea:
Economy is at the top of the system , in Vegastrike i would use it like it :
Economy * ConfedEconomy ;//general faction economy
Economy * AeraEconomy ;//general faction economy
...
...
This way , simple comparaisons could be done :
if(Gross_national_product (ConfedEconomy ) < Gross_national_product (AeraEconomy ))
printf(" YOU LOOSE THE ECONOMICAL CAMPAIGN ! " );

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

:idea: One asked how to introduce this market api in vega strike .
I can describe the simple way :

We will use for this example only one Economy object , that will represent the
economy of the game .

In the main.cpp of vegastrike , we have:
...
...
/*
* Globals
*/
Universe *_Universe;
At the root , it's just an other class object .
But it's also the object that is updated each frame ...
We will try to use it , when he update himself .

The initialisation would occur in the main() fonction , and that is precisely where the
GameUniverse is actually created :
_Universe = new GameUniverse( argc, argv, vs_config->getVariable( "general", "galaxy", "milky_way.xml" ).c_str() );
_Universe->Loop( bootstrap_first_loop );
GameUniverse is already used to initialise game objects , like StarSystem :
StarSystem* GameUniverse::Init( string systemfile, const Vector &centr, const string planetname )
{
static bool js = true;
if (js) {
js = false;
LoadWeapons( VSFileSystem::weapon_list.c_str() );
CacheJumpStar( false );
}
return this->Universe::Init( systemfile, centr, planetname );
}
We see that it's the Universe class that is responsible for the initialisation of gameobjects : ( universe_generic.h )
...
///currently only 1 star system is stored
std::vector< StarSystem* >active_star_system;
...
///Should load the Universe data file. Now just inits system with test.xml
virtual class StarSystem * Init( string systemfile, const Vector &centroid = Vector( 0,
0,
0 ), const string planetname = string() );
Following that exemple , i would add to this class :

// As i said simple example :
Economy*active_Market_system;
virtual class Economy* InitMarket( string Marketfile) ;
That will allow ( because of GameUniverse inherit from Universe ) :
Economy* GameUniverse::InitMarket(( string Marketfile)
{

//initialisation by reading xml file
...
return active_Market_system;
}
So now , GameUniverse is responsible for the updates .
These updates occurs at frame level in main_loop.cpp :
void main_loop()
{
//Evaluate number of loops per second each XX loops
if (loop_count == 500) {
last_check = cur_check;
cur_check = getNewTime();
if (last_check != 1) {
//Time to update test
avg_loop = ( (nb_checks-1)*avg_loop+( loop_count/(cur_check-last_check) ) )/(nb_checks);
nb_checks = nb_checks+1;
}
loop_count = -1;
}
loop_count++;

//Execute DJ script
Music::MuzakCycle();
_Universe->active_Market_system->Tick(); //Market tick that update all bases ... :wink:
_Universe->StartDraw();
if (myterrain)
myterrain->AdjustTerrain( _Universe->activeStarSystem() );
if (Network != NULL)
for (size_t jj = 0; jj < _Universe->numPlayers(); jj++)
Network[jj].checkMsg( NULL );

#ifndef NO_GFX
VSFileSystem::vs_dprintf(3, "Drawn %d vertices in %d batches\n",
gl_vertices_this_frame,
gl_batches_this_frame);
gl_vertices_this_frame = 0;
gl_batches_this_frame = 0;
#endif

//Commit audio scene status to renderer
if (g_game.sound_enabled)
Audio::SceneManager::getSingleton()->commit();
}

That was the simple way .

The hardcore way is to use the Governor class of the Market as an AI agent ,
and the Market as a Finite state machine .
check how was designed initially the governor :
Governor

A base is ruled by a Governor which is in charge of making sure a sane amount of goods is available. The governor is to be responsible for deciding how many or which goods are to be produced in a particular factory, though initial factories may use a function choosing a default production option. Still, Initially this governer is to call these functions and give the factories access to the correct cargo.
A FSM ( finite state machine ) would be simple to equilibrate , using states :
class weneedmorefactories : public State ;
class weneedmoremoney : public State ;
class economyisgood : public State ;
class economyisbad : public State ;
etc ...

each derived state has 3 methods :
_OnEnter()
_Update()
_OnExit()

Imagine the actual Governer state ( the state of the Market's FSM ) is economyisgood .
The _Update() is called each frame ( possibly i mean , could be driven by the perf counter option ; like the atom ...)
economyisgood::update ()
{
//make money
...
//check if enough money
if(mycash<enough )
ChangeState(weneedmoremoney);
}
ChangeState(weneedmoremoney) will call first economyisgood::OnExit() , where for example we could display a panel to advertise the player for that event .

But to keep the things simple , i'll work first with the single Economy* , then
vectors of Economy * ( yeah , one * per faction )

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

:!: I made my first little console program with the market api .
The program demonstrate how the economy class works , using a base on earth
and a base on the moon .

I have made a new version of the vc9 solution for this market , including the code
that follows . New version ( windows ) : http://spacetechs.free.fr/VEGASTRIKEDEV ... rketVS.rar
The executable is in NidoMarket\Release
If you have downloaded my previous vc9 solution release , you can replace the content
of VSMarket.cpp by this code :

Code: Select all

// VSmarket.cpp : Defines the entry point for the console application.
//
#include<windows.h> //for sleep()
#include "stdafx.h"
#include <string.h>
#include <cstdio>


#include "Base.hpp"
#include "Cargo.hpp"
#include "CargoType.hpp"
#include "Economy.hpp"
#include "Factory.hpp"
#include "MPLParse.hpp"
#include "ProductionOption.hpp"
#include "XMLNode.hpp"



int _tmain(int argc, _TCHAR* argv[])
{
//create economy
Economy globalEco;

//create our bases
Base earthbase;
Base moonbase;
//create the factory
Factory earthFactory;

//define cargo type
CargoType ganja("Ganja","Contraband",10,25,1);

//define a cargoHolder for the base
Cargo earthbaseCargoHolder;
Cargo contrabandcargo;
Cargo ganjacargo;

//add cargo
contrabandcargo.addCargo(ganja,1);
ganjacargo.addCargo(ganja,10);
contrabandcargo.addCargo(ganjacargo);

//set up the ganja industry
//option input,output
ProductionOption earthProdOptGanja(ganjacargo,contrabandcargo);

//add option to factory
earthFactory.addProductionOption(earthProdOptGanja);
earthFactory.setProductionOption(earthProdOptGanja);

//add baseto global economy
globalEco.addBase(earthbase);
globalEco.addBase(moonbase);
//add storecargo
earthbase.addCargo(contrabandcargo);
//link factory
earthbase.addFactory(earthFactory);

bool quit=false;
int distanceToMoon=200;//384400;
while(!quit)
{
//update the market engine
globalEco.tick();
//decoration...
if(distanceToMoon==200)
  {
   printf("\nEarth Base Factory production =\n%s\n",earthbase.getCargo().getXML().c_str());
   printf("\nQuantity of cargo = %i",earthbase.getCargo().getCount(ganja));
   printf("\n\n***  Vessel launched to moon *** \n");
  }
  
Sleep(100);// gameplay eh eh
printf(".");// movement of the vessel
distanceToMoon--;

if(distanceToMoon==0)
 {
 //remove cargo from vessel
 printf("\n\n*** Vessel has landed on the Moon Base ***\n");
 printf("\n-Unload of the Vessel started \n");
 //decoration ...
 for(int i=0;i<20;i++)
 {printf(".");Sleep(100);}
 moonbase.addCargo(earthbase.getCargo());
 //empty the vessel
 earthbase.delCargo(earthbase.getCargo());
 printf("\n-Ganja quantity delivered to moon : %i\n",moonbase.getCargo().getCount(ganja));
 //check for vessel room
 printf("-Cargo remaining in Vessel : %i \n",earthbase.getCargo().getCount(ganja));
 quit=true;
 }
}
return 0;
}

The resulting console :
Image

That simple program is enough to feel what part of the API need to be improved .
What is really missing is the existence of states , for example in the factory class :

The factory consumes in input some products , and produce in output other products .
But actually , the factory will make x products using a predefined cargo quantity in input.
And each tick() , or turn if you prefer , all the production cycle is done .
Without reporting that the production is stopped because you don't have enough cargo
in input .

So i think that this API should also generate events , and even manage states , to be
autonomous .

And also , give more option to the factory work , like how many input quantity for how many outpout quantity , with time of units production too .
( say , if the engine is running at 1frame by second , in how many frames one unit of
product will be ready for the Market place ... )

The governor class is not yet implemented , i will use it as an AI agent , with the Market
as a FSM .

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

I started to implement a finite state machine , using the example provided in ai-junkie.com :
http://www.ai-junkie.com/architecture/s ... tate1.html

But i also started to search where to link the Market lib with the actual source code .
My goal is to keep a constant logic , and try to use the logic in Vegastrike that is already
in use . ( i won't debate here about the overall logic in vs code and script , but for example , the Cargo class is defined in a file named " images.h " ... :roll: )

So , there is already in the vs source code a class named Cargo .
That suggest the future use of a namespace for the Market lib .
But also , it could be an interesting insert point for our market's base object .

The Cargo class in VegaStrike is declared like this ( complete doc here -> http://spacetechs.free.fr/VEGASTRIKEDEV ... cargo.html ) :
Cargo ()

Cargo (std::string name, std::string cc, float pp, int qq, float mm, float vv, float func, float maxfunc)

Cargo (std::string name, std::string cc, float pp, int qq, float mm, float vv)

float GetFunctionality ()

float GetMaxFunctionality ()

void SetFunctionality (float func)

void SetMaxFunctionality (float func)

void SetMissionFlag (bool flag)

void SetPrice (float price)

void SetMass (float mass)

void SetVolume (float vol)

void SetQuantity (int quantity)

void SetContent (const std::string &content)

void SetCategory (const std::string &category)

bool GetMissionFlag () const

const std::string & GetCategory () const

const std::string & GetContent () const

const std::string & GetDescription () const

std::string GetCategoryPython ()

std::string GetContentPython ()

std::string GetDescriptionPython ()

int GetQuantity () const

float GetVolume () const

float GetMass () const

float GetPrice () const

bool operator== (const Cargo &other) const

bool operator< (const Cargo &other) const
while in market lib , cargo is :
class Cargo {
public:
/** Create an empty Cargo container */
Cargo();

/** deconstructor */
~Cargo();

/** Add quantity cargo of type to this Cargo
* @param type reference to the CargoType to add
* @param quantity the amount of cargo to add
*/
void addCargo(const CargoType& type, const unsigned int quantity);

/** Add newCargo to the cargohold
* @param newCargo reference to another cargo to add.
*/
void addCargo(const Cargo& newCargo);

/** Removes cargo from this Cargo
* TODO: replace return with exceptions
* @param newCargo reference to the Cargo to remove.
* @return true when successfull, false on failure
*/
bool delCargo(const Cargo& newCargo);

/** Counts the amount of Caargo::const_iterator
* @param type reference to the CargoType to find
* @return the amount of CargoType in this Cargo
*/
unsigned int getCount(const CargoType& type) const;

/** check if the content of newCargo is in this Cargo
* @param newCargo Cargo that we wish to check for
* @return true if newCargo is in this Cargo, false on failure
*/
bool contains(const Cargo& newCargo) const;

/** Compare one cargo to another
* @param that reference to the other cargo
* @return true when this and that are equal, false otherwise
*/
bool operator==(const Cargo& that) const;

/** XML representation of this Cargo
* @return XML compliant string representing this Cargo */
std::string getXML() const;

/** String representation of this Cargo
* @by ezee */
std::string Cargo::getName() const ;

private:
/** Iterator datastructure iterator */
typedef std::map<CargoType, unsigned int>::iterator iterator;

/** Iterator datastructure const iterator */
typedef std::map<CargoType, unsigned int>::const_iterator
const_iterator;

/** const Begin of the Cargo datastructure
* @return const iterator to the begin of cargo */
const_iterator begin() const;

/** const End of the Cargo datastructure
* @return const iterator to the end of cargo */
const_iterator end() const;

/** Begin of the Cargo datastructure
* @return iterator to the begin of cargo */
iterator begin();

/** End of the Cargo datastructure
* @return iterator to the end of cargo */
iterator end();

/** The datastructure holding the actual cargo itself. */
std::map<CargoType, unsigned int> cargo;
};

#endif //H_CARGO
The two classes share some attributes , so my question is :
Is it possible to merge the two classes , using c++ inheritance ?

And after looking to the header file of the VegaStrike Cargo class , we are lucky to don't
have extra dependencies linked to it .

My etude shows that the includes in image.h could even serve the Market lib , by adding
animation , sprite etc ... to the base class :
#include <string>
#include <vector>
#include "gfx/vec.h"
#include "container.h"
#include "../SharedPool.h"
#include "gfx/sprite.h"
#include "gfx/animation.h"
I think we should attempt to make Market Cargo inherit from VS Cargo , thus making
market cargo accessible in the VS source code , as a normal VS Cargo .
The benefits should be to inherit the VS behavior of the class , + our internal economy
engine .

That's a path to explore ...

Edit : Now i wonder if it would be better to make Market lib ancestor of all base,cargo from VS . Doing that , we don't have to link to vs for compile the market .
And Vs will inherit of all Market new functions .

Anyway , i just created a Git repository for my version of this Market lib :
https://github.com/Ezeer/Vegastrike_Market

This way , all my changes will be visible etc ...

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

Hello ezee.

I must say I am quite impressed with what you have produced. I have only seen the code on the forum (haven't downloaded it yet), but I am happy to see you have use for my code. Here are a few comments which may help you on your quest.
I am trying to port your code in a visualstudio9 solution .
I am glad you have succeeded with your efforts, since it produced results, but I would like to suggest you take a look at CMake. CMake is capable of creating vs9 solution files which you can use in your IDE, and also the system used by vegastrike proper. http://www.cmake.org/cmake/help/runningcmake.html may help you on your way. I am also eager to know about any problems it gives on windows, since that is a platform I haven't used in a development sense in a while.

On that note, Also thank you for posting your changes. They are most informative and will help me maintain platform independence in future code I write.
#ifdef WIN32
float cargoMass = atof(this->attributes["mass"].c_str());
strtof is a c++11 function which outputs a float, atof returns a double but works on pre-c++11 code. If this is the only c++11 function in use and/or c++11 code is a problem, I suggest we change the code to the atof version for both win32 and non-win32 platforms.
:!: Cargo is something that i would better define in the actual API . :!:
I am not really sure where you got CargoHolder from, since I do not find it in the code i have here present, but let me tell you the history of Cargo.

"Cargo" started its life as vegastrikes Cargo class. Aside from the not-economy junk, it represented an amount of one thing. So it is 1 ganja, or it is 10 ganja, or 3 rhum; but not 1 ganja and 3 rhum. Also, all this not-economy junk about what exactly a ganja is would have been carries with all the amounts of ganja in the galaxy, which sizewise, was a lot. Hence i moved most of that stuff over to cargotype, since, a ganja's a ganja's a ganja. who cares which, which left cargo being an int, and a pointer of sorts to that other class.

The concept 'Cargo', to me, has the idea of "a bunch of stuff". this stuff is not necesarily anywhere specific, but can be any amount of any amount of goods. Gamewise, this would also allow to keep track of mission cargo, by having it in its own virtual container, rather then piled together with the rest of your junk (even though it is really still all lumped together in this virtual reality. Hence I brought in the datastructure to include some of anything. Basically is just a pimped out STL template.
But i just realized that i can now simply rename: Cargo Container;
I would have no problem with that. The code may already be too far gone from the vegastrike Cargo that integrating them will be difficult regardless of my planned efforts.

Economy is at the top of the system , in Vegastrike i would use it like it :
Economy * ConfedEconomy ;//general faction economy
Economy * AeraEconomy ;//general faction economy
Personally I was thinking about one global economy in order to escape the probability of having a cargo run through two economies. Who controls which resource is determined by whoes governor controls which planet/ship/othercargocontainer. The economical comparion example you gave can then still be done by keeping a list of governours per faction, and have them do the counting... Maybe they can even 'lie' if they are desperate enough or otherwise persuaded (not something i think for the near future, but one can dream).

Though it is probably because it is a 'quick example', but I'd advice aside further explicitly defining the factions in code. There are already a few vegastrike mods and having them needing to change that all in-code is a tedious process. Regardless of how the economies are defined though, you can certainly still have individual economies.


I lack a quote for this one, but you mentioned the idea of running the economy clock once a frame or once per second. Though the current economy simulation can easily provide that, even with multidigit numbers in the bigtest one, I myself was more thinking along the line of once per minute, or longer. In vegastrike, you easily spend more time then that in space, so it seems wasted resources to me to simulate at that speed whilst it is not interacted with. Besides, the merchant doesn't get his shipments one bullet at the time either.
The hardcore way is to use the Governor class of the Market as an AI agent
Hot damn. I am very impressed. What i came up with was something that periodically checked how much resources were available and activate the first factory that could provide something when it needed it. Yours is quite a lot more sophisticated.

The idea of the governor class is to have multiple possible systems around. One can divide by faction, planet, randomly, or some other factor. These governers would indeed need to know the concept of credits and be able to send messages to eachother that they need good x or y for some reason (e.g., governator realises not much mining can be done on a starbase, so you need to get stones from elsewhere).

The factories (or rather, the cargoes, bubbling up through the factories) can definitely emit events when unable to do production, though I am not sure whether the governor be the one alerted to it. I have not much experience in c++ so I decided to stay away from exceptions for the time being, as their specifics were not very familiar to me.
I think we should attempt to make Market Cargo inherit from VS Cargo , thus making
market cargo accessible in the VS source code , as a normal VS Cargo .
If i read my doxygen graphs correctly (site should still be up), the Cargo code should only be touched by the buy cargo interface code and the cargo holds. It may not be too hard to replace vegastrikes' stock Cargo with the market cargo altogether.

It is getting late, i will comment more later. Again, I am very impressed with your efforts. I hope these words will help you on your way.
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

I've checked out your git repo and had a few problems getting it working. Obviously, the vs9 solution will not work for my platform, so I decided to take the CMakeLists.txt from my local copy. Upon this, I noticed firstly that you have eliminated the test directory, so I reinstated it.

After that, I noticed there were also some changes in the API itself. I reintroduced some of the functions and butchered some of the XMLNode tests. After running the tests after these fixes, I noticed you have introduced an error in the MPLParser::Parse function. By removing the line "this->file.clear();", if the file is parsed again, the EOF flag will still be set and thus nothing will be read.

Trying to compile your console code I am currently running into the windows-specifics regarding time and console functionality. It is going to take some time for me to get this compiled. I will keep you informed of the status.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

Hi nido !
Glad to have news from you , and thank you for your interest .

About the test files that i removed :
It was an attempt to keep the Core Market API only , as i don't know how to use the tests ( i am not familiar with that procedure and on windows/visual studio it was an extra dependency) .
So sorry if i broke an important part of your work .
I learned c and c++ as an autodidact , and a lot of things that good devs learn in university are still obscure for me ... :roll:

It's cool to be 2 devs working on the Market now .
Actually , i am working in an Audio game ( sailing simulation for blind people ) ,
and so i let the vegastrike dev on pause ...

But i could easily be back on the market project if you need a companion one of these days.
I only set the bases for AI , and a lot of interesting work could be done on that level .
Well , thank you for your attention and long life to your economy !
:wink:

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

ezee wrote:So sorry if i broke an important part of your work .
I learned c and c++ as an autodidact , and a lot of things that good devs learn in university are still obscure for me ... :roll:
Do not worry about it. I myself already destroyed a lot of redadders work, but in the end we may get something someone can use. I myself are also not as versed in c++, hence I added the tests.

But i could easily be back on the market project if you need a companion one of these days.
If you are interested the first thing I would like to work at with you is creating platform independance and concequently incorperating the AI and Time you made into the market proper.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

Ok !
Let me be back in the files , to check what i've done already and the direction i have started to follow , then discuss about the details ?

If you want to read my background source for AI, it is located at :
http://www.ai-junkie.com/architecture/s ... tate1.html

All my ideas for the governor are based upon that .
I already have worked on a little project to test the power of that STATE DRIVEN AGENT
CONCEPT , and the results were positive ( not hard to code , and flexible ) .

Nice day to you .
:wink:

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

Let me be back in the files , to check what i've done already and the direction i have started to follow , then discuss about the details ?
The first thing I would like to ask you is to see if you can get the CMake configuration working on your end. If that is working, I suggest we move "my" files into a subfolder in src, for example 'economy', and move your files in their own little subdirectory next to it (rather then in the NidoMarket folder it is now) and have it make use of the economy as a library (more or less like a dll), as the test code is doing.

After that, I think we probably want to separate out the windowsconsole specific bits and perhaps make a platform independent timer function to use (there are a lot of difference in posix and win32 timing systems. For example, the fact it starts at system bootup time is probably not important for this code but it might very well be.)

EDIT: Assuming that you can get the cmake configuration to work, I have no problem altering the cmakelists.txt myself to also compile your code.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

After that, I think we probably want to separate out the windowsconsole specific bits and perhaps make a platform independent timer function to use (there are a lot of difference in posix and win32 timing systems. For example, the fact it starts at system bootup time is probably not important for this code but it might very well be.)
Okay .

First , the console program was just an experimentation of practical use of the Market API .
I don't think it could be usable directly in Vegastrike .
The purpose was to test the actual functionalities in a pseudo mini-game .
We can think of it as a demo program that exposes the api to the user .
So yeah , that could be stored in a folder of type "demos" or "samples" , in a standalone
version of the MarketLib. ( yeah , that market lib could be used in other projects than vegastrike too... )

About CMAKE :

I already have used CMAKE to obtain a Visual studio solution and compile the source code of Ogre3d API , but i never made myself a configuration file .
It is a good thing to know how it works , so i'll try to make it .
:wink:

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

Edit : You made a great job with the program architecture and the documentation system. So i let you decide about the "packaging aspects" , because it's important to stay " user friendly " .
:)

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

ezee wrote:First , the console program was just an experimentation of practical use of the Market API .
I don't think it could be usable directly in Vegastrike .
The purpose was to test the actual functionalities in a pseudo mini-game .
We can think of it as a demo program that exposes the api to the user .
This agrees with what I thought of it. The program can help understanding and testing what the market api is supposed to do.
So yeah , that could be stored in a folder of type "demos" or "samples" , in a standalone
version of the MarketLib. ( yeah , that market lib could be used in other projects than vegastrike too... )
I've made market a library purely for the convenience when linking it to the different test programs included. I agree it is a good idea to keep it separate from the library proper, but I think it still does belong in this package on the same level of importance as the test programs.
I already have used CMAKE to obtain a Visual studio solution and compile the source code of Ogre3d API , but i never made myself a configuration file .
It is a good thing to know how it works , so i'll try to make it .
:wink:
my remakes from redadders code already have a CMakeLists.txt file. I'd be happy to make the necessary alterations to include your code in its configuration. I would still be interested to know if the sln file it generates is working in your environment. If not I would happily assist in fixing it.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

my remakes from redadders code already have a CMakeLists.txt file. I'd be happy to make the necessary alterations to include your code in its configuration. I would still be interested to know if the sln file it generates is working in your environment. If not I would happily assist in fixing it.
That's neat , thank you .
:D

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

So I was ploughing through the AI code indiscriminately changing stuff that gcc didn't agree with, following by PrecisionTimer, which looked like an implementation of a time protocol of sorts based on windows time. Upon realising it would basically be a complete rewrite if i was to slash through it the same way I did with AI, so i pushed everything through doxygen in order to make sense of it all.

What I found was a state machine which worked on a miner of sorts. It took me a while to realise this wasn't pointing in any way to my economy code. Only recently i located VSmarket.cpp, which fortunately was magnitudes easier to port. If you want the file as is: http://wardenscat.foxserver.be/nido/VSmarket.cpp

The first thing i did with this code was process it through clang-format. Because the following example just doesn't work for me.
{printf(".");Sleep(100);}
I noticed this program used a 'main' function defined as
int _tmain(int argc, _TCHAR *argv[])
I changed this to void realmain(), and had a main or that particular function around it depending on an ifdef for WIN32 , just as the include of <windows> and <tchar>. I also removed the Sleep() calls because there wasn't a direct equivalent in posix that i knew of right now.

Anyway; I am proud to report to report the example works now too on linux. I will include this file in my original code layout so we could work from there when you get cmake working.

kind regards,

Nido
charlieg
Elite Mercenary
Elite Mercenary
Posts: 1329
Joined: Thu Mar 27, 2003 11:51 pm
Location: Manchester, UK
Contact:

Re: Now I was thinking maybe I'd code a market

Post by charlieg »

Nice work nido. Do you have your own svn or could you maybe push to github or somewhere that easily handles forks/patches?
Free Gamer - free software games compendium and commentary!
FreeGameDev forum - open source game development community
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

charlieg wrote:Nice work nido. Do you have your own svn or could you maybe push to github or somewhere that easily handles forks/patches?
That is a good idea.
https://github.com/nido/vegastrike-market

Changes to this is that i created a library out of the market component, and i did a few tricks to make it compile under mingw32. For people who wish to not compile it but still press on .exe files, see http://wardenscat.foxserver.be/vsmarket.zip for some messages appearing in a console window.

After i posted i found Ezeer has a version which probably has some better attribution.
https://github.com/Ezeer/Vegastrike_Market

In that regard i probably should create an AUTHORS file containing everyone who did something regarding this project. If someone has one ready i'd happily use that.

It is using a sln file, so I can't compile it on linux. Though we can probably work this out in a good way.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

Hello Nido , i'm back ... :)
I don't have yet tried the CMAKE to produce a solution for windows system ,
but i will try this week .

I have spent an hour to read again this thread , and the governor class appear to be
the future brain of this economical system .
I think you are right with that design of one global economy driven by multiple governors.

Sorry to have let you believe that the AI code was ready ...
It is the good work of AI-Junkie that i will try to adapt step by step to our needs .
The actual code is a demonstration of a framework to achieve a great FSM machine
with messaging between the different actors .

The Governors would act as the miner in the demo code , using his states to solve trading problems : The base is out of iron , create mission to bring back the raw products to the factory , that will create jobs ( pirates will be there to capture cargo , police to stop them etc ... :lol: )

I want to try that soon , give life to the governors .
That will introduce a new gameplay also , because human player could pretend to be
governors too , and use the functions that my AI will use to manage their bases .
That mean a new room in the base , the governor lounge ?
( imagine you can launch AI flights , choosing for them their routes , give them escort
or just escort them yourself ... would be nice uh )

I have an idea how to realize that technically , because my old work based on an ingame
menu showed me how to access new rooms in the game .

I hope that will work , seem to be promising .
Tchao Nido .
:wink:

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

CMAKE tested but failed to configure-and-make a BUILD solution for vc9 .
I have no time to dig into the problem nor to learn more about CMAKE .
I think some params are missing in the configuration file .

I could retry and post here the error message to help you to fix it , nido ?

Now i started to look again into the code of the Market source , and i think that :

Market could be a lib (.lib) and .dll in the windows environment .
Programmer-side , the user could include a header file in his project and link to the
compiled sources ( .lib) .
In a big project like vega strike , the project explorer is busy , so have only header
to add is a good point . ( yeah , there could be a release version and a source version.... too ..)

That would turn the Market in an Api very simple to insert in a project and to use .
( with that beautiful doc u made :wink: )
But i don't know how you intended to use that Market project , i mean in a context
with an exemple .

From my point of view , there is two directions possible :

_A: The market lib is a set of classes that the user need to derive for his own classes.

Example 1:
class AI : public Governor
The AI is now able to interact with other Market Modules .
AI could have steering functions to moove in the game ( yeah inside a vessel ... ) but
also have access to the management of Bases thx of governor .

_B: The market lib is intended to be used in VEGASTRIKE ONLY .

That mean for example that a base in the Market lib should have properties that are in relation with the vegastrike Universe .
Because the final user won't have to reinvent the wheel and scan again and again the vegastrike sources to pick the right variable .

Actually , a base in Market has no name , nor location in space :

Code: Select all

class Base {
public:
  /** Create an empty Base */
  Base();

  /** delete a factory */
  ~Base();

  /** iterator access */
  typedef std::vector<Factory>::iterator iterator;

  /** iterator access */
  typedef std::vector<Factory>::const_iterator const_iterator;

  /** add a factory for production to the base
   * @param factory the Factory to add
   */
  void addFactory(const Factory& factory);

  /** delete a factory from the base
   * @param factory the Factory to remove
   */
  void delFactory(const Factory& factory);

  /** Add cargo to the base
   * @param cargo the Cargo to add
   */
  void addCargo(const Cargo& cargo);

  /** delete cargo from the base 
   * @param cargo the Cargo to delete
   */
  void delCargo(const Cargo& cargo);

  /** return the Factories in this Base
   * @return vector of factories
   */
  const std::vector<Factory>& getFactories();

  /** return a reference to this Base cargo
   * @return this Base Cargo
   */
  const Cargo& getCargo() const;

  /** Process all activities on this base
   */
  void Process();

  /** Compare this base to another
   * @param that the Base to compare to
   * @return true when equal, false otherwise
   */
  bool operator==(const Base& that) const;

private:
  /** The Factories on this Base */
  std::vector<Factory> factories;

  /** The Cargo on this Base */
  Cargo cargoStore;
};
Not a problem in a generic context (A) , because the Base will be derived and so lot
of Vegastrike"s " details " added in the derived class.
But in a " B " perspective , let's say 'out of the box' , the user would use a Base class
that is ready to plug in the universe .

Wich of plans appears to be better for you ?
The 2 will need the same amount of work ?
Is it our job to implement vegastrike data in the market lib , or the final user's job ?

I will also be a final user of the market lib , and for the vegastrike project , a plug and play (B) solution is the key , but for a stand alone project , i don't want to have vegastrike dependencies ...

My idea is to keep in mind the freedom of the lib , and design it so final users derive
their classes from it . ( A )
But with a minimum of vegastrike requirements inside , as that lib is first an extension
for the vegastrike Universe , that could be used in other games environments .

I stay tuned .
8)

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

ezee wrote:CMAKE tested but failed to configure-and-make a BUILD solution for vc9 ....I could retry and post here the error message to help you to fix it , nido ?
No problem. I am guessing it cannot find the libraries it needs, that would be relatively easy to solve.
ezee wrote:Now i started to look again into the code of the Market source , and i think that :

Market could be a lib (.lib) and .dll in the windows environment .
Programmer-side , the user could include a header file in his project and link to the
compiled sources ( .lib) .
one step ahead of you. market is already a library. :)
ezee wrote:In a big project like vega strike , the project explorer is busy , so have only header
to add is a good point . ( yeah , there could be a release version and a source version.... too ..)
I am not really sure what you are talking about here. I assume it has to do with visual studio. At the moment you would need the library (dll), some header files and some dependencies (other dlls, headers) for this to work.
But i don't know how you intended to use that Market project , i mean in a context
with an exemple .
the current version has an "example" program VSmarket. not sure if this is the kind of example you want.
_A: The market lib is a set of classes that the user need to derive for his own classes.
[snip]
_B: The market lib is intended to be used in VEGASTRIKE ONLY .

That mean for example that a base in the Market lib should have properties that are in relation with the vegastrike Universe .
Because the final user won't have to reinvent the wheel and scan again and again the vegastrike sources to pick the right variable .
I am afraid I must disagree with your conclusion here. Even within software projects, it is important to keep separate things separate. For the economy to work, it does not need to know its physical location. I agree there must be a relation between planet sxdcfvgbhnj and economy 'base' number 345, they do not necesarily need to be the same. The easiest way to intergrate this is probably to add a pointer to a 'Base' class which gives it access to its goods.
Is it our job to implement vegastrike data in the market lib , or the final user's job ?
We happen to be both people in this case so this point is essentially moot
I will also be a final user of the market lib , and for the vegastrike project , a plug and play (B) solution is the key , but for a stand alone project , i don't want to have vegastrike dependencies ...
My idea is to keep in mind the freedom of the lib , and design it so final users derive
their classes from it . ( A )
Ah you have interest in using this in another project. In that case a separate library seems to be the most sensible path.

I think the biggest challenge next is to determine how market will get a relation itself to the physical locations. At the moment the economy generates itself, but entities in it are not readily available. Question is whether it is more sensible to give the library user access to the inner parts of the economy so they can bolt it onto their own datastructures, or to have users create the economy themselves from their own datastructures. Essentially your question of "Is it our job to implement vegastrike data in the market lib , or the final user's job ?". Do you have a suggestion on this?
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

ezee wrote:I have spent an hour to read again this thread , and the governor class appear to be
the future brain of this economical system .
I think you are right with that design of one global economy driven by multiple governors.
[snip]
The Governors would act as the miner in the demo code , using his states to solve trading problems : The base is out of iron , create mission to bring back the raw products to the factory , that will create jobs ( pirates will be there to capture cargo , police to stop them etc ... :lol: )
Yes, that is sort of what i envisioned them doing. it is easy to start out with an 'always produce' governeur and build from there if even needed. They are basically the traders of the economy. They will probably also bring about the need for actual currency in this economy model.
I want to try that soon , give life to the governors . That will introduce a new gameplay also , because human player could pretend to begovernors too , and use the functions that my AI will use to manage their bases .
very long term idea. but not impossible.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

Yes !
Cool to have you insight again Nido !
Thanks for your comments , i appreciate your opinion .

Yeah i plan to use the Market lib in a private project later , and ... what about the licensing you use Nido ? It is a thing i forgot to check , not to mention your name in the work i do .

I want to make a windows release for the version 0.5.1 rc1 , i have fixed this bug with the music , and it's an opportunity to start this slow change that is possible now .

I have opened a project in source forge , with Git and Svn repositories .
I will only work on the windows part , so if you want to join me for your Os part ,
just PM me your account name in sourceforge and i will add you as Dev .
You can check the project here : http://sourceforge.net/projects/vegastrikevo/

I'm working actually in http://sourceforge.net/p/vegastrikevo/c ... ntal/tree/
In the SVN there is a fresh Tags/0.5.1 rc1 that should work for you , if you want to try things with your lib .

I actually work on basic things , like the interface , trying to make it ... evolve .
But i have an idea how to plug the Market in the Universe of VS ... we'll try that in the experimental branch later .
^^

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

ezee wrote:Yeah i plan to use the Market lib in a private project later , and ... what about the licensing you use Nido ? It is a thing i forgot to check , not to mention your name in the work i do .
This started as a project 100% intended for vegastrike. As such, I ripped out parts of vegastrike in order to build upon redadders code (common/common.* for starters), so there is really not much choice other then 'GPL v3 or Later' (due to that being vegastrikes license.'
ezee wrote:You can check the project here : http://sourceforge.net/projects/vegastrikevo/
I haven't tried to upstream any code yet, but is it really going so bad it warrants forking the code? If this market is to merge with vegastrike proper, it may be benefitial to work with a copy of vegastrike proper. If only because one will get all the updates. I may be mistaken in my assessment here though.

I'm working actually in http://sourceforge.net/p/vegastrikevo/c ... ntal/tree/
ezee wrote:But i have an idea how to plug the Market in the Universe of VS ... we'll try that in the experimental branch later .
^^
I'd love to hear about it in this thread. I've been looking around the source code on and off hoping to find a time and place where the vegastrike universe is defined and accessable.
ezee
Intrepid Venturer
Intrepid Venturer
Posts: 703
Joined: Tue Feb 11, 2014 12:47 am
Location: FRANCE
Contact:

Re: Now I was thinking maybe I'd code a market

Post by ezee »

so there is really not much choice other then 'GPL v3 or Later' (due to that being vegastrikes license.'
I think so .
But in my personal work ( other that vegastrike ) , i will use Ogre3D that is under MIT ,
due to the coolest coder of the world , the well named Sinbad who designed the engine
and ... a community .

What you've done with the Market lib is great , i mean well written , similar to the Ogre3D
way . You got my respect for that . ^^
And so , Market Lib is something that could be useful for the game Makers from everywhere.

I really think like you , things must stay separated , meanin live in their owns but able to
work with other things .

I am a user of your lib , and the changes i could make are for a specific usage .
You have that quality i don't have to make Market Lib a cool lib . ^^
So please , continue your effort regardless of vegastrike , i for example could help you
from the Vegastrike side , by implementing ( and perhaps modify/adapt it ) your lib .

My experimental branch will be the place for that , and could serve as " example " ,
with vegastrike as context ( no more console display and Sleep() functions .... ^^ )

Code: Select all

I haven't tried to upstream any code yet, but is it really going so bad it warrants forking the code
Ask Vincele .
Or better , TurboHolder .
A friend sing my opinion :
https://www.youtube.com/watch?v=IAshOzRGrBw
:wink:

So , about the possible implementation in the vegastrike Logic :

The Ai is 'driven' actually by the computer in the bases stations , when you choose a mission . Ai is a Unit ( vessel ) that can hold other units ( cargo ) .

Now imagine your Governor class as ancestor for the computer class .
The computer class is able to deal with Units , the Governor know what to do with it .
EDIT : You could implement generic virtual fonctions here , like buy() , sell() , etc ...
And use of templates ...


The problem is : We want the computer/governor online in the game , not only when we
launch it manually from the station .

The Good news are that there is a Tick() or Update fonction in your lib !
And that tick() can be syncronized in the main loop ( at the frequency we want yeah )

So , via that " heart beat " , we can have computer/Governor stay alive ...
That example seem to works for an instance of Governor , but we want more Governors.
There will be only one instance of computer , but more governors .

Stored in std::map for example ?

Well , it's a first shot , but if you check the code in the Units parts , you will find Cargo
and all the stuff related to market . And the computer is the human interface , thus we could use the computer as interface when we will be ... Governors .

More to come ...
:)

EDIT : More to come ... about multiplayer consequences , that is the very difficult part
to handle . I had one vision or expectation about it , the management of online AI units .
For example , in a peer to peer model , who is responsible for the AI updates ? User A or
User B ?

I imagine a rule where the AI is managed by the peer that first create it .
But if the peer get disconnected ? Ownership must go to someone else etc .

In a dedicated server, the things seems to be more simple as the AI/Governors/Pilots would be managed by the server .

Code: Select all

 if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
Vegastrike evolved
DEV YOUTUBE CHANNEL
Vegastrike evolved wiki
nido
Merchant
Merchant
Posts: 43
Joined: Tue Sep 03, 2013 2:35 pm

Re: Now I was thinking maybe I'd code a market

Post by nido »

ezee wrote: But in my personal work ( other that vegastrike ) , i will use Ogre3D that is under MIT ,
due to the coolest coder of the world , the well named Sinbad who designed the engine
and ... a community .
vegastrike also uses Ogre3d. The MIT license is compatible with the GPLv3, so you can use MIT code in GPLv3 projects.
So , about the possible implementation in the vegastrike Logic :

The Ai is 'driven' actually by the computer in the bases stations , when you choose a mission . Ai is a Unit ( vessel ) that can hold other units ( cargo ) .
Wow, stop. What is this 'compmuter in the bases stations? Is there actually something codewise that represents this or is this the physical location where you imagine it to run in-universe?

As for the Unit, I think this may not be a bad moment to consider implementing Cargo inside Vegastrike to remove such references from the god class that is Unit. Other then the cargohold and the market, there isn't really a place where a bunch of cargo has use as a unit, right?
The problem is : We want the computer/governor online in the game , not only when we
launch it manually from the station .
The Good news are that there is a Tick() or Update fonction in your lib !
And that tick() can be syncronized in the main loop ( at the frequency we want yeah )
If you want to go big, or have player interaction, it may be a better idea to give the foverner access to the data it needs from his base, and have it decide in its own time, in its own thread, when it wants to do something. implemented fully within vegastrike that'd make about 3000 threads though so that probably won't work like that, though a signal can be sent to a governers thread which will process afterwards.

A 'tick' in the Economy as it is now means "this is the moment that all factories start production". Before and after it the world is essentially static, but during it it is in flux, so even if the governer is the only thing updating during that moment, One cannot guarantee the cargo of the other bases will actually be available/buyable by the time they start their update.

Similarly, a 'tick' in a vegastrike sized economy on a single thread takes roughly two seconds on my i3 laptop. I don't think you want to sync that up with any main loop period. It may be advantagous to have it run in its own thread, and have it update more along the lines of once per minute rather then 60 times per second. Also, the 'tick' code is very predictable at the moment. When you add a complex AI, it becomes harder and harder to guarantee that the code will indeed run for two seconds, rather then, say, 'something between 2 and 10 seconds'. If the governer ai runs in its own thread, it can take its responsibility itself to be ready when the time comes, and the rest of the economic universe will not need to wait for that one ai that encountered a bug and is now forever deciding whether to buy from base A or base B.

EDIT : More to come ... about multiplayer consequences , that is the very difficult part
to handle . I had one vision or expectation about it , the management of online AI units .
For example , in a peer to peer model , who is responsible for the AI updates ? User A or
User B ?
No it is not. Even in peer to peer, it is trivial to arbitrarily assign one side as the server and the other the client. Though in a true p2p model, you might want to use something a bit more inteligent then 'arbitrary' to find the right host to play server. Another option would be to demand the governer to be deterministic, so everyone can run their own economy where each instance comes to the same conclusion.
Post Reply