Advertisement
MagicWinnie

Untitled

Mar 14th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.00 KB | None | 0 0
  1. import powerstand
  2. psm = powerstand.init()
  3. #psm = powerstand.init_test()
  4.  
  5. '''
  6. psm.orders.line_on("m5", 1)
  7. psm.orders.line_on("m5", 2)
  8. psm.orders.line_on("e3", 1)
  9. psm.orders.line_on("e3", 2)
  10. psm.orders.line_on("e3", 3)
  11. '''
  12.  
  13. print("Фактические контракты:")
  14. for receipt in psm.exchange:
  15.     print("Контрагент:", receipt.agent)
  16.     # None = оператор, иначе это другой игрок
  17.     print("Объём:", receipt.flux)
  18.     # Плюс = покупка, минус = продажа
  19.     print("Цена за МВт:", receipt.price)
  20.     print("")
  21.  
  22.  
  23.  
  24. if psm.tick >= 0 and psm.tick <= 2:
  25.     psm.orders.buy(5, 5)
  26.  
  27. '''
  28. if psm.tick >= 44 and psm.tick <= 48:
  29.    psm.orders.buy(2, 5)
  30. '''
  31.  
  32. def get_con():
  33.     total = 0
  34.     total += psm.forecasts.house[psm.tick + 2].upper0 * 2
  35.     total += psm.forecasts.factory[psm.tick + 2].upper0
  36.     total += psm.forecasts.hospital[psm.tick + 2].upper0 * 2
  37.     return total
  38.  
  39. def get_gen():
  40.     total = 0
  41.     for obj in psm.objects:
  42.         if obj.type == "wind" and obj.power.now.generated >= 0:
  43.             total += psm.forecasts.wind[psm.tick + 2].upper0
  44.             break
  45.     total += psm.forecasts.sun[psm.tick + 2].upper0 * 2
  46.     return total
  47.  
  48. try:
  49.     if get_gen() - get_con() > 0:
  50.         psm.orders.sell(get_gen() - get_con(), 7)
  51.     elif get_gen() - get_con() < 0:
  52.         psm.orders.buy(abs(get_gen() - get_con()), 1)
  53. except Exception as e:
  54.     print(e)
  55.     pass
  56.  
  57.  
  58.  
  59. '''
  60. if psm.total_power.generated-psm.total_power.consumed < 0:
  61.    psm.orders.diesel("M3", min(5, abs(psm.total_power.generated-psm.total_power.consumed)))
  62. elif psm.total_power.generated-psm.total_power.consumed > 0:
  63.    psm.orders.sell(psm.total_power.generated-psm.total_power.consumed, receipt.price-0.89)
  64.  
  65. if psm.total_power.generated-psm.total_power.consumed < 0:
  66.    psm.orders.buy(abs(psm.total_power.generated-psm.total_power.consumed), receipt.price+0.9)
  67. '''
  68.  
  69.  
  70. psm.save_and_exit()
  71. #print("\n".join(psm.orders.humanize()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement