Page computer Player Strategy Builder Guide ai expert Documentation



Download 488.45 Kb.
Page4/11
Date02.02.2017
Size488.45 Kb.
#15186
1   2   3   4   5   6   7   8   9   10   11

Examples

#load-if-defined BRITON-CIV

(defrule

(true)


=>

(chat-to-all "I am Briton")

(disable-self)

)

#end-if


#load-if-defined TURKISH-CIV

(defrule


(true)

=>

(chat-to-all "I am Turkish")



(disable-self)

)

#end-if


#load-if-defined JAPANESE-CIV

(defrule


(true)

=>

(chat-to-all "I am Japanese")



(disable-self)

)

#end-if


Conditional Loading and User-Defined Constants

A combination of conditional loading and user-defined constants can be very powerful. One of the common uses is scaling of parameters. Depending on the conditions, parameters with the same names are given different values. This technique reduces the number of needed rules and makes code more readable.


Example:
#load-if-defined DEATH-MATCH

(defconst dark-age-villagers 6)

#else

(defconst dark-age-villagers 22)



#end-if
In Death Match games the code sets the dark-age-villagers constant to 6. In other games the code sets it to 22.
Note that constants can not be redefined. The code
(defconst my-constant 1)

(defconst my-constant 2)


will cause the following error
ERR2012: Constant Already Defined: my-constant
The error will not appear if the constant is defined more than once with the same value:
(defconst my-constant 1)

(defconst my-constant 1)



System Defined Constants

For every computer player the system defines a set of constants that make rule-writing easier and more efficient. Here they are:


my-player-number

(type
)


my-civ

(type )


my-unique-unit

(type )


my-unique-unit-upgrade

(type )


my-elite-unique-unit

(type )


my-unique-unit-line

(type )




Facts

Fact List


true 24

false 24

attack-soldier-count 24

attack-warboat-count 24

building-available 24

building-count 24

building-count-total 24

building-type-count 24

building-type-count-total 24

can-afford-building 24

can-afford-complete-wall
24


can-afford-research 25

can-afford-unit 25

can-build 25

can-build-gate
25


can-build-gate-with-escrow
25


can-build-wall
25


can-build-wall-with-escrow
26


can-build-with-escrow 26

can-buy-commodity 26

can-research 26

can-research-with-escrow 26

can-sell-commodity 26

can-spy 26

can-spy-with-escrow 26

can-train 26

can-train-with-escrow 27

cc-players-building-count
27


cc-players-building-type-count
27


cc-players-unit-count
27


cc-players-unit-type-count
27


cheats-enabled 27

civ-selected 27

civilian-population 28

commodity-buying-price 28

commodity-selling-price 28

current-age 28

current-age-time 28

current-score 28

death-match-game 28

defend-soldier-count 28

defend-warboat-count 28

difficulty 28

doctrine 28

dropsite-min-distance 28

enemy-buildings-in-town 28

enemy-captured-relics 28

escrow-amount 29

event-detected 29

food-amount 29

game-time 29

goal 29

gold-amount 29

housing-headroom 29

idle-farm-count 29

map-size 29

map-type 29

military-population 29

player-computer
29


player-human
29


player-in-game
30


player-number
30


player-resigned
30


player-valid
30


players-building-count
30


players-building-type-count
30


players-civ
30


players-civilian-population
30


players-current-age
30


players-current-age-time
30


players-military-population
31


players-population
31


players-score
31


players-stance
31


players-tribute
31


players-tribute-memory
31


players-unit-count
31


players-unit-type-count
31


population 31

population-cap 31

population-headroom 31

random-number 32

regicide-game 32

research-available 32

research-completed 32

resource-found 32

shared-goal 32

sheep-and-forage-too-far 32

soldier-count 32

stance-toward
32


starting-age 32

starting-resources 32

stone-amount 32

strategic-number 32

taunt-detected
32


timer-triggered 33

town-under-attack 33

unit-available 33

unit-count 33

unit-count-total 33

unit-type-count 33

unit-type-count-total 33

victory-condition 33

wall-completed-percentage
33


wall-invisible-percentage
33


warboat-count 34

wood-amount 34




Download 488.45 Kb.

Share with your friends:
1   2   3   4   5   6   7   8   9   10   11




The database is protected by copyright ©ininet.org 2024
send message

    Main page