home *** CD-ROM | disk | FTP | other *** search
/ GameStar Special 2002 April / GSSH42002.iso / MODS / AgeOfEmpires2 / Raw.exe / AI / defensive.per < prev    next >
Text File  |  2001-05-21  |  20KB  |  934 lines

  1. ;Svede
  2. ; This AI file is used for the Saxons in my Battle of Mount Badon Scenario for an ES competition.
  3.  
  4. ; ============== GROUPS - most of these will work for any file
  5.  
  6. (defrule
  7.     (true)
  8. =>
  9.  
  10.     (set-strategic-number sn-percent-enemy-sighted-response 100)
  11.     (set-strategic-number sn-enemy-sighted-response-distance 25)
  12.     (set-strategic-number sn-blot-exploration-map 1)
  13.     (disable-self)
  14. )
  15.  
  16. ; ============== ATTACK GROUPS - changing percent attack soldiers will make an AI weak or tough
  17.  
  18. (defrule
  19.     (true)
  20. =>
  21.     (set-strategic-number sn-town-defend-priority 7)
  22.     (set-strategic-number sn-task-ungrouped-soldiers 25)
  23.     (set-strategic-number sn-percent-attack-soldiers 3)
  24.     (set-strategic-number sn-number-defend-groups 22)
  25.     (set-strategic-number sn-number-explore-groups 0)
  26.     (disable-self)
  27. )
  28.  
  29.  
  30.  
  31. ; ============== VILLAGER ASSIGNMENT - most of these will work for any file
  32.  
  33. (defrule
  34.     (true)
  35. =>
  36.     (set-strategic-number sn-percent-civilian-explorers 0)
  37.     (set-strategic-number sn-percent-civilian-builders 15)
  38.     (set-strategic-number sn-percent-civilian-gatherers 85)
  39.     (set-strategic-number sn-cap-civilian-explorers 0)
  40.     (set-strategic-number sn-cap-civilian-gatherers 100)
  41.     (set-strategic-number sn-food-gatherer-percentage  35)
  42.     (set-strategic-number sn-gold-gatherer-percentage  40)
  43.     (set-strategic-number sn-stone-gatherer-percentage 0)
  44.     (set-strategic-number sn-wood-gatherer-percentage  25)
  45.     (set-strategic-number sn-maximum-gold-drop-distance 20)
  46.     (set-strategic-number sn-maximum-stone-drop-distance 20)
  47.     (set-strategic-number sn-maximum-food-drop-distance 20)
  48.     (disable-self)
  49. )
  50.  
  51.  
  52.  
  53. ; ============== ATTACKING - The AI will attack once at 1100 seconds and then again every 1400 sec, provided it has enough defense soldiers.
  54.  
  55. (defrule
  56.     (game-time > 2000)
  57. =>
  58.     (attack-now)
  59.     (enable-timer 7 2000)
  60.     (disable-self)
  61.     (chat-local-to-self "first attack")
  62. )
  63.  
  64. (defrule
  65.     (timer-triggered 7)
  66.     (defend-soldier-count >= 100)
  67. =>
  68.     (attack-now)
  69.     (disable-timer 7)
  70.     (enable-timer 7 2000)
  71.     (chat-local-to-self "other attacks")
  72. )
  73.  
  74. ; ============== BUILD LISTS
  75.  
  76.  
  77. ;maintain housing
  78. (defrule
  79.     (housing-headroom less-than 4)
  80.     (population-headroom greater-than 0)
  81.     (can-build house)
  82. =>
  83.     (build house)
  84.     (chat-local-to-self "house")
  85. )
  86.  
  87. (defrule
  88.     (building-type-count-total blacksmith less-than 1)
  89.     (can-build blacksmith)
  90. =>
  91.     (build blacksmith)
  92.     (chat-local-to-self "blacksmith")
  93. )
  94.  
  95. (defrule
  96.     (building-type-count-total market less-than 1)
  97.     (can-build market)
  98. =>
  99.     (build market)
  100.     (chat-local-to-self "market")
  101. )
  102.  
  103. (defrule
  104.     (building-type-count-total university less-than 1)
  105.     (can-build university)
  106. =>
  107.     (build university)
  108.     (chat-local-to-self " university ")
  109. )
  110.  
  111. (defrule
  112.     (building-type-count-total monastery less-than 1)
  113.     (can-build monastery)
  114. =>
  115.     (build monastery)
  116.     (chat-local-to-self " monastery ")
  117. )
  118.  
  119.  
  120. (defrule
  121.     (building-type-count-total castle less-than 1)
  122.     (can-build castle)
  123. =>
  124.     (build castle)
  125.     (chat-local-to-self "castle")
  126. )
  127.  
  128. (defrule
  129.     (building-type-count-total barracks less-than 1)
  130.     (can-build barracks)
  131. =>
  132.     (build barracks)
  133.     (chat-local-to-self "barracks")
  134. )
  135.  
  136. (defrule
  137.     (building-type-count-total archery-range less-than 1)
  138.     (can-build archery-range)
  139. =>
  140.     (build archery-range)
  141.     (chat-local-to-self "range")
  142. )
  143.  
  144.  
  145. ; ============== MILITARY UNITS
  146.  
  147.  
  148. (defrule
  149.     (unit-type-count-total militiaman-line < 15)
  150.     (can-train militiaman-line)
  151. =>
  152.     (train militiaman-line)
  153.     (chat-local-to-self "infantry")
  154. )
  155.  
  156. (defrule
  157.     (unit-type-count-total spearman-line < 15)
  158.     (can-train spearman-line)
  159. =>
  160.     (train spearman-line)
  161.     (chat-local-to-self "spearman")
  162. )
  163.  
  164. (defrule
  165.     (unit-type-count-total throwing-axeman-line < 50)
  166.     (can-train throwing-axeman-line)
  167. =>
  168.     (train throwing-axeman-line)
  169.     (chat-local-to-self "axeman")
  170. )
  171.  
  172. (defrule
  173.     (unit-type-count-total archer-line < 15)
  174.     (can-train archer-line)
  175. =>
  176.     (train archer-line)
  177.     (chat-local-to-self "archer")
  178. )
  179.  
  180. (defrule
  181.     (unit-type-count-total skirmisher-line < 50)
  182.     (can-train skirmisher-line)
  183. =>
  184.     (train skirmisher-line)
  185.     (chat-local-to-self "skirmisher")
  186. )
  187.  
  188.  
  189.  
  190. ; ========================== UPGRADES - I usually use the same rules for upgrades for all civs.  If the AI has a certain number of units, it tries to upgrade them.  There are no rules for Hand Cannons or Bombards below.
  191.  
  192. ; problem with escrow - give up
  193.  
  194. (defrule
  195.     (or
  196.         (or
  197.             (escrow-amount wood > 2000)
  198.             (escrow-amount food > 2000)
  199.         )
  200.         (or
  201.             (escrow-amount gold > 3000)
  202.             (escrow-amount stone > 3000)
  203.         )
  204.     )
  205. =>
  206.     (release-escrow wood)
  207.     (release-escrow food)
  208.     (release-escrow gold)
  209.     (release-escrow stone)
  210.     (set-goal 16 0)
  211. )
  212.  
  213.  
  214. ; ////////////////////////////////////////////////////
  215.  
  216. ; sets initial goal for escrow to make sure there are villagers
  217.  
  218. ; sets escrow
  219.  
  220. (defrule
  221.     (true)
  222. =>
  223.     (set-escrow-percentage wood 40)
  224.     (set-escrow-percentage food 40)
  225.     (set-escrow-percentage gold 40)
  226.     (set-escrow-percentage stone 40)
  227. )
  228.  
  229. ; /////////////////////////////////////////////////////
  230. ;UNIT UPGRADES
  231.  
  232.  
  233.  
  234.  
  235. (defrule
  236.     (goal 16 0)
  237.     (unit-type-count man-at-arms > 6)
  238.     (can-research-with-escrow ri-long-swordsman)
  239. =>
  240.     (release-escrow wood)
  241.     (release-escrow food)
  242.     (release-escrow gold)
  243.     (release-escrow stone)
  244.       (research ri-long-swordsman)
  245.     (chat-local-to-self "research long swordsman ")
  246. )
  247.  
  248. (defrule
  249.     (goal 16 0)
  250.     (unit-type-count long-swordsman > 6)
  251.     (can-research-with-escrow ri-two-handed-swordsman)
  252. =>
  253.     (release-escrow wood)
  254.     (release-escrow food)
  255.     (release-escrow gold)
  256.     (release-escrow stone)
  257.       (research ri-two-handed-swordsman)
  258.     (chat-local-to-self "research two-handed-swordsman")
  259. )
  260.  
  261. (defrule
  262.     (goal 16 0)
  263.     (unit-type-count two-handed-swordsman > 6)
  264.     (can-research-with-escrow ri-champion)
  265. =>
  266.     (release-escrow wood)
  267.     (release-escrow food)
  268.     (release-escrow gold)
  269.     (release-escrow stone)
  270.       (research ri-champion)
  271.     (chat-local-to-self "research champion")
  272. )
  273.  
  274. (defrule
  275.     (goal 16 0)
  276.     (unit-type-count-total spearman > 2)
  277.     (can-research-with-escrow ri-pikeman)
  278. =>
  279.     (release-escrow wood)
  280.     (release-escrow food)
  281.     (release-escrow gold)
  282.     (release-escrow stone)
  283.       (research ri-pikeman)
  284.     (chat-local-to-self "research pike")
  285. )
  286.  
  287. (defrule
  288.     (goal 16 0)
  289.     (unit-type-count archer > 6)
  290.     (can-research-with-escrow ri-crossbow)
  291. =>
  292.     (release-escrow wood)
  293.     (release-escrow food)
  294.     (release-escrow gold)
  295.     (release-escrow stone)
  296.     (research ri-crossbow)
  297.     (chat-local-to-self "research crossbow")
  298. )
  299.  
  300.  
  301. (defrule
  302.     (unit-type-count-total skirmisher > 2)
  303.     (can-research-with-escrow ri-elite-skirmisher)
  304. =>
  305.     (release-escrow wood)
  306.     (release-escrow food)
  307.     (release-escrow gold)
  308.     (release-escrow stone)
  309.     (research ri-elite-skirmisher)
  310.     (chat-local-to-self "research elite skirmisher")
  311. )
  312.  
  313.  
  314.  
  315. ; ////////////////////////WEAPONS//////////////////
  316.  
  317. (defrule
  318.     (goal 16 0)
  319.     (can-research-with-escrow ri-forging)
  320. =>
  321.     (release-escrow wood)
  322.     (release-escrow food)
  323.     (release-escrow gold)
  324.     (release-escrow stone)
  325.      (research ri-forging)
  326.     (chat-local-to-self "research forging")
  327. )
  328.  
  329. (defrule
  330.     (goal 16 0)
  331.     (can-research-with-escrow ri-iron-casting)
  332. =>
  333.     (release-escrow wood)
  334.     (release-escrow food)
  335.     (release-escrow gold)
  336.     (release-escrow stone)
  337.     (research ri-iron-casting)
  338.     (chat-local-to-self "research iron-casting")
  339. )
  340.  
  341. (defrule
  342.     (goal 16 0)
  343.     (can-research-with-escrow ri-blast-furnace)
  344. =>
  345.     (release-escrow wood)
  346.     (release-escrow food)
  347.     (release-escrow gold)
  348.     (release-escrow stone)
  349.     (research ri-blast-furnace)
  350.     (chat-local-to-self "research blast-furnace")
  351. )
  352.  
  353. ;ARCHER UPGRADES -- cost food/gold
  354. (defrule
  355.     (goal 16 0)
  356.     (can-research-with-escrow ri-fletching)
  357. =>
  358.     (release-escrow wood)
  359.     (release-escrow food)
  360.     (release-escrow gold)
  361.     (release-escrow stone)
  362.     (research ri-fletching)
  363.     (chat-local-to-self "research fletching")
  364. )
  365.  
  366. (defrule
  367.     (goal 16 0)
  368.     (can-research-with-escrow ri-bodkin-arrow)
  369. =>
  370.     (release-escrow wood)
  371.     (release-escrow food)
  372.     (release-escrow gold)
  373.     (release-escrow stone)
  374.     (research ri-bodkin-arrow)
  375.     (chat-local-to-self "research bodkin-arrow")
  376. )
  377.  
  378. (defrule
  379.     (goal 16 0)
  380.     (can-research-with-escrow ri-bracer)
  381. =>
  382.     (release-escrow wood)
  383.     (release-escrow food)
  384.     (release-escrow gold)
  385.     (release-escrow stone)
  386.     (research ri-bracer)
  387.     (chat-local-to-self "research bracer")
  388. )
  389.  
  390. (defrule
  391.     (goal 16 0)
  392.     (or
  393.         (unit-type-count-total archer-line > 3)
  394.         (or
  395.             (unit-type-count-total skirmisher-line > 3)
  396.             (unit-type-count-total cavalry-archer-line > 3)
  397.         )
  398.     )
  399.     (can-research-with-escrow ri-padded-archer-armor)
  400. =>
  401.     (release-escrow wood)
  402.     (release-escrow food)
  403.     (release-escrow gold)
  404.     (release-escrow stone)
  405.     (research ri-padded-archer-armor)
  406.     (chat-local-to-self "research padded-archer-armor")
  407. )
  408.  
  409. (defrule
  410.     (goal 16 0)
  411.     (or
  412.         (unit-type-count-total archer-line > 3)
  413.         (or
  414.             (unit-type-count-total skirmisher-line > 3)
  415.             (unit-type-count-total cavalry-archer-line > 3)
  416.         )
  417.     )
  418.     (can-research-with-escrow ri-leather-archer-armor)
  419. =>
  420.     (release-escrow wood)
  421.     (release-escrow food)
  422.     (release-escrow gold)
  423.     (release-escrow stone)
  424.     (research ri-leather-archer-armor)
  425.     (chat-local-to-self "research leather-archer-armor")
  426. )
  427.  
  428. (defrule
  429.     (goal 16 0)
  430.     (or
  431.         (unit-type-count-total archer-line > 3)
  432.         (or
  433.             (unit-type-count-total skirmisher-line > 3)
  434.             (unit-type-count-total cavalry-archer-line > 3)
  435.         )
  436.     )
  437.     (can-research-with-escrow ri-ring-archer-armor)
  438. =>
  439.     (release-escrow wood)
  440.     (release-escrow food)
  441.     (release-escrow gold)
  442.     (release-escrow stone)
  443.     (research ri-ring-archer-armor)
  444.     (chat-local-to-self "research ring-archer-armor")
  445. )
  446.  
  447. (defrule
  448.     (goal 16 0)
  449.     (or
  450.         (unit-type-count-total militiaman-line > 3)
  451.         (unit-type-count-total spearman-line > 3)
  452.     )
  453.     (can-research-with-escrow ri-scale-mail)
  454. =>
  455.     (release-escrow wood)
  456.     (release-escrow food)
  457.     (release-escrow gold)
  458.     (release-escrow stone)
  459.     (research ri-scale-mail)
  460.     (chat-local-to-self "research scale-mail")
  461. )
  462.  
  463. (defrule
  464.     (goal 16 0)
  465.     (or
  466.         (unit-type-count-total militiaman-line > 3)
  467.         (unit-type-count-total spearman-line > 3)
  468.     )
  469.     (can-research-with-escrow ri-chain-mail)
  470. =>
  471.     (release-escrow wood)
  472.     (release-escrow food)
  473.     (release-escrow gold)
  474.     (release-escrow stone)
  475.     (research ri-chain-mail)
  476.     (chat-local-to-self "research chain-mail")
  477. )
  478.  
  479. (defrule
  480.     (goal 16 0)
  481.     (or
  482.         (unit-type-count-total militiaman-line > 3)
  483.         (unit-type-count-total spearman-line > 3)
  484.     )
  485.     (can-research-with-escrow ri-plate-mail)
  486. =>
  487.     (release-escrow wood)
  488.     (release-escrow food)
  489.     (release-escrow gold)
  490.     (release-escrow stone)
  491.     (research ri-plate-mail)
  492.     (chat-local-to-self "research plate-mail")
  493. )
  494.  
  495.  
  496. (defrule
  497.     (goal 16 0)
  498.     (or
  499.         (unit-type-count-total militiaman-line > 3)
  500.         (unit-type-count-total spearman-line > 3)
  501.     )
  502.     (can-research-with-escrow ri-tracking)
  503. =>
  504.     (release-escrow wood)
  505.     (release-escrow food)
  506.     (release-escrow gold)
  507.     (release-escrow stone)
  508.     (research ri-tracking)
  509.     (chat-local-to-self "research tracking")
  510. )
  511.  
  512. (defrule
  513.     (goal 16 0)
  514.     (or
  515.         (unit-type-count-total militiaman-line > 3)
  516.         (unit-type-count-total spearman-line > 3)
  517.     )
  518.     (can-research-with-escrow ri-squires)
  519. =>
  520.     (release-escrow wood)
  521.     (release-escrow food)
  522.     (release-escrow gold)
  523.     (release-escrow stone)
  524.     (research ri-squires)
  525.     (chat-local-to-self "research squires")
  526. )
  527.  
  528.  
  529. ;FORTRESS UPGRADES
  530. (defrule
  531.     (goal 16 0)
  532.     (can-research-with-escrow ri-hoardings)
  533. =>
  534.     (release-escrow wood)
  535.     (release-escrow food)
  536.     (release-escrow gold)
  537.     (release-escrow stone)
  538.     (research ri-hoardings)
  539.     (chat-local-to-self "research hoardings")
  540. )
  541.  
  542.  
  543. ;OTHER RESEARCH ITEMS
  544. (defrule
  545.     (goal 16 0)
  546.     (can-research-with-escrow ri-ballistics)
  547. =>
  548.     (release-escrow wood)
  549.     (release-escrow food)
  550.     (release-escrow gold)
  551.     (release-escrow stone)
  552.     (research ri-ballistics)
  553.     (chat-local-to-self "research ballistics ")
  554. )
  555.  
  556. (defrule
  557.     (goal 16 0)
  558.     (can-research-with-escrow ri-conscription)
  559. =>
  560.     (release-escrow wood)
  561.     (release-escrow food)
  562.     (release-escrow gold)
  563.     (release-escrow stone)
  564.     (research ri-conscription)
  565.     (chat-local-to-self "research conscription")
  566. )
  567.  
  568.  
  569. ;university stuff
  570. (defrule
  571.     (goal 16 0)
  572.     (can-research-with-escrow ri-masonry)
  573. =>
  574.     (release-escrow wood)
  575.     (release-escrow food)
  576.     (release-escrow gold)
  577.     (release-escrow stone)
  578.     (research ri-masonry)
  579.     (chat-local-to-self "research masonry")
  580. )
  581.  
  582. (defrule
  583.     (goal 16 0)
  584.     (can-research-with-escrow ri-architecture)
  585. =>
  586.     (release-escrow wood)
  587.     (release-escrow food)
  588.     (release-escrow gold)
  589.     (release-escrow stone)
  590.     (research ri-architecture)
  591.     (chat-local-to-self "research architecture")
  592. )
  593.  
  594. (defrule
  595.     (goal 16 0)
  596.     (can-research-with-escrow ri-stonecutting)
  597. =>
  598.     (release-escrow wood)
  599.     (release-escrow food)
  600.     (release-escrow gold)
  601.     (release-escrow stone)
  602.     (research ri-stonecutting)
  603.     (chat-local-to-self "research stonecutting")
  604. )
  605.  
  606.  
  607. ; ////////////////////MONK/////////////////
  608. (defrule
  609.     (goal 16 0)
  610.     (or
  611.         (cc-players-unit-type-count any-enemy monk > 1)
  612.                 (unit-type-count-total war-elephant-line > 2)
  613.     )
  614.     (can-research-with-escrow ri-faith)
  615. =>
  616.     (release-escrow wood)
  617.     (release-escrow food)
  618.     (release-escrow gold)
  619.     (release-escrow stone)
  620.     (research ri-faith)
  621.     (chat-local-to-self "research faith")
  622. )
  623.  
  624. (defrule
  625.     (goal 16 0)
  626.         (cc-players-unit-type-count any-enemy monk > 2)
  627.     (can-research-with-escrow ri-atonement)
  628. =>
  629.     (release-escrow wood)
  630.     (release-escrow food)
  631.     (release-escrow gold)
  632.     (release-escrow stone)
  633.     (research ri-atonement)
  634.     (chat-local-to-self "research atonement")
  635. )
  636.  
  637. (defrule
  638.     (goal 16 0)
  639.     (unit-type-count-total monk > 2)
  640.     (can-research-with-escrow ri-block-printing)
  641. =>
  642.     (release-escrow wood)
  643.     (release-escrow food)
  644.     (release-escrow gold)
  645.     (release-escrow stone)
  646.     (research ri-block-printing)
  647.     (chat-local-to-self "research block printing")
  648. )
  649.  
  650. (defrule
  651.     (goal 16 0)
  652.     (unit-type-count-total monk > 2)
  653.     (can-research-with-escrow ri-illumination)
  654. =>
  655.     (release-escrow wood)
  656.     (release-escrow food)
  657.     (release-escrow gold)
  658.     (release-escrow stone)
  659.     (research ri-illumination)
  660.     (chat-local-to-self "research illumination")
  661. )
  662.  
  663. (defrule
  664.     (goal 16 0)
  665.     (unit-type-count-total monk > 2)
  666.     (can-research-with-escrow ri-fervor)
  667. =>
  668.     (release-escrow wood)
  669.     (release-escrow food)
  670.     (release-escrow gold)
  671.     (release-escrow stone)
  672.     (research ri-fervor)
  673.     (chat-local-to-self "research fervor")
  674. )
  675.  
  676. (defrule
  677.     (goal 16 0)
  678.     (unit-type-count-total monk > 2)
  679.     (can-research-with-escrow ri-redemption)
  680. =>
  681.     (release-escrow wood)
  682.     (release-escrow food)
  683.     (release-escrow gold)
  684.     (release-escrow stone)
  685.     (research ri-redemption)
  686.     (chat-local-to-self "research redemption")
  687. )
  688.  
  689. (defrule
  690.     (goal 16 0)
  691.     (unit-type-count-total monk > 2)
  692.     (can-research-with-escrow ri-sanctity)
  693. =>
  694.     (release-escrow wood)
  695.     (release-escrow food)
  696.     (release-escrow gold)
  697.     (release-escrow stone)
  698.     (research ri-sanctity)
  699.     (chat-local-to-self "research sanctity")
  700. )
  701.  
  702. ;TOWERS
  703.  
  704. (defrule
  705.     (goal 16 0)
  706.     (building-type-count-total watch-tower > 1)
  707.     (can-research-with-escrow ri-guard-tower)
  708. =>
  709.     (release-escrow wood)
  710.     (release-escrow food)
  711.     (release-escrow gold)
  712.     (release-escrow stone)
  713.     (research ri-guard-tower)
  714.     (chat-local-to-self "research guard tower")
  715. )
  716.  
  717. (defrule
  718.     (goal 16 0)
  719.     (building-type-count-total guard-tower > 1)
  720.     (can-research-with-escrow ri-keep)
  721. =>
  722.     (release-escrow wood)
  723.     (release-escrow food)
  724.     (release-escrow gold)
  725.     (release-escrow stone)
  726.     (research ri-keep)
  727.     (chat-local-to-self "research keep")
  728. )
  729.  
  730. (defrule
  731.     (goal 16 0)
  732.     (or
  733.         (building-type-count-total castle > 0)
  734.         (building-type-count-total watch-tower-line > 2)
  735.     )
  736.     (can-research-with-escrow ri-murder-holes)
  737. =>
  738.     (release-escrow wood)
  739.     (release-escrow food)
  740.     (release-escrow gold)
  741.     (release-escrow stone)
  742.     (research ri-murder-holes)
  743.     (chat-local-to-self "research murder-holes")
  744. )
  745.  
  746. (defrule
  747.     (goal 16 0)
  748. (or
  749.         (building-type-count-total castle > 0)
  750.         (building-type-count-total watch-tower-line > 2)
  751.     )
  752.     (can-research-with-escrow ri-fortified-wall)
  753. =>
  754.     (release-escrow wood)
  755.     (release-escrow food)
  756.     (release-escrow gold)
  757.     (release-escrow stone)
  758.     (research ri-fortified-wall)
  759.     (chat-local-to-self "research fortifications")
  760. )
  761.  
  762.  
  763. ; ================ MARKET - just buys and sells when the price is right and stockpile low
  764.  
  765. ; ///////////////////////// FEUDAL
  766.  
  767. (defrule
  768.     (current-age == feudal-age)
  769.     (gold-amount >= 500)
  770.     (wood-amount <= 100)
  771.     (commodity-buying-price wood <= 100)
  772.     (can-buy-commodity wood)
  773. =>
  774.     (chat-local-to-self "Wood panic")
  775.     (buy-commodity wood)
  776. )
  777.  
  778. (defrule
  779.     (current-age == feudal-age)
  780.     (gold-amount >= 500)
  781.     (food-amount <= 100)
  782.     (commodity-buying-price food <= 100)
  783.     (can-buy-commodity food)
  784. =>
  785.     (chat-local-to-self "Food panic")
  786.     (buy-commodity food)
  787. )
  788.  
  789. (defrule
  790.     (current-age == feudal-age)
  791.     (gold-amount >= 600)
  792.     (stone-amount <= 100)
  793.     (commodity-buying-price stone <= 200)
  794.     (can-buy-commodity stone)
  795. =>
  796.     (chat-local-to-self "need stone")
  797.     (buy-commodity stone)
  798. )
  799.  
  800. (defrule
  801.     (current-age == feudal-age)
  802.     (wood-amount >= 500)
  803.     (or
  804.         (gold-amount < 100)
  805.         (food-amount < 100)
  806.     )
  807.     (commodity-selling-price wood >= 50)
  808.     (can-sell-commodity wood)
  809. =>
  810.     (chat-local-to-self "Gold panic; sell wood")
  811.     (sell-commodity wood)
  812. )
  813.  
  814. (defrule
  815.     (current-age == feudal-age)
  816.     (food-amount >= 1000)
  817.     (or
  818.         (gold-amount < 100)
  819.         (wood-amount < 100)
  820.     )
  821.     (can-sell-commodity food)
  822. =>
  823.     (chat-local-to-self "excess food")
  824.     (sell-commodity food)
  825. )
  826.  
  827. (defrule
  828.     (current-age == feudal-age)
  829.     (stone-amount >= 1000)
  830.     (or
  831.         (gold-amount < 100)
  832.         (wood-amount < 100)
  833.     )
  834.     (can-sell-commodity stone)
  835. =>
  836.     (chat-local-to-self "excess stone")
  837.     (sell-commodity stone)
  838. )
  839.  
  840. ;****************************CASTLE
  841. (defrule
  842.     (current-age == castle-age)
  843.     (gold-amount >= 1000)
  844.     (wood-amount <= 200)
  845.     (commodity-buying-price wood <= 100)
  846.     (can-buy-commodity wood)
  847. =>
  848.     (chat-local-to-self "Wood panic")
  849.     (buy-commodity wood)
  850. )
  851.  
  852. (defrule
  853.     (current-age == castle-age)
  854.     (gold-amount >= 500)
  855.     (wood-amount <= 100)
  856.     (can-buy-commodity wood)
  857. =>
  858.     (chat-local-to-self "Wood panic")
  859.     (buy-commodity wood)
  860. )
  861.  
  862. (defrule
  863.     (current-age == castle-age)
  864.     (gold-amount >= 1000)
  865.     (food-amount <= 200)
  866.     (commodity-buying-price food <= 100)
  867.     (can-buy-commodity food)
  868. =>
  869.     (chat-local-to-self "Food panic")
  870.     (buy-commodity food)
  871. )
  872.  
  873. (defrule
  874.     (current-age == castle-age)
  875.     (gold-amount >= 500)
  876.     (food-amount <= 100)
  877.     (can-buy-commodity food)
  878. =>
  879.     (chat-local-to-self "Food panic")
  880.     (buy-commodity food)
  881. )
  882.  
  883. (defrule
  884.     (current-age == castle-age)
  885.     (gold-amount >= 1200)
  886.     (stone-amount <= 200)
  887.     (commodity-buying-price stone <= 200)
  888.     (can-buy-commodity stone)
  889. =>
  890.     (chat-local-to-self "need stone")
  891.     (buy-commodity stone)
  892. )
  893.  
  894. (defrule
  895.     (current-age == castle-age)
  896.     (wood-amount >= 1000)
  897.     (or
  898.         (gold-amount < 200)
  899.         (food-amount < 200)
  900.     )
  901.     (commodity-selling-price wood >= 25)
  902.     (can-sell-commodity wood)
  903. =>
  904.     (chat-local-to-self "Gold panic; sell wood")
  905.     (sell-commodity wood)
  906. )
  907.  
  908. (defrule
  909.     (current-age == castle-age)
  910.     (food-amount >= 1200)
  911.     (or
  912.         (gold-amount < 200)
  913.         (wood-amount < 200)
  914.     )
  915.     (can-sell-commodity food)
  916. =>
  917.     (chat-local-to-self "excess food")
  918.     (sell-commodity food)
  919. )
  920.  
  921. (defrule
  922.     (current-age == castle-age)
  923.     (stone-amount >= 1000)
  924.     (or
  925.         (gold-amount < 200)
  926.         (wood-amount < 200)
  927.     )
  928.     (can-sell-commodity stone)
  929. =>
  930.     (chat-local-to-self "excess stone")
  931.     (sell-commodity stone)
  932. )
  933.  
  934.