FLAME’s Future
263
{
agent->price=lowest_price;
}
else
{
agent->price=agent->sprice;
}
/* Calculate price inflation by calculating the difference of
the prices from the new set price and the old */
agent->priceinflation=agent->price - agent->oldprice;
/* Send message stating offer price for goods with firm id
and the offer price */
/* Send message stating amount of stock to be sold by the firm
goodsproduced is an integer value of the productivity factor
multiplied by the man power the firm has - Refer to equation(2) */
agent->goodsproduced=(int)(agent->productivity * agent->numberofworkers);
/* Set the stock to be equal to the goods produced */
agent->stock=agent->goodsproduced;
/* Post message that firm is selling with firm id and the stock it has */
/*add_firm_stock_message(get_id(), get_stock());*/
/* New */
/* Goods to a random Mall */
mall_chosen=floor(GetRandomNumber(1,MALLSNO+1,rand48));
if((mall_chosen>0)&&(agent->stock > 0))
{
add_firm_stock_price_message(firm_stock_price_messages,agent->id,
agent->stock, agent->price, agent->mall_goods, MESSAGE_RANGE,
agent->x, agent->y, 0.0f);
}
else
{
agent->mall_goods=0;
}
return 0;
}
/** \fn Firm_4()
* \brief Calculates the stock being sold by the firm,
the revenue and the profits its earned*/
__FLAME_GPU_FUNC__ int Firm_4(xmachine_memory_Firm* agent,
xmachine_message_firm_stock_list* firm_stock_messages)
{
int revenue;
float ave_wage;
/* Find last stock message for firm says how much stock left */
xmachine_message_firm_stock* current_message =
get_first_firm_stock_message(firm_stock_messages);
while(current_message)
{
/* If the stock message relates to this firm */
if(agent->id == current_message->firm_id)
{
Précédent

- 292/329

Suivant