You must be logged in to post messages.
Please login or register

AI & RM Scripting
Moderated by Sebastien, Leif Ericson

Hop to:    
loginhomeregisterhelprules
Bottom
Topic Subject: Some AI questions: chat-to-player and lumber/mining camp
posted 09-18-19 01:33 AM CT (US)   
So, I'm trying to send some chats to player. I copied and pasted the tribute algorithm from CPSB.doc
; Schedule 15 minute timer for the first time

(defrule
(true)
=>
(enable-timer 2 900)
(disable-self))

; Every 15 minutes ask for tribute and wait 5 minutes to get it.
; Restart 15 minute timer.

(defrule
(timer-triggered 2)
=>
(disable-timer 2)
(enable-timer 2 900)
(chat-to-player 1 "Give me 500 gold in the next 5 minutes.")
(clear-tribute-memory 1 gold)
(enable-timer 1 300))

; Tribute not received in time, declare player 1 to be an enemy.
; No need to ask for tribute again - disable both timers.

(defrule
(timer-triggered 1)
=>
(disable-timer 1)
(disable-timer 2)
(chat-to-player 1 "Time is up. We are enemies now")
(set-stance 1 enemy))

; Tribute received in time. Disable the 5 minute timer

(defrule
(players-tribute-memory 1 gold greater-or-equal 500)
=>
(disable-timer 1)
(clear-tribute-memory 1 gold)
(chat-to-player 1 "Thanks"))
The only thing I modified was checking if the player was allied before asking for tribute. Now, what happens is that chats get sent, but I only hear the chat sound, I don't see the sent text. So, What am I missing?


The other thing is more of a noob question. I want the AI to build some lumber/mining camps or mills, near the corresponding resources. How is it done?
Even with this rule
(defrule
(resource-found stone) ;
(can-build mining-camp)
=>
(build mining-camp)
)
nothing happens and villagers walk a lot to mine gold and stone. Any help?
Replies:
posted 09-18-19 04:28 AM CT (US)     1 / 6  
I think this topic is in the wrong place.

Proud Member of Black Forest Studios
Co-creator of Silent Evil - Voted Best Multiplayer Scenario of 2009
and The Seas of Egressa - Voted Best Multiplayer Scenario of 2010
posted 09-18-19 07:32 AM CT (US)     2 / 6  
Hey Zungen, I moved the topic to the AI scripting forum.

Did it work before you added the ally condition? Did you use (players-stance 1 ally) as the condition? I haven't seen this happen before.

For the lumber camp and mining camp stuff, you'll want different rules for wood, gold, and stone. It's possible that you need to add a line (set-strategic-number sn-camp-max-distance 30). You can change the 30 to whatever distance you want. It is the max distance from the town center that the AI will build mining camps and lumber camps. Also, add the line (set-strategic-number sn-cap-civilian-builders 5) to make sure that the cap isn't currently set to 0.

It's also possible that escrow might be delaying building construction. Escrow is when the AI sets aside resources for more expensive items such as techs. You can stop the AI from doing this by adding the line (set-escrow-percentage wood 0) to see if that fixes it. If it does, you should create similar set-escrow-percentage lines for each resource.

~`o´~|\  Join the fresh and exciting AI Ladder for its fourth season!
´ `  |_\
       |    Learn the joy of AI scripting in my guide: The World of AI Scripting
