mardi 17 mars 2015

In Netlogo, How can I coordinate randomly choosen turtle and it's characteristic?

I just want to build simple market model, and I have a question.


breed [ firms firm ]

breed [ consumers consumer ]

firms-own [ price ]

hogus-own [ money stock ]

globals [ m0 ]

...

and I made 100 customers and 10 firms, and set price of firm randomly from 0 to 10. Also, each consumer has initial capital of 100.

...

to setup

set m0 [ 0 ]

set m0 lput p0 m0

end



to go

tick

buy

sell

set m0 fput p0 m0

end



to-report p0

report [ price ] of one-of firms

end



to-report recent

report item ticks m0

end



to-report past

report item ( ticks - 1 ) m0

end


I made a list so that we can compare current and past price of firm.

But now I faced a problem.


I am trying to find a way to do this.

Each agent will choose random 5 firms out of 10 firms.

And it will compare it's past and current price. If it increased, consumer will buy it( which means increase stock)



to buy

if (recent > past and capital > 0) [

set capital capital - recent0

set stock stock + 1 ]

end



This is the way I tried, but I have a problem. Each agent shoud choose one of random firm. However, Since, every agent is bond by one code, they all buy same firm.

Is there any way to solve this problem?


Aucun commentaire:

Enregistrer un commentaire