Пример #1
0
 private void buyFrom(Human other) {
   // Show that the agents have engaged in another trade
   incrementTrades();
   other.incrementTrades();
   // Check each commodity for trading value
   for (int i = 0; i < Commodity.NUM_COMM; i++) {
     // If the buyer is low in the commodity...
     if (checkStatus(i) == CommodityStatus.DEFICIENT) {
       // And the seller is satisfied...
       if (other.checkStatus(i) == CommodityStatus.SATISFIED) {
         // Let the trades begin!
         trade(i, other);
       } else {
         // If the seller is also low, the good is scarce and price expectations rise
         expPrice[i] *= 1.01;
         other.expPrice[i] *= 1.01;
       }
       // If both agents are satisfied, the good is not as scarce and price expectations fall
     } else if (other.checkStatus(i) == CommodityStatus.SATISFIED) {
       expPrice[i] *= .99;
       other.expPrice[i] *= .99;
     }
   }
 }