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.
Post Reply
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 »

Wow, stop. What is this 'compmuter in the bases stations?
Sadly , i deleted the Doxygen doc of vegastrike from my dropbox , that was usefull to reach
the exact information with details ...
But yeah , the computer is a class , perhaps named BeseComputer , something like that .

I will report the real thing later , with more details , ok ?
Thx

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 »

okay , i use the svn of my site to communicate with you about the source code .
About the real BaseComputer i was talking about :
//The BaseComputer class displays an interactive screen that supports a
//number of functions in a base.
//Current list:
//Buying and selling cargo.
//Upgrading and downgrading your ship.
//Replacing your current ship with a new one.
//News articles.
//Mission bulletin board.
//Player info.
The file :
BaseComputer( Unit *player, Unit *base, const vector< DisplayMode > &modes );

What is " Display mode " ?
//The Computer displays that are possible.
enum DisplayMode
{
CARGO=0, //Buy and sell cargo.
UPGRADE, //Buy and sell ship upgrades.
SHIP_DEALER, //Replace current ship.
MISSIONS, //Show available missions.
NEWS, //Show news items.
INFO, //Show basic info.
LOADSAVE, //LOAD SAVE
NETWORK, //Network submenu of Loadsave.
DISPLAY_MODE_COUNT, //Number of display modes.
NULL_DISPLAY=DISPLAY_MODE_COUNT, //No display.
};
We could notify here a special page for consulting or interacting with the market

In the same file , TRANSACTION is described :
//These are the transactions that can happen using this object.
//Transactions are operations that modify the player's state. Reading news isn't
//a transaction.
enum TransactionType
{
BUY_CARGO, //Buy item and put in ship.
SELL_CARGO, //Sell item to base.
BUY_UPGRADE, //Buy an improvement for current ship.
SELL_UPGRADE, //Sell an improvement on current ship.
BUY_SHIP, //Replace our current ship with a new one.
ACCEPT_MISSION, //Accept a mission.
NULL_TRANSACTION, //Not initialized yet.
};
The relationship between Vega and the Market could be added here ?
For example , in the case of " I WANT TO BE THE GOVERNOR RIGHT NOW !! HOW MUCH
YOUR STATION COSTS ? I also want to buy a planet , called earth . Man , i've got cash 8) "
:lol:

I imagine possible tricks :
BUY_STATION , // Buy a station
UPDATE_MARKET , // Transaction from vega state to the Market state ?

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 »

We go Deeper ?
Ok , so let's inspect the core Unit with first the container :
class Unit;

class UnitContainer
{
protected:
Unit *unit;
public: UnitContainer();
UnitContainer( Unit* );
UnitContainer( const UnitContainer &un )
{
VSCONSTRUCT1( 'U' )
unit = 0;
SetUnit( un.unit );
}
const UnitContainer& operator=( const UnitContainer &a )
{
SetUnit( a.unit );
return a;
}
bool operator==( const Unit *oth ) const
{
return unit == oth;
}
bool operator!=( const Unit *oth ) const
{
return unit != oth;
}
bool operator==( const UnitContainer oth ) const
{
return unit == oth.unit;
}
bool operator!=( const UnitContainer oth ) const
{
return unit != oth.unit;
}
~UnitContainer();
void SetUnit( Unit* );
Unit * GetUnit();
};
Source :container.h


It's time to introduce your code , and you remember my old comment with Cargo name in
market lib , with my desirated " Container " distinction ?
/** 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();

/** 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;

std::string getName() 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;

std::map<CargoType, unsigned int>::iterator begin();
std::map<CargoType, unsigned int>::const_iterator begin() const;
std::map<CargoType, unsigned int>::iterator end();
std::map<CargoType, unsigned int>::const_iterator end() 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;

/** The datastructure holding the actual cargo itself. */
std::map<CargoType, unsigned int> cargo;
};
Source : https://github.com/nido/vegastrike-mark ... /Cargo.hpp

It is interresting to compare these files , to see how they could interact , and at wich
level . That's the way i do .

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 »

Now in // , still in the Base context in vegastrike , an init that shows how VS deals
with running or not real time 3D when in 2D mode .
That could be useful to control the live of the Market module in the same fashion .
( related to the main loop() and update of states or steps in your factories - real time processing or Interpolation for the economy steps )
void BaseInterface::InitCallbacks()
{
winsys_set_keyboard_func( base_keyboard_cb );
winsys_set_mouse_func( ClickWin );
winsys_set_motion_func( ActiveMouseOverWin );
winsys_set_passive_motion_func( PassiveMouseOverWin );
CurrentBase = this;
CallComp = false;
static bool simulate_while_at_base =
XMLSupport::parse_bool( vs_config->getVariable( "physics", "simulate_while_docked", "false" ) );
if ( !(simulate_while_at_base || _Universe->numPlayers() > 1) )
GFXLoop( base_main_loop );
}
It could be an entry point , and we could introduce some new vars in the vsconfig file

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 »

As we are here , we enter the critical zone in mainloop.cpp , to examine how Units ( you call them Entitys in your files comments i think ) are inserted in the game memory :
void AddUnitToSystem( const SavedUnits *su )
{
Unit *un = NULL;
switch (su->type)
{
case ENHANCEMENTPTR:
un =
UnitFactory::createEnhancement( su->filename.get().c_str(), FactionUtil::GetFactionIndex( su->faction ), string( "" ) );
un->SetPosition( QVector( 0, 0, 0 ) );
break;
case UNITPTR:
default:
un = UnitFactory::createUnit( su->filename.get().c_str(), false, FactionUtil::GetFactionIndex( su->faction ) );
un->EnqueueAI( new Orders::AggressiveAI( "default.agg.xml" ) );
un->SetTurretAI();
if ( _Universe->AccessCockpit()->GetParent() )
un->SetPosition( _Universe->AccessCockpit()->GetParent()->Position()
+QVector( rand()*10000./RAND_MAX-5000, rand()*10000./RAND_MAX-5000, rand()*10000./RAND_MAX-5000 ) );
break;
}
_Universe->activeStarSystem()->AddUnit( un );
}
So it seem that a unit is inserted in the player local system only .
And so , Ai and other Units don't have independent lives in other systems (those not actually played , i don't know if it's the case in multiplayer game , but i think it is )

One thing i see is that flag :
case ENHANCEMENTPTR:

Market lib is an enhancement i want ...
:lol:


SO , what is an " enhancement " ?
We need to check unitfactory to know the kind of Units types :
class Mesh;
class Flightgroup;
class Nebula;
class Missile;
class Enhancement;
class Building;
class Asteroid;
class Terrain;
class ContinuousTerrain;
Source : Unit Factory header in vegastrike

We don't know yet what enhancement is , but we realize how important is a Unit class
in Vegastrike .

And why i insist to use them , is that they are also implemented server side :
Unit* UnitFactory::createServerSideUnit( const char *filename,
bool SubUnit,
int faction,
std::string customizedUnit,
Flightgroup *flightgroup,
int fg_subnumber )
{
return new Unit( filename,
SubUnit,
faction,
customizedUnit,
flightgroup,
fg_subnumber );
}
Source : UnitFactory.cpp

They use Unit as you want to use Cargo , it's too generic i think , but they use flags to describe the type of unit . Here it's for vessels only .
But that could be a way to register A Market place server side ( hosted by a distant player or peer in a system ... )

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 »

Back to the quest of ENHANCEMENTS :

Code: Select all

class GameEnhancement : public GameUnit< Enhancement >
{
    friend class UnitFactory;
protected:
/// constructor only to be called by UnitFactory
    GameEnhancement( const char *filename,
                     int faction,
                     const string &modifications,
                     Flightgroup *flightgrp = NULL,
                     int fg_subnumber = 0 ) :
        GameUnit< Enhancement > ( filename, false, faction, modifications, flightgrp, fg_subnumber )
    {
        string file( filename );
        this->filename = filename;
    }
private:
/// default constructor forbidden
    GameEnhancement();
/// copy constructor forbidden
    GameEnhancement( const Enhancement& );
/// assignment operator forbidden
    GameEnhancement& operator=( const Enhancement& );
};
Source : https://sourceforge.net/p/vegastrikevo/ ... ancement.h

I think that this part is to be improved , to allow different types of GameEnhancements ,
and it's the man that think to turn Vegastrike in a game engine that talks to you .
:lol:

But wait ... what is a " GameUnit " ....
SHit !
That don't fit at all with what i was thinking , but it is pure logic this time ...
/**
* GameUnit contains any physical object that may collide with something
* And may be physically affected by forces.
* Units are assumed to have various damage and explode when they are dead.
* Units may have any number of weapons which, themselves may be units
* the aistate indicates how the unit will behave in the upcoming phys frame
*/
So that's not the way to use with the Market , unless a Market place has a 3D place
in the universe ( like a station ? )
ANyway , i see the Market lib ( my version in fact ) as an engine , similar to a physics engine ( that is the perfect illustration of " dynamics " . This kind of engine use clever tricks that could serve
the processing of moovement for cargos ( from the creation in the factory to the Dealer ,
using similars steps to compute ? ) .

If we want a dynamic economy , we should know the principles of the dynamic and how
to simulate it . RedAdder made a work i haven't checked yet , but i know that he was
working on something very similar to forces interaction in the Markets .
Money is a force , cost of life a negative force , etc....

I'm gonna search for myself a very simple model of physics engine to be aware of the
basics .

EDIT : I've found some interesting links :
Real-time engines offer two options for controlling the physics engine timing:
Static
Always provides the engine with a non-changing amount of time that is expected to pass every frame. Static real-time engines run at different speeds on different computers, so it's common that they behave differently.
Dynamic
Feeds an elapsed time to the engine.
The example physics engine in this article needs to be running continuously, so you need to set up an infinite loop to run against the engine. This processing pattern is called the game loop.
Source :very simple 2d physics engine

Something in that previous doc that may talk to you Nido :
Entity as a model
As the logic in Listing 3 shows, the physics entity stores nothing but raw data and produces different variants of the data set. If you're familiar with any of the MV* patterns, such as MVC or MVP, the entity represents the Model component of those patterns. (See Resources for information on MVC.) The entity stores several pieces of data—all to represent the state of that object. For every step in the physics engine, those entities change, which ultimately changes the state of the engine as a whole. The different groupings of the entity's state data are discussed in more depth later.
That talk to me .
:wink:
Last edited by ezee on Sat May 30, 2015 12:35 am, edited 1 time in total.

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 »

If i say :
Position, velocity, and acceleration: The positional data
The entity includes positional data, which is information depicting how the entity can move in space. Positional data includes basic logic that you would see in Newtonian kinematic physics equations (see Resources). Of these data points, the example entity is concerned about the acceleration, velocity, and position.
you could think i'm crazy to talk about vectors with the economy ?
But if i translate the words ( containers ... ) from their Newtonians origins in an other
cartesian space , that's not so crazy :
Cartesian coordinates, also called rectangular coordinates, provide a method of rendering graphs and indicating the positions of points on a two-dimensional (2D) surface or in three-dimensional ( 3D ) space. The scheme gets its name from one of the first people known to have used it, the French mathematician (me : Cocoricooo ! ^^ ) and philosopher René Descartes (1596-1650). The Cartesian coordinate system is used to define positions on computer displays and in virtual reality (VR) renderings. The system is also employed in mathematics, physics, engineering, navigation, robotics , economics, and other sciences.
Source :http://whatis.techtarget.com/definition ... oordinates

_ Position = can be the position in the production chain
_ Velocity = ( how many time before delivering )
_ Acceleration = used to control with smooth the inertia of the economy ?
( acceleration = how many buyers ? When buyers=0 , acceleration=0 , what about the velocity then ? All that is a sum of equations to solve with maths . But in your case , it's perhaps not your problem but the final user's problem - me eh eh )

Edit : I forgot to talk of TIME , that is one of the coordinates of the equations to solve.
And the reason why i want to use the precious " time-elapsed-since-last-frame " .
That will allow time interpolation for the Vector that describe a factory state , for example .

A serious reading extract about that :
The Infinity Cartesian Space shows the behavior of different prices into the same Cartesian Space from a new graphic view, at the same time, the average price in the same period of time.
And the book :
Application of Infinity Cartesian Space (I-Cartesian Space):
Oil Prices from 1960 to 2010


With interpolation we could simulate a complex system at the frequency you said ( in terms of seconds , not ms as it's the case per rendered frame )

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 »

The last of my serie of posts , and my favorite part , where the heart beats in Vegastrike : mainLoop.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->StartDraw();
...
...
...
Universe is the main Object in Vegastrike , your interface with everything .
And one " detail " that is so important is that :
class Universe
{
protected:
std::auto_ptr<GalaxyXML::Galaxy> galaxy;
...
...
///currently only 1 star system is stored
std::vector< StarSystem* >active_star_system;
Yeah , only one StarSystem in memory at a given time , but could store a lot ?
Why they don't store the nodes in a certain range ?
Probably for a question of size in memory ? I will check that too , because we want
a dynamic Market in more than one system...

FINALLY I MADE A DOC FOR VEGASTRIKE ONLINE AGAIN AT :
http://vegastrikevo.sourceforge.net/vegaevo_doc/html/index.html
The search box in the right corner of the doc is very useful !
Here's a link to the basecomputer class :Base computer doc

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 »

Ouch ... i realize i posted a lot of datas , and some are very far away from what you are
doing now Nido . Excuse me for that , it's just that you said " i'd love to know ... " and i
should have resisted more to the temptation to reveal my intentions too early .

I realize also that i missed the very basic implementation of economy in vegastrike actually.
The market prices are all defined in master-part-list.csv , as starting prices .
But i don't know if they change in the game , nor if the prices are stored per stations, bases or dealer . ( i guess no for the dealer , perhaps for the bases ? )

That is the data that your library will deal with , and so perhaps it won't be needed to go
the hard way , with inheritance of classes and huge modifications of code.
If your lib can write in the right place the prices that were updated by it , then that
will be a neat step ahead into dynamics ...

THINGS I DON'T KNOW :

_If master-part-list.csv is the only file used by VS to make the deals
_ If master-part-list.csv is somewhere updated and when .

I'm gonna check that soon , to be sure of my doin' ...
bye :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:That is the data that your library will deal with , and so perhaps it won't be needed to go
the hard way , with inheritance of classes and huge modifications of code.
If your lib can write in the right place the prices that were updated by it , then that
will be a neat step ahead into dynamics ...
That is more or oless the plan. There isn't much which is dependant on what Cargo stuffs do, so replacing it shouldn't be too hard.
_If master-part-list.csv is the only file used by VS to make the deals
_ If master-part-list.csv is somewhere updated and when .
nopes, there are modifiers which change the price depending on the location. the file itself is static though.
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 »

nopes, there are modifiers which change the price depending on the location. the file itself is static though.
Ok , i will trace the modifiers so ...
Thank 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
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 »

And thus i've found something that is very interesting in the BaseCOmputer :
void trackPrice(int whichplayer, const Cargo &item, float price, const string &systemName, const string &baseName,
/*out*/ vector<string> &highest, /*out*/ vector<string> &lowest)
It's a very long fonction , i don't want to publish it entirely , i'll give you a link to it :
Track prices

And i'm surprised and happy to see that i was not completly wrong with my idea of modified
physics engine for the economy :
bool sellShip( Unit *baseUnit, Unit *playerUnit, std::string shipname, BaseComputer *bcomputer )
{
...
...
if ( cockpit->GetUnitSystemName(i) == _Universe->activeStarSystem()->getFileName() )
{
static const float shipping_price =XMLSupport::parse_float( vs_config->getVariable( "physics", "sellback_shipping_price", "6000" ) );
xtra += shipping_price;
}
cockpit->RemoveUnit(i);
static float shipSellback =XMLSupport::parse_float( vs_config->getVariable( "economics", "ship_sellback_price", ".5" ) );
cockpit->credits += shipSellback*shipCargo->price; //sellback cost
cockpit->credits -= xtra; //transportation cost
break;
...
...
The function is here :Sell ship

That's for the ship part, i'm gonna search now the modifiers for the other goods .
But here we already have an idea of how is done the computation of prices , via the
configuration file for global parameters in physics and economy ...
:lol:

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:Ouch ... i realize i posted a lot of datas
I didn't even realise until i revisited this thread and noticed page 4 was full whilst it was the 'last page' last time i chcked.

Regarding BaseComputer, I think this is the class we need to pimp out with hooks into the economy. Somehow the base or basecomputer needs to figure out which node in the economy is 'his'... Or perhaps we shouldn't precreate the entire economy, but rather give the ability to add entities to it, returning references to them upon creation. The BaseComputer seems to me to be the thingie controlling the screens you can trade with. "Buying a planet" is probably more long term, though once the economy is in place, i don't think it'd be too hard to create a screen of buttons to push corresponding to governer actions inside the economy.


I'm not sure market necesitates not running during 2d time. In fact, it might prove advantagous to only process during 2d time (as you don't exactly need to run those static backgrounds at 60fps, but seeing that missle before it hits sounds like a good idea. Though this could lead to some delay before being able to buy something due to the economy needing to calculate what happened those three hours you spent in space.


I didn't call thinks 'units' in my documentations because units are actual things within the vegastrike code, and there are some differences between vegastrike units and 'entity's. The reason a Cargo is not a container, is that the container would impose limits to the size and perhaps weight of its contents. These are probably not too hard to make either. Cargo is also a tad different from the unit systems' representation of cargo. IIRC, A unit can be any number of a singular "cargotype". It may be benefitial from vegastrike too to remove the concept of cargo from the unit class and implement the cargo/cargotype classes.

Those enhancements seem enhancements for units, and within vegastrike pretty much anything is a unit, so they could do possibly anything. They require a filename for some reason though. Possibly this is how mods work.

market/economy at the moment is a simulation of production of resources. There are as of yet no ways to move stuff from base a to base b or vice versa. For a first try, it would probably be best to have a way to insta-move cargo from one place to the other to facilitate actual trade, and perhaps later have a mechanism by which to tell vegastrike to have a ship actually moving 400 cattle from earth to the moon and the moon taking in those 400 cattle (assuming they aren't shot down in between ofcourse).

I am familiar with the carhesian coordinate system but i am not really sure what you are planning to do with it. A position in a production chain is a integer value where we can have multiple things on the same place in the production chain. For example, starting with a 'stuff', we can make either a 'foo' or a 'bar', then, with the 'foo' and the 'bar', we can make a 'baz'. the production for foo and bar are both second in line in the production process.

Position, velocity and acceleration are related concepts, Whilst you can certainly define them to be unrelated things, they will still act in relation to eachother. I think at this time you may be trying to find a problem to fit the solution you found.

Redadders work had simulation of price deal creation, divident payout and what not. However, simulating one economic tick already takes 2 seconds now all that is happening is the production. I think it is important to keep additions simple and fast rather then to precisely simulate what we think will happen. To that effect i would suggest we start with price being a simple multiplication of the quantity available and the (physical) distance it needs to travel. Have the library keep the potential to run 'insane' economies, and delegate control to the governers whom may fail at that job (because for some reason player keeps shooting down all his shipments of, say, wine. Why affect a planet directly when you can do it indirectly for profit? :p).

Curious about the active starsystem thingie. Are you sure the rest is not loaded? or is that just the convenient "this is where the player is, so spawn stuff here" handle? In the former case, we would need for the basecomputers to find their market equivalence.

By the way, you haven't yet posted your cmake errors. I need to go out now, but I'd love to take a look at it and see if there is anything i can do at my end.
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 »

market/economy at the moment is a simulation of production of resources. There are as of yet no ways to move stuff from base a to base b or vice versa. For a first try, it would probably be best to have a way to insta-move cargo from one place to the other to facilitate actual trade, and perhaps later have a mechanism by which to tell vegastrike to have a ship actually moving 400 cattle from earth to the moon and the moon taking in those 400 cattle (assuming they aren't shot down in between ofcourse).
Yeah , i am trying to figure out how proceduraly launch a vessel ( via the AI:Orders interface probably , duno yet . First i plan to do intra-system trips , like in the console
program , earth-moon to deliver goodies to poor miners ... ^^

I agree with all what you explained , and the use of 2D for the computation time sounds
good to me - AI pilots will follow a flight plan , the bases could be updated at player launch time , but perhaps in solo mode only ... Multiplayer will be again tricky , we can't
freeze the market because a pilot is out of fuel in a base and had lost his money in
a bad cards game named poker ... :lol:
....
...
Finally , i've got the last modifier i think .
It's for the cargo , and very simple modifier as you'll see :
//Create a Cargo for the specified starship.
Cargo CreateCargoForOwnerStarship( const Cockpit *cockpit, const Unit *base, int i )
{
Cargo cargo;
cargo.quantity = 1;
cargo.volume = 1;
cargo.price = 0;

string locationSystemName = cockpit->GetUnitSystemName(i);
string locationBaseName = cockpit->GetUnitBaseName(i);
string destinationSystemName = _Universe->activeStarSystem()->getFileName();
string destinationBaseName = (base != NULL) ? Cockpit::MakeBaseName(base) : "";

bool needsJumpTransport = (locationSystemName != destinationSystemName);
bool needsInsysTransport = (locationBaseName != destinationBaseName);

static const float shipping_price_base =
XMLSupport::parse_float( vs_config->getVariable( "physics", "shipping_price_base", "0" ) );
static const float shipping_price_insys =
XMLSupport::parse_float( vs_config->getVariable( "physics", "shipping_price_insys", "1000" ) );
static const float shipping_price_perjump =
XMLSupport::parse_float( vs_config->getVariable( "physics", "shipping_price_perjump", "25000" ) );

cargo.price = shipping_price_base;
cargo.content = cockpit->GetUnitFileName(i);
cargo.category = "starships/My_Fleet";

if (needsJumpTransport) {
vector< string > jumps;
_Universe->getJumpPath(
locationSystemName,
destinationSystemName,
jumps);
VSFileSystem::vs_dprintf(3, "Player ship needs transport from %s to %s across %d systems",
locationBaseName.c_str(),
destinationSystemName.c_str(),
jumps.size());
cargo.price += shipping_price_perjump * (jumps.size() - 1);
} else if (needsInsysTransport) {
VSFileSystem::vs_dprintf(3, "Player ship needs insys transport from %s to %s",
locationBaseName.c_str(),
destinationBaseName.c_str());
cargo.price += shipping_price_insys;
}

return cargo;
}
These previous BaseComputer functions should be rewritten for the dynamic market .
They could just ask the Market lib instead of the configuration file .
Correct ?

EDIT : I forgot the python side ... So there is a modifier in the Modules/trading.py
But again , a very light operation .
Perhaps the computation part of your lib for vs could be in python ?
I mean the maths part .
Look what they do :

Code: Select all

class trading:
    def __init__(self):
        self.last_ship=0
        self.quantity=4
        self.price_instability=0.01
        self.count=0
    def SetPriceInstability(self, inst):
        self.price_instability=inst
      
    def SetMaxQuantity (self,quant):
        self.quantity=quant
      
    def Execute(self):
        self.count+=1
        if (self.count<3):
            return
        self.count=0
        quant = (vsrandom.random()*(self.quantity-1))+1
        un = VS.getUnit (self.last_ship)
        if (un.isNull()):
            self.last_ship=0
        else:
            if (un.isSignificant()):
                if (un.isPlayerStarship()==-1):
                    global production
                    name = un.getName()
                    faction= un.getFactionName()
                    if un.isPlanet():
                        name = un.getFullname();
                        faction="planets"
                    prad=production.get((name,faction))
                    if None==prad:
                        prad= getImports(name,faction)
                        production[(name,faction)]=prad
                    if len(prad):
                        prod=prad[vsrandom.randrange(0,len(prad))]
                        cargo=VS.getRandCargo(int(prod[3]+prod[4]),prod[0])
                        if (cargo.GetCategory()==prod[0]):
                            removeCargo=False
                            if (prod[3] or prod[4]):
                                ownedcargo=un.GetCargo(cargo.GetContent())
                                quant=ownedcargo.GetQuantity()
                                #if un.getName()=="mining_base" and (cargo.GetContent()=="Tungsten" or cargo.GetContent()=="Space_Salvage"):
                                #    debug.debug("Mining "+str(quant)+" from "+str(prod[3])+" to "+str(prod[4]))
                                if (quant<prod[3]-prod[4] or quant==0):
                                    quant=int(prod[3]+vsrandom.uniform(-1,1)*prod[4])
                                    #if un.getName()=="mining_base" and (cargo.GetContent()=="Tungsten" or cargo.GetContent()=="Space_Salvage"):                                   
                                    #    debug.debug("Will add quant "+str(quant))
                                    if (quant>0):
                                        cargo.SetQuantity(quant)
                                        price = prod[1]+vsrandom.uniform(-1,1)*prod[2]
                                        cargo.SetPrice(cargo.GetPrice()*price)
                                        debug.debug("Adding "+str(quant)+" of "+cargo.GetContent()+" cargo for "+str(price))
                                        un.addCargo(cargo)
                                    else:
                                        removeCargo=True
                                elif quant>prod[3]+prod[4]:
                                   removeCargo=True
                            else:
                                removeCargo=True
                            if removeCargo:
                                ownedcargo=un.GetCargo(cargo.GetContent())
                                if (ownedcargo.GetQuantity()):
                                    debug.debug("Removing one "+ownedcargo.GetContent())
                                    
                                    un.removeCargo(ownedcargo.GetContent(),ownedcargo.GetQuantity()/3+1,0)
            self.last_ship+=1
        

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:I agree with all what you explained , and the use of 2D for the computation time sounds
good to me - AI pilots will follow a flight plan , the bases could be updated at player launch time , but perhaps in solo mode only ... Multiplayer will be again tricky , we can't
freeze the market because a pilot is out of fuel in a base and had lost his money in
a bad cards game named poker ... :lol:
In light of multiplayer (and people hanging around in space too long, perhaps it is indeed better to calculate it always and see if we can fiddle with the thread's priority.
These previous BaseComputer functions should be rewritten for the dynamic market .
They could just ask the Market lib instead of the configuration file .
Correct ?

EDIT : I forgot the python side ... So there is a modifier in the Modules/trading.py
But again , a very light operation .
Perhaps the computation part of your lib for vs could be in python ?
I mean the maths part .
Look what they do :

Code: Select all

[snip
both would seem to be possible. the python code seems at first glance to also determine the amount of stuff that is available in the bases.


On a sidenote, I would like to know what this other project is you plan to use market with. Also I am still looking forward to the report of the cmake configuration errors.
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 »

(and people hanging around in space too long
Thank you for the correction, i was so tired and inverted the situation ...
:roll:

Next ... Python .
For the management of stocks your c++ lib is perfect .
It is 50% of what we need or more because you provide also the quantity of products
available .
What you don't do actually is the work around prices , and as there are calls to python
scripts in the c++ source , we'll have to deal with that too .
_Comment out all the python modifiers we find first then replace with new code linked to Market ?
_Or just find where are done the calls to python in the c++ code and comment out there .
_Or create new python script scaled to Market Lib needs and call them inplace of the old
trade.py ?

I'm gonna do the CMAKE for you now ...

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 report !

The C compiler identification is MSVC 15.0.30729.1
The CXX compiler identification is MSVC 15.0.30729.1
Check for working C compiler using: Visual Studio 9 2008
Check for working C compiler using: Visual Studio 9 2008 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 9 2008
Check for working CXX compiler using: Visual Studio 9 2008 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Could NOT find EXPAT (missing: EXPAT_LIBRARY EXPAT_INCLUDE_DIR)
CMake Error at D:/program files/cmake-2.8.11-win32-x86/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find EXPAT (missing: EXPAT_LIBRARY EXPAT_INCLUDE_DIR)
Call Stack (most recent call first):
D:/program files/cmake-2.8.11-win32-x86/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
D:/program files/cmake-2.8.11-win32-x86/share/cmake-2.8/Modules/FindEXPAT.cmake:50 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:12 (find_package)


Configuring incomplete, errors occurred!
I could give the expat i use in my working modified project for windows ,
( have no real time to do that meanwhile .... ) ;
the other fail is about CPPUNIT_INCLUDE and DIR .

You intentionally removed expat , but that is an extra work for the dev to find the package ( the first time i tried to use your lib , it was the first time i heard about Expat...)

EDIT : I finally found that EXPAT is xmlparse.lib ...
That's written nowhere ^^ .

ANd CPPUNIT are your tests i don't use ... but i configured them , and ...
The generation works .
I tried a quick build , all failed because of your :
4>Build log was saved at "file://c:\NIDOTEST\makestupidproductionoptions.dir\Release\BuildLog.htm"
:lol:

I'm joking , i think it's just a question of header inputs that are not defined good .
wait ...
1>c:\vegastrike-market-master\src\Base.hpp(6) : fatal error C1083: Cannot open include file: 'cppunit/TestCaller.h': No such file or directory
1>c:\vegastrike-market-master\src\XMLNode.hpp(6) : fatal error C1083: Cannot open include file: 'expat.h': No such file or directory
1>..\vegastrike-market-master\src\Cargo.cpp(84) : error C2039: 'at' : is not a member of 'std::map<_Kty,_Ty>'
Well , i had the same problem the first time i used your lib , that's why i ripped out the TESTS to have only market in the project .

I AM NOT CLIENT FOR YOUR TESTS BED . ( :lol: )

Seriously , i never used tests and it sound to me like a waste of time .
Probably not , as it is rigorous procedure , but i don't like that , can't explain why .
I'm more artist than scientist probably ....

Anyway , if someone want to use your CMAKE for windows , with some efforts that will work .
Okay , it's so boring , please let me do some fun things today ?
:wink:

EDIT : THAT DON'T WORK , EVEN WHEN CMAKE SAY OK !
The build contains only the projects , the folders are not copied into it .
That can be done manually , but it's not the way that works .
Last edited by ezee on Sun May 31, 2015 8:52 am, edited 1 time in total.

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 »

By boring , i don't mean Market lib is boring , it's all the contrary .
The CMAKE thing is boring ... for me .

Look at the clean autogenerated web site github can make for your visibility :
http://ezeer.github.io/Vegastrike_Market/

Nice uh ?

As you are able to code a portable thing , i will probably remove from Github that project
now . I'm not in competition with you , so i can still work in private my own versions and
let your project grow without the shadow of my fork.

EDIT : But as this is a headache to have your solution running on my environnement ,
and that i have a working solution for it now, i suggest you add me in your project and wecould work together on it ? Me on the windows part i mean .
I suggest also for your windows users more details about the procedure to install it , otherwise you will not have a lot of clients ( no time to figure out how to do ... )
For all that reasons , i keep my window version , just because it is working after my efforts to make it work . Why do portable things if they don't work at all ?
It's better to have separate code in that case .

What do you think about that ?
:)

PS: My ' other ' project is not a commercial thing , just an other video game that will use Ogre3d
as renderer , Market Lib for the trading aspects of RPG style , Bullet probably for the physics engine , ENET probably for the network , OpenAL for music and sounds .
Perhaps SDL for Joystick inputs .
SImulation , RPG , multiplayer game .
You'll have to pay to learn more . ( :lol: )

EDIT 2 : I had a closer look into your other projects in GitHub NIDO, and ...
ARE YOU WRITING A COMPILER ? :shock:
Well , i'm really not at this level of dev , and i understand better why you use CPPUNIT.
I understand your goals , but they are somewhere too much technicals for me ( i am autodidact and i missed a lot of things ... )

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 »

Hey Nido ?
I wanted to share with you something that is fabulous to me , from my "AI guru " ,
that is in relation with my final goal for AI economical strategy :
" Overview

Kohonen Self Organising Feature Maps, or SOMs as I shall be referring to them from now on, are fascinating beasts. They were invented by a man named Teuvo Kohonen, a professor of the Academy of Finland, and they provide a way of representing multidimensional data in much lower dimensional spaces - usually one or two dimensions. This process, of reducing the dimensionality of vectors, is essentially a data compression technique known as vector quantisation. In addition, the Kohonen technique creates a network that stores information in such a way that any topological relationships within the training set are maintained. "
Follow this link , you will understand how i imagine the influences of AI factions in the game, or their equivalent economical power in the Universe . I have no direct solution
in mind , but the root of my expectations is here : http://www.ai-junkie.com/ann/som/som1.html

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:EDIT : But as this is a headache to have your solution running on my environnement ,
and that i have a working solution for it now, i suggest you add me in your project and wecould work together on it ? Me on the windows part i mean .
I suggest also for your windows users more details about the procedure to install it , otherwise you will not have a lot of clients ( no time to figure out how to do ... )
For all that reasons , i keep my window version , just because it is working after my efforts to make it work . Why do portable things if they don't work at all ?
It's better to have separate code in that case .
I wouldn't say it 'don't work at all'. I'd love to give more info on how to install it, but since I lack a working windows environment, any instructions I create will be made up on the spot and untested.Hence I decided to wait for someone with an actual windows environment in order for him/her to guide me on that. Having two different build systems is a bad thing. Especially when one of them works on multiple platforms. People will notice the configuration software they are used to, use it, and later find out that the person who created that buildsystem had left the project and nobody knows how it works, so it generally doesn't. It is better to have one system which everybody has at least a bit of understanding of.

Regarding fixing the problems you have:

CPPUNIT is a dependency that is apparently disturbingly hard to use on windows. Luckily, this is only used in the unittests, so those can be disabled in case cppunit is not found. So you don't need to worry about this anymore (not that it was even required beforehand. well, some code dependend on it erronously, but that's fixed).

EXPAT however is definitely required for the economy to work. As in, you can't even compile it without it no matter how you do things. Installing http://sourceforge.net/projects/expat/f ... e/download (to its default path) should be enough to get it to work with the version of market I just pushed to github.

So, all in all, assuming you follow the instructions above (or in the README file), you should be able to generate a visual studio project file out of cmake now. Let me know how it went
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 wouldn't say it 'don't work at all'.
ah ah ah .
Yeah , that is abusive , but i was upset by sourceforge when i have written this line .
( they have issue in their Git/Svn actually , and i possibly lost datas ...

I have seen your last changes and commented your last commits for windows users in github . Thank you for taking care of us , i will try again later , cause i'm tired to configure
things all day long since 4 days ( my new project in sourceforge for example + all other things i do ...)

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 »

' have done some cleaning in my version , made the build of the .lib , separated the
console programe from the lib itself .

Now there is a folder " Examples " where i placed the first old console test , renamed " Ex1 "
I will learn how to use the lib in deep by making other examples , ordered by level of complexity . I hope you'll like it , you can see the changes here :
https://github.com/Ezeer/Vegastrike_Market
: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 »

Hi Nido .

As client of your lib , i would like to have in the future :

_ Time implementation

In the examples of games that i will make with/for it , the bases should be able to report their build progressions ,delivery time , etc ...
You could use the same portable code used by vegastrke for time ?
Look please -> http://vegastrikevo.sourceforge.net/veg ... ource.html

I'd like to setup for exemple a factory with prdefined time ,that could be expressed
in milliseconds with real numbers .
Something like SetBuildMaxTime(real t) , real GetBuildMaxTime() , real GetTimeLeft()

**** TOP SECRET
( in stardate.py )
# Independent of the date system used, this will scale how fast time progresses
# in VS.
# 0.1 will mean 10000 (real) seconds (~3h) = 1 (VS) year
# 1 will mean 1000 (real) seconds (~17min) = 1 (VS) year
# 2 will mean 500 (real) seconds (~ 8min) = 1 (VS) year ... ie time is twice as fast
SCALEFACTOR = 0.02 # ~14h gameplay = 1 VS year
*******************



_ Workers implementation

A base could be defined to fully work with (x) people on it , and the GetTimeLeft()
would vary if there is more or less workers on it .
So again , somewhere functions like
Base::SetWorkersMx(UINT max);
UINT Base::GetWorkers() ;
void PayWorker( UINT w ) ; // one worker in a std::vector or map if he has a name ...
And all other kind of stuff
Also that would be one job for the Governor to manage the " crew " , by firing or hiring
employes following the state of the economy .


I can make these things , but it could be better for your lib to provide that kind of stuff,
that could work for Vegastrike and every games ?

Thank you .

ZDIT : CMAKE not working , please add some options to disable CPPUNIT for windows
Or leave it as this but this will be for advanced endusers on windows, that already know
and use CPPUNIT ( just my humble opinion here ^^ ).
Note that visual studio has a test suite intagrated ( that i never have used ... ) :
http://en.wikipedia.org/wiki/Visual_Stu ... _Framework
And also missing option :
" PKG_CONFIG_EXECUTABLE-NOTFOUND "
Last edited by ezee on Mon Jun 01, 2015 8:17 pm, edited 1 time in total.

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've found a python code that adds Bases to system randomly , following predefined rules.
I think that's done only when the milkyway is generated for the first time , but not sure .
That will be tricky to add a dynamic market in vegastrike because of theway c++ and python files works together .

So i put in this thread the references i find to have an helper at coding time ...
The code : ( in generate_dyn_universe.py )

Code: Select all

doNotAddBasesTo={"enigma_sector/heavens_gate":1,"sol_sector/celeste":1,"enigma_sector/enigma":1,"enigma_sector/niven":1,"Gemini":1,"Crucible/Cephid_17":1}

def AddBasesToSystem (faction,sys):
    if (sys in doNotAddBasesTo):
        return
    slash = sys.find("/")
    if (slash!= -1):
        if (sys[0:slash] in doNotAddBasesTo):
            return
    if faction in faction_ships.factions:
        fsfac= list(faction_ships.factions).index(faction)
        numbases=0
#               numplanets=VS.GetGalaxyProperty(sys,"num_planets");
        numjumppoints=VS.GetNumAdjacentSystems(sys);
        if (numjumppoints<4):
            if (vsrandom.random()>=.25):
                numbases=1
        elif (vsrandom.random()>=.005):
            if (numjumppoints<7):
                numbases=vsrandom.randrange(1,int(numjumppoints/2)+1)
            elif numjumppoints==7:
                numbases=vsrandom.randrange(1,6)
            else:
                numbases=vsrandom.randrange(1,numjumppoints+1)
        if numbases==0:
            return
        shiplist=[]
        nums=[]
        for i in xrange(numbases):
            whichbase = faction_ships.bases[fsfac][vsrandom.randrange(0,len(faction_ships.bases[fsfac]))]
            if whichbase in shiplist:
                nums[shiplist.index(whichbase)]+=1
            else:
                shiplist.append(whichbase)
                nums.append(1)
        tn =[]
        for i in xrange(len(shiplist)):
            tn+=[ (shiplist[i],nums[i])]
        fg_util.AddShipsToFG(fg_util.BaseFGInSystemName (sys),faction,tn,sys)

numericalfaction=0

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 »

************************ IMPORTANT *********************************

I was wondering how treat a Market base in vegastrike , and the Unit class seemed to be
the best choice . I was thinking about the enhancement class for the implementation .

I just found a piece of code that show that a base in VS is a unit :
( in unit.py )
def isBase (un):
unit_fgid = un.getFlightgroupName()
retval = unit_fgid=="Base"
return retval and not un.isSun()
That is something to fix , the FlightGroup that serves for everything !
It's because of that that it's very difficult to follow where the things go .
Moon and earth , a flightgroup also ? :lol:

Anyway , we'll have to deal with that ...
ANd the python part of vegastrike must be perfectly known ...
It's like the moon , one face is visible while the other is to be explored .
I know the c++ part for 70% , 1 % in python .
ToDO : WORK .
:mrgreen:

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
Post Reply