Page 1 of 2

MFI (beta)

Posted: Fri Feb 14, 2014 5:16 am
by dead_kniight
This is my first AI , so all suggestions and feedback is welcome. MFI will not rush and usually won't attack until castle age if it detects you are too weak, normally it attacks mostly in late castle \ early imperial age.

I am pretty sure this version is not even in working condition, uploading it because I need help in the mining camp part. AI won't build any more mining camp unless mines near the previous one have finished i.e. if there is even one gold mine left near my first gold mining camp it won't build another until the mines have been exhausted. Tried a lot of different things but nothing seems to work. Any help would be appreciated.

strategy : none so far
civ : any(except goths, code still in progress for goths)
map : any land map (no docks or Scandinavia)
mode : conquest
population cap : 200
user patch compatible only

Note: This AI as I mentioned above is my first AI, hence it may contain quite a few peculiarities/bugs. If you notice any please tell me.

Re: MFI (beta)

Posted: Fri Feb 14, 2014 5:46 am
by scripter64
Welcome to the forum! I tried the file (renamed training-units-faulty.per to training-units.per to make it load) and the AI started without any errors. Is the problem related to some specific improper behavior or script loading?

Re: MFI (beta)

Posted: Fri Feb 14, 2014 5:57 pm
by dead_kniight
scripter64 wrote:Welcome to the forum! I tried the file (renamed training-units-faulty.per to training-units.per to make it load) and the AI started without any errors. Is the problem related to some specific improper behavior or script loading?
Actually the script is without any syntax error. The problem is that MFI would not train any military units if that file is loaded. :(

Re: MFI (beta)

Posted: Fri Feb 14, 2014 8:21 pm
by scripter64
It looks like the goal names are defined to 0 in constants.per, which is an invalid goal id.
For UP, the goal ids span from 1 to 512. For v1.0c, it's 1 to 40.

The following goals must be changed, so they refer to unique goal ids. For example:

Code: Select all

(defconst g-can-use-escrow 10)

(defconst g-can-train-villager 20)
(defconst g-can-train-sword 21)
(defconst g-can-train-spear 22)
(defconst g-can-train-skirm 23)
(defconst g-can-train-scout 24)
(defconst g-can-train-arrow 25)
(defconst g-can-train-knight 26)
(defconst g-can-train-cav-arrow 27)
(defconst g-can-train-unq-unit 28)
(defconst g-can-train-hnd-can 29)
(defconst g-can-train-treb 30)
(defconst g-can-train-bmb-can 31)
(defconst g-can-train-ram 32)
After adjusting these defconsts, these names can be used to refer to the associated goals at those id numbers.
All goals default to -1, so if you would like them to start as 0, you would need a rule like this:

Code: Select all

(defrule
	(true)
	=>
	(set-goal g-can-use-escrow 0)
	(set-goal g-can-train-villager 0)
	(set-goal g-can-train-sword 0)
	(set-goal g-can-train-spear 0)
	(set-goal g-can-train-skirm 0)
	(set-goal g-can-train-scout 0)
	(set-goal g-can-train-arrow 0)
	(set-goal g-can-train-knight 0)
	(set-goal g-can-train-cav-arrow 0)
	(set-goal g-can-train-unq-unit 0)
	(set-goal g-can-train-hnd-can 0)
	(set-goal g-can-train-treb 0)
	(set-goal g-can-train-bmb-can 0)
	(set-goal g-can-train-ram 0)
	(disable-self)
)
Essentially, defconst is just giving a name to a number. The set-goal command is what actually changes a goal's value.
In other words, these 2 lines will both set goal #20 to 5, after defconst'ing the text "g-can-train-villager" as 20:
- (set-goal g-can-train-villager 5)
- (set-goal 20 5)

Here's the adjusted constants.per: http://pastebin.com/c7Y5NHaR
Two other notes:
1. your AI seems stronger when escrow is disabled
- maybe leave g-can-use-escrow defconst'ed to 0 (effectively disabling it) until it's optimized
2. be careful when building the lumber camp too early
- it sometimes gets stuck at 10/10 population, all food gatherers, with no wood for a house
- a temporary fix might be to add a (game-time > 150) condition for building the first camp

Other than that, it seems to work well and was able to win against the built-in AI :devil

Re: MFI (beta)

Posted: Fri Feb 14, 2014 9:35 pm
by dead_kniight
@scripter64

Thank you very much. I wanted to use goals so as to train units as required i.e. training scouts when monks detected instead of knights. This will make it so much easier.
Thank you again. :D :D

Re: MFI (beta)

Posted: Sun Feb 16, 2014 6:32 am
by Promiskuitiv
Welcome to the forum dead knight! :)

Re: MFI (beta)

Posted: Mon Feb 17, 2014 4:04 am
by dead_kniight
@Promiskuitiv
Hi there, thanks for the welcome. People here are really helpful. Seeing the quality of AIs you guys make, I never thought mine would even be noticed.
By the way, I just love your AI. Barbarian and Promi are my favorite allies in 4v4 games against Nightmare, UnfairSteel and other two mayan standard AIs

Re: MFI (beta)

Posted: Fri Jun 20, 2014 3:36 am
by jdstankosky
I have been away from the forums for a year or longer! :o I'm glad to see that people are still finding their way onto the site! :D

I find it interesting that your first script is UP only! You will have a totally different mindset to scripting than those of us who went through the school of hard knocks on 1.0c!

I still have yet to find what I did with my game installation CDs, but once I do I'm going to check this out!

Re: MFI (beta)

Posted: Mon Jul 21, 2014 4:18 am
by dead_kniight
Typed a bloody big comment asking for some advice on the ai and lost all as soon as i tried uploading the new file. :lol: :lol: :lol:
btw why can't i upload a newer version.

@jdstankosky
Hey thanks man and i guess :unsure: ...... Welcome back :D :D :D :D

Re: MFI (beta)

Posted: Mon Jul 21, 2014 4:26 pm
by Campeador
Hi dead_kniight!

It is not so strange that we notice your AI. Even the strongest AIs started being weak. For example, UnfairestEel was a newcomer in the scripting world a couple of years ago and currently one of his AI is the number one inthe Ladder.

I'll test your AI after to judge The Horde vsa Barbarian match, to give you a few comments or suggestions. B)

Welcome to the world of :head .


:P