-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirstAI.per
More file actions
648 lines (589 loc) · 15.3 KB
/
Copy pathFirstAI.per
File metadata and controls
648 lines (589 loc) · 15.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
(defrule
(true)
=>
(set-strategic-number sn-minimum-civilian-explorers 0); minimum number of vills to explore
(set-strategic-number sn-cap-civilian-explorers 0); max number of vills to explore
(set-strategic-number sn-total-number-explorers 1); total number of explorers
(set-strategic-number sn-number-explore-groups 1); number of explore groups , unused by ai, always set equal to num of explorers
(set-strategic-number sn-initial-exploration-required 0); percent to explore before building
(disable-self)
)
(defrule
(true)
=>
(set-strategic-number sn-maximum-food-drop-distance 15)
(set-strategic-number sn-maximum-wood-drop-distance 15)
(set-strategic-number sn-maximum-stone-drop-distance 25)
(set-strategic-number sn-maximum-gold-drop-distance 25)
(set-strategic-number sn-maximum-hunt-drop-distance 15)
(set-strategic-number sn-maximum-fish-boat-drop-distance 15)
(set-strategic-number sn-mill-max-distance 15)
(set-strategic-number sn-cap-civilian-builders 10) ;max number of builders
(disable-self)
)
(defrule
(true)
=>
(set-strategic-number sn-gold-defend-priority 1)
(set-strategic-number sn-stone-defend-priority 0)
(set-strategic-number sn-forage-defend-priority 0)
(set-strategic-number sn-relic-defend-priority 0)
(set-strategic-number sn-town-defend-priority 0)
(set-strategic-number sn-task-ungrouped-soldiers 0) ; dont scatter villagers
(set-strategic-number sn-gather-idle-soldiers-at-center 0); useful for stopping tsa. how?
(set-strategic-number sn-minimum-town-size 1) ; defend enemy attack
(set-strategic-number sn-maximum-town-size 16)
(set-strategic-number sn-enemy-sighted-response-distance 2)
(disable-self)
)
(defrule
(true)
=>
(up-assign-builders c: house c: 2)
(disable-self)
)
(defrule
(true)
=>
(up-assign-builders c: castle c: 5)
(disable-self)
)
(defrule
(true)
=>
(up-assign-builders c: 621 c: 4) ; town-center-foundation = 621
;(up-assign-builders c: town-center c: 4) ; error: this will not work
(disable-self)
)
(defrule
(current-age == dark-age)
=>
(set-strategic-number sn-food-gatherer-percentage 60)
(set-strategic-number sn-wood-gatherer-percentage 40)
(set-strategic-number sn-gold-gatherer-percentage 0)
(set-strategic-number sn-stone-gatherer-percentage 0)
)
(defrule
(current-age == feudal-age)
=>
(set-strategic-number sn-food-gatherer-percentage 55)
(set-strategic-number sn-wood-gatherer-percentage 30)
(set-strategic-number sn-gold-gatherer-percentage 10)
(set-strategic-number sn-stone-gatherer-percentage 5)
)
(defrule
(current-age == castle-age)
=>
(set-strategic-number sn-food-gatherer-percentage 50)
(set-strategic-number sn-wood-gatherer-percentage 30)
(set-strategic-number sn-gold-gatherer-percentage 15)
(set-strategic-number sn-stone-gatherer-percentage 5)
(set-strategic-number sn-maximum-town-size 25)
)
(defrule
(current-age == imperial-age)
=>
(set-strategic-number sn-food-gatherer-percentage 50)
(set-strategic-number sn-wood-gatherer-percentage 30)
(set-strategic-number sn-gold-gatherer-percentage 15)
(set-strategic-number sn-stone-gatherer-percentage 5)
(set-strategic-number sn-maximum-town-size 36)
)
(defrule
(unit-type-count villager > 0 )
=>
(chat-local-to-self "I just made my first rule!!")
(disable-self)
)
;################### Age Advance rules
(defrule
(can-research feudal-age)
=>
(research feudal-age)
(chat-local-to-self "Feudal Age, here we come!")
)
(defrule
(can-research castle-age)
=>
(research castle-age)
(chat-local-to-self "Castle Age, here we come!")
)
(defrule
(can-research imperial-age)
=>
(research imperial-age)
(chat-local-to-self "Imperial Age, here we come!")
)
(defrule
(food-amount < 50)
(can-research ri-loom)
=>
(research ri-loom)
(chat-local-to-self "Researching loom.")
)
;***************************** Feudal Age Research ****************************
(defrule
(can-research ri-wheel-barrow)
=>
(research ri-wheel-barrow)
(chat-to-allies "Researching wheel barrow.")
)
(defrule
(current-age == imperial-age)
(can-research ri-man-at-arms)
=>
(research ri-man-at-arms)
(chat-to-allies "Researching man at arms.")
)
(defrule
(not(research-available ri-wheel-barrow))
(can-research ri-double-bit-axe)
=>
(research ri-double-bit-axe)
(chat-to-allies "Researching double bit axe.")
)
(defrule
(current-age == castle-age)
(not(research-available ri-double-bit-axe))
(can-research ri-gold-mining)
=>
(research ri-gold-mining)
(chat-to-allies "Researching gold mining.")
)
(defrule
(can-research ri-horse-collar)
=>
(research ri-horse-collar)
(chat-to-allies "Researching horse collar.")
)
(defrule
(current-age == castle-age)
(not(research-available ri-pikeman))
(can-research ri-scale-mail)
=>
(research ri-scale-mail)
(chat-to-allies "Researching scale mail armor.")
)
(defrule
(current-age == castle-age)
(research-completed ri-scale-mail)
(can-research ri-forging)
=>
(research ri-forging)
(chat-to-allies "Researching forging.")
)
; ################################## Castle Age Research
(defrule
(can-research ri-hand-cart)
=>
(research ri-hand-cart)
(chat-to-allies "Researching hand cart.")
)
(defrule
(can-research ri-bow-saw)
=>
(research ri-bow-saw)
(chat-to-allies "Researching bow saw.")
)
(defrule
(can-research ri-gold-shaft-mining)
=>
(research ri-gold-shaft-mining)
(chat-to-allies "Researching gold shaft mining.")
)
(defrule
(can-research ri-heavy-plow)
=>
(research ri-heavy-plow)
(chat-to-allies "Researching heavy plow.")
)
(defrule
(can-research ri-chain-mail)
=>
(research ri-chain-mail)
(chat-to-allies "Researching chain mail armor.")
)
(defrule
(can-research ri-iron-casting)
=>
(research ri-iron-casting)
(chat-to-allies "Researching iron casting.")
)
(defrule
(can-research ri-gold-shaft-mining)
=>
(research ri-gold-shaft-mining)
(chat-to-allies "Researching gold-shaft-mining.")
)
(defrule
(can-research ri-stone-shaft-mining)
=>
(research ri-stone-shaft-mining)
(chat-to-allies "Researching stone-shaft-mining.")
)
(defrule
(can-research ri-crop-rotation)
=>
(research ri-crop-rotation)
(chat-to-allies "Researching crop-rotation")
)
(defrule
(can-research ri-guilds)
=>
(research ri-guilds)
(chat-to-allies "Researching guilds.")
)
(defrule
(building-type-count-total castle > 0)
(can-research ri-murder-holes)
=>
(research ri-murder-holes)
)
(defrule
(building-type-count-total castle > 0)
(can-research ri-chemistry)
=>
(research ri-chemistry)
)
(defrule
(town-under-attack)
(can-research ri-fletching)
=>
(research ri-fletching)
(chat-to-allies "Researching fletching.")
)
(defrule
(town-under-attack)
(can-research ri-bodkin-arrow)
=>
(research ri-bodkin-arrow)
(chat-to-allies "Researching bodkin-arrow.")
)
(defrule
(town-under-attack)
(can-research ri-bracer)
=>
(research ri-bracer)
(chat-to-allies "Researching bracer.")
)
(defrule
(can-research ri-masonry)
(town-under-attack)
=>
(research ri-masonry)
(chat-to-allies "Researching masonry.")
)
(defrule
(current-age >= castle-age)
(can-research ri-stone-mining)
=>
(research ri-stone-mining)
(chat-to-allies "Researching stone mining.")
)
;#################################Market Rules#######################
(defrule
(current-age >= feudal-age)
(wood-amount > 400)
(or(gold-amount < 200)
(food-amount < 800))
(can-sell-commodity wood)
=>
(sell-commodity wood)
)
;Buy food if you have surplus gold.
(defrule
(current-age >= feudal-age)
(gold-amount > 400)
(food-amount < 800)
(can-buy-commodity food)
=>
(buy-commodity food)
)
;Sell food if you have surplus food.
(defrule
(current-age >= feudal-age)
(gold-amount < 200)
(food-amount > 1000)
(can-sell-commodity food)
=>
(sell-commodity food)
)
(defrule
(current-age == imperial-age)
(gold-amount < 500)
(food-amount > 1500)
(can-sell-commodity food)
=>
(sell-commodity food)
)
(defrule
(current-age == imperial-age)
(gold-amount < 800)
(wood-amount > 1500)
(can-sell-commodity wood)
=>
(sell-commodity wood)
)
;################################## building rules
(defrule
(can-build house)
(housing-headroom < 4) ;the difference between the current population and supportable population (not the
;amount of population houses support)
(population-headroom > 3) ;the difference between the current population and the population limit
=>
(chat-local-to-self "building house.")
(build house)
)
(defrule
(can-build house)
(housing-headroom < 15)
(building-type-count barracks > 2)
(population-headroom > 3) ;the difference between the current population and the population limit
=>
(chat-local-to-self "building house.")
(build house)
)
(defrule
(unit-type-count-total villager < 100)
(can-train villager)
=>
(train villager)
)
(defrule
(building-type-count-total house > 0) ; We want to build a house before a mill
(building-type-count-total mill == 0) ; Prevents the construction of multiple mills
(resource-found food) ; Builds a mill only if forage bushes or deer is found
(can-build mill)
=>
(chat-local-to-self "building mill.")
(build mill)
)
(defrule
(building-type-count-total lumber-camp == 0)
(resource-found wood)
(can-build lumber-camp)
=>
(chat-local-to-self "building lumbercamp.")
(build lumber-camp)
)
(defrule
(current-age >= feudal-age)
(dropsite-min-distance wood > 5)
(can-build lumber-camp)
=>
(build lumber-camp)
)
; build a gold mine in feudal age
(defrule
(current-age == feudal-age)
(building-type-count-total mining-camp == 0)
(resource-found gold)
(can-build mining-camp)
=>
(chat-local-to-self "building mining-camp.")
(build mining-camp)
)
;build a barrack in dark age
(defrule
(current-age == dark-age)
(game-time > 480)
(building-type-count-total barracks == 0)
(can-build barracks)
=>
(chat-local-to-self "building barracks.")
(build barracks)
)
; build a blacksmith
(defrule
(current-age >= feudal-age)
(building-type-count-total barracks > 0)
(building-type-count-total blacksmith == 0)
(can-build blacksmith)
=>
(chat-local-to-self "building blacksmith.")
(build blacksmith)
)
; build a market
(defrule
(current-age == feudal-age)
(building-type-count-total blacksmith > 0)
(building-type-count-total market == 0)
(can-build market)
=>
(chat-local-to-self "building market.")
(build market)
)
; build a stone mine in castle age
(defrule
(current-age >= feudal-age)
(building-type-count-total mining-camp > 0)
(resource-found stone)
(dropsite-min-distance stone > 5)
(can-build mining-camp)
=>
(chat-local-to-self "building mining-camp.")
(build mining-camp)
)
; 2nd mining camp for gold if necessary
(defrule
(current-age >= feudal-age)
(building-type-count-total mining-camp > 0)
(resource-found gold)
(dropsite-min-distance gold > 5)
(can-build mining-camp)
=>
(chat-local-to-self "building mining-camp.")
(build mining-camp)
)
; build a monastery
(defrule
(current-age == castle-age)
(building-type-count-total monastery == 0)
(can-build monastery)
=>
(chat-local-to-self "building monastery.")
(build monastery)
)
; build a university
(defrule
(current-age == castle-age)
(building-type-count-total university == 0)
(can-build university)
=>
(chat-local-to-self "building university.")
(build university)
)
(defrule
(current-age >= castle-age)
(building-type-count-total town-center < 3)
(can-build town-center)
=>
(chat-local-to-self "building town-center.")
(build town-center)
)
(defrule
(current-age >= castle-age)
(building-type-count-total university == 1)
(can-build castle)
=>
(chat-local-to-self "building castle.")
(build castle)
)
;build upto barracks in imperial age
(defrule
(current-age > castle-age)
(building-type-count-total barracks < 10)
(can-build barracks)
=>
(chat-local-to-self "building barracks.")
(build barracks)
)
;########################### Farms #########################
; keep farms at lower priority than buildings
(defrule
(building-type-count-total mill > 0);build mill before farms
(building-type-count-total lumber-camp > 0) ; We want a lumber camp before farms
(unit-type-count-total villager > 15)
(idle-farm-count == 0) ; Only build farms if there are no idle farms
(can-build farm)
=>
(chat-local-to-self "building farm.")
(build farm)
)
; research long swordsman
(defrule
(current-age == imperial-age)
(can-research ri-long-swordsman)
=>
(research ri-long-swordsman)
(chat-local-to-self "Researching Long Swordsman.")
)
; research two-handed-swordsman
(defrule
(can-research ri-two-handed-swordsman)
=>
(research ri-two-handed-swordsman)
(chat-local-to-self "Researching two-handed-swordsman.")
)
; research champion
(defrule
(can-research ri-champion)
=>
(research ri-champion)
(chat-local-to-self "Researching champion.")
)
; research pikeman
(defrule
(can-research ri-pikeman)
=>
(research ri-pikeman)
(chat-local-to-self "Researching pikeman.")
)
; research Halberdier
(defrule
(can-research ri-halberdier )
=>
(research ri-halberdier)
(chat-local-to-self "Researching halberdier.")
)
(defrule
(can-research ri-plate-mail)
=>
(research ri-plate-mail)
(chat-to-allies "Researching plate mail armor.")
)
(defrule
(can-research ri-blast-furnace)
=>
(research ri-blast-furnace)
(chat-to-allies "Researching blast furnace.")
)
(defrule
(can-research ri-conscription)
=>
(research ri-conscription)
(chat-to-allies "Researching conscription.")
)
(defrule
(current-age > castle-age)
(can-research ri-tracking)
=>
(research ri-tracking)
)
(defrule
(current-age > castle-age)
(can-research ri-squires)
=>
(research ri-squires)
)
(defrule
(current-age > castle-age)
(can-research ri-arson)
=>
(research ri-arson)
)
(defrule
(current-age > feudal-age)
(military-population <= 10)
(can-train spearman-line)
=>
(train spearman-line)
)
(defrule
(current-age > castle-age)
(can-train militiaman-line)
=>
(train militiaman-line)
)
(defrule
(current-age > castle-age)
(can-train spearman-line)
=>
(train spearman-line)
)
; be conservative as standard AI doesnt attack much
(defrule
(military-population >= 80)
=>
(attack-now)
)