Crusade AI Project

Upload your latest creations here.
Please note that by posting comments to posts in this forum you forfeit your personal copyright on whatever you post. AI Scripters reserves the right to re-use objective comments in script reviews without requiring the posting author's permission. Credit, where appropriate will be given in such cases.
User avatar
Alevo1
Guru
Posts: 835
Joined: Thu Aug 04, 2011 10:10 am
Location: England

Re: Crusade AI Project

Post by Alevo1 »

For that I set food-timer1 to 48 and food-timer2 to 23 every time I press the villager button

User avatar
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Re: Crusade AI Project

Post by Campeador »

Thanks for the info. I'll try to add it.

One thing. I have an error in the line
(up-modify-goal G-MAX-FARMS s:* sn-food-gatherer-percentage)

of this rule

Code: Select all

; Farm Building
(defrule
	(up-get-fact unit-type-count villager G-MAX-FARMS)
	(up-modify-goal G-MAX-FARMS s:* sn-food-gatherer-percentage)
	(up-modify-goal G-MAX-FARMS c:/ 100)
	(up-get-fact unit-type-count villager-fisherman G-MATH-1)
	(up-modify-goal G-MAX-FARMS g:- G-MATH-1)
	(up-get-fact unit-type-count villager-forager G-MATH-1)
	(up-modify-goal G-MAX-FARMS g:- G-MATH-1)
	(up-get-fact unit-type-count villager-hunter G-MATH-1)
	(up-modify-goal G-MAX-FARMS g:- G-MATH-1)
	(up-get-fact unit-type-count villager-shepherd G-MATH-1)
	(up-modify-goal G-MAX-FARMS g:- G-MATH-1)
	(building-type-count-total farm g:< G-MAX-FARMS)
=>
	(build farm)
)
The constant for the goal G-MAX-FARMS is defined. :P

User avatar
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Re: Crusade AI Project

Post by Campeador »

Apart from the previous error, I have anotehr quite similar in this line:
(up-modify-goal G-REAL-HOUSING-HEADROOM g:- G-MATH-1)

The whole rule is:

Code: Select all

(defrule
	(population-headroom < 5)
	(up-get-player-fact my-player-number housing-headroom 0 G-REAL-HOUSING-HEADROOM)
	(up-get-player-fact my-player-number up-resource-amount amount-queued-count G-MATH-1)
	(up-modify-goal G-REAL-HOUSING-HEADROOM g:- G-MATH-1)

	(up-get-player-fact my-player-number building-type-count-total house  G-MATH-2)
	(up-get-player-fact my-player-number building-type-count-total town-center  G-MATH-3)
	(up-modify-goal G-MATH-2 g:+ G-MATH-3)
	(up-modify-goal G-MATH-2 c:* 5)

	(up-get-player-fact my-player-number building-type-count-total castle  G-MATH-3)
	(up-modify-goal G-MATH-3 c:* 20)
	(up-modify-goal G-REAL-HOUSING-HEADROOM g:- G-MATH-2)
	(up-modify-goal G-REAL-HOUSING-HEADROOM g:- G-MATH-3)

	(up-compare-goal G-REAL-HOUSING-HEADROOM < 5)
	(up-pending-objects c: house == 0)
	(up-can-build 0 c: house)
=>
	(up-build house)
)
Does anyone have an answer? The idea of that line is just to substract the number of units who are being trained (goal G-MATH-1) to real goal who stores the housing headroom.

scripter64
Waheguru
Posts: 5891
Joined: Fri Jan 16, 2009 8:36 pm

Re: Crusade AI Project

Post by scripter64 »

The up-modify-goal/sn can only be in the Action part of the rule. It can't be used as a Fact, unfortunately.

User avatar
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Re: Crusade AI Project

Post by Campeador »

So my last two doubts were because a confunsion between facts and actions. What silly mistakes. :lol:

Errors resolved. I'll continue making my AI, at a slow rate :rolleyes: , and adding force drop and any other interesting suggestions that you make me.

P.D: The new power of the UP makes me feel like a newbie. B)

User avatar
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Re: Crusade AI Project

Post by Campeador »

Next request. I need a table with EVERY UP constants that I could need for my AI. I've copied some of them from The Horde and Barbarian, but I have them disorganized.

One consequence of it is that I had a bug because I used:
(defconst idle-type-villager 0)

and later the condition:
(unit-type-count-total idle-type-villager < 5)

That problem has been resolved, so don't worry for that. But a file with a complete collection of UP constants should make my scripting much easier, avoiding possible future problems. B)

Archon
Waheguru
Posts: 1905
Joined: Sat Nov 08, 2003 9:22 am

Re: Crusade AI Project

Post by Archon »

Campeador wrote:But a file with a complete collection of UP constants should make my scripting much easier, avoiding possible future problems. B)
With UP there come a file called UserPatchConst.per that is exactly that.

User avatar
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Re: Crusade AI Project

Post by Campeador »

Hahaha. Thanks for the info, I didn't remember that small thing. :lol:

Just for curiosity. What use has idle-type-villager got? I can count idle villagers without it, but I have curiosity.

User avatar
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Re: Crusade AI Project

Post by Campeador »

Crusade has the same power, but I've updated it to 4.42b.

Difference? It is 1.c compatible again. None difference for UP and FE.

scripter64
Waheguru
Posts: 5891
Joined: Fri Jan 16, 2009 8:36 pm

Re: Crusade AI Project

Post by scripter64 »

Campeador! Great to see you! :)

Post Reply