______|______
 \        /
   .....Hinga Dinga Durgen! - SpongeBob
  `-=<.__.>=-´

[This message has been edited by Leif Ericson (edited 09-18-2019 @ 07:33 AM).]

posted 09-18-19 10:59 AM CT (US)     3 / 6  
Yes. I've noticed I posted in the wrong forum, but I realized it too late


I didn't try the script before applying the allied condition, but now that you mention it, I should. What I did test was adding a chat-to-player effect in this rule

(defrule
(true)
=>
(enable-timer 2 900)
(disable-self))
and it worked, so it may be related to the allied condition

Now, suppose it works testing without allied condition. What should the next step be? I want the allied player to ask for tributes only when both players are allied, because later on he'll change diplomacy.

Suppose it doesn't work without allied condition. What could it be?

About builders, I did add a (set-strategic-number sn-camp-max-distance 30) and tried with different distances and nothing worked. BUT I do have a really low villager builder count, so it may be related, because this guys have to build plenty of buildings. Is it possible to raise priority of a building construction? My best guess is using a elapsed-time condition in the AI, so they build all their camps and mills before barracks and stables.
By the way, do I need to add a build camp/mill command or will the villagers do it on their own?

I'll have to test all these thing the next week, though, so we'll see what happens then and I'll tell you

Edit: I just added
(defrule
(dropsite-min-distance stone/gold/wood > 6)
(can-build mining/lumber-camp)
=>
(build mining/lumber-camp)
)
and the AI started building camps.

Now, regarding the messages, I tried modifying the allied condition and there wasn't anything different.
I also tried to do a workaround: instead of sending chat to player, set-signal and in triggers, if signal set, send message. The result was the same. I'm running out of ideas.


Edit 2: it seems that neither the AI or Trigger Stuido like characters like this: áéíóúàèìòù.I ended up replacing the offending ANSI characters with utf-8 equivalents, using this
https://www.indalcasa.com/programacion/html/tabla-de-codificaciones-de-caracteres-entre-ansi-utf-8-javascript-html/

So that's the solution to the invisible chat or text or whatever issue


Edit 3: the first camp has 0 issues. As soon as the gold near the first camp is gone, the villagers go walking to the next gold/stone patch and DON'T construct a camp. They just mine and go walking to Town Center or previous camp
I have
(set-strategic-number sn-camp-max-distance 300)
(set-strategic-number sn-[i]all-resources[/i]-dropsite-distance 4)
(set-strategic-number sn-maximum-town-size 50)
and
(defrule
(dropsite-min-distance gold > 6)
(can-build mining-camp)
=>
(build mining-camp)
)

[This message has been edited by Zungen (edited 09-19-2019 @ 02:07 AM).]

posted 09-19-19 08:14 AM CT (US)     4 / 6  
The mines they are walking to are over 6 tiles away from the current mining camps and TC, right? Are escrow percentages set to 0? I can do some testing this evening to see what might be going on.

Glad you figured out the chat issue. That makes sense.

Edit:

By the way, if you're scripting an AI for random maps, we have another forum just for AI scripting that you might be interested in: http://forums.aiscripters.com/. We also have a discord group. Those spaces are visited more frequently right now.

~`o´~|\  Join the fresh and exciting AI Ladder for its fourth season!
´ `  |_\
       |    Learn the joy of AI scripting in my guide: The World of AI Scripting
______|______
 \        /
   .....Hinga Dinga Durgen! - SpongeBob
  `-=<.__.>=-´

[This message has been edited by Leif Ericson (edited 09-19-2019 @ 09:40 AM).]

posted 09-19-19 07:15 PM CT (US)     5 / 6  
Yes, I set escrow to zero, so if you'd like to help me, it would be really cool!
posted 09-19-19 09:31 PM CT (US)     6 / 6  
The quickest way would be to either post your script here if it's short or attach it in an email. Email is in my profile. I'll try to look at it tomorrow or Saturday. No promises on a Friday night.

~`o´~|\  Join the fresh and exciting AI Ladder for its fourth season!
´ `  |_\
       |    Learn the joy of AI scripting in my guide: The World of AI Scripting
______|______
 \        /
   .....Hinga Dinga Durgen! - SpongeBob
  `-=<.__.>=-´
Age of Kings Heaven » Forums » AI & RM Scripting » Some AI questions: chat-to-player and lumber/mining camp
Top
You must be logged in to post messages.
Please login or register
Hop to:    
Age of Kings Heaven | HeavenGames