AB-CE / examples

Repos for examples of abcEconomics simulations that can be extended from
Apache License 2.0
29 stars 23 forks source link

In Jupyter Notebook example, drug dealer does not run out of money #9

Closed pjakobsen closed 4 years ago

pjakobsen commented 4 years ago

You Say:

"When looking at round one one can see that after the customer offered 10 dollars, the 10 dollars are not available to him util the deal has either been accepted or rejected. After the drug dealer accepts the offer in the 0 round. The money is transfered to the drug dealer and the drugs to the customer.

In round 1, where the drug dealer runs out of drugs the 10 dollars go back to the customer."

but when I run the notebook, nothing seems to change: I simply get:

Customer offers 10 dollar: customer{'money': 90.0} drug_dealer{'drugs': 1.0} Drug Dealer accepts or rejects the offer: customer{'money': 100.0} drug_dealer{'drugs': 1.0}

Customer offers 10 dollar: customer{'money': 90.0} drug_dealer{'drugs': 1.0} Drug Dealer accepts or rejects the offer: customer{'money': 100.0} drug_dealer{'drugs': 1.0}

DavoudTaghawiNejad commented 4 years ago

The bug is fixed:

if offer.price >= 10 and self['drugs'] >= 1:

instead of

if offer.price >= 10 and self['drugs'] > 1: