FLAME’s Future
271
xmachine_message_consumer_spending* current_message =
get_first_consumer_spending_message(consumer_spending_messages);
while(current_message)
{
/* If the vacancy message refers to this mall*/
if(agent->id == current_message->mall_id)
{
if(consumercnt {
consumers[consumercnt]=current_message->person_id;
spending[consumercnt]=current_message->spending;
consumercnt++;
}
}
/* Move onto next message to check */
current_message = get_next_consumer_spending_message(current_message,
consumer_spending_messages);
}
/* Sell goods until no consumer can buy more goods */
int firmsnumber=5;
while(can_buy)
{
/* Count consumers not buying */
consumer_count = 0;
/* Loop though consumer list */
for(i=0; i {
/* If firms left */
if(firmsnumber > 0)
{
/* If enough spending to buy */
if(spending[i] >= agent->firm_1_price)
{
/* Buy one good */
agent->firm_1_stock = agent->firm_1_stock - 1;
spending[i] = spending[i] - agent->firm_1_price;
/* If zero stock for current firm then dismiss */
}
else consumer_count++;
}
}
/* If consumers not buying */
if(consumer_count == consumercnt) can_buy = 0;
}
/* Loop though consumer list */
for(i=0; i {
add_consumer_spent_message(consumer_spent_messages,consumers[i],
spending[i], MESSAGE_RANGE, agent->x, agent->y, 0.0f);
}
return 0;
}
__FLAME_GPU_FUNC__ int Goods_market_c(xmachine_memory_Mall* agent,
xmachine_message_firm_stock_list* firm_stock_messages)
Précédent

- 300/329

Suivant