How do I make the units on a side ignore/avoid an enemy unit

Discussion and development of scenarios and campaigns for the game.

Moderator: Forum Moderators

Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

Dacyn wrote:
Dave wrote:There are many fields internal to the engine which are inaccessible from WML, and which are used in determining the AI's behavior. It'd be thus impossible to program an AI in WML.
what would be an example of this?
Actually, thinking about it, all fields you could hardcode into the WML, I think. This'd be impractibly tedious to do though, and wouldn't really work, since if a user changed the stats for a unit in their WML, it wouldn't change in your scenario.

The bigger problem is that even though we've been saying WML is turing-complete, I don't think it is. Its array handling isn't sufficient for turing-completness, because you can't create your own arrays, or add items to arrays, etc. I believe it'd be impossible to calculate, for instance, all the tiles that a unit can move to, which would be essential to writing an AI.

Oh, and of course, I think users would notice when their AI runs 10,000 times as slow ;)

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

Dave wrote:Oh, and of course, I think users would notice when their AI runs 10,000 times as slow ;)
How slow is WML, anyway?
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn »

Dave wrote:The bigger problem is that even though we've been saying WML is turing-complete, I don't think it is. Its array handling isn't sufficient for turing-completness, because you can't create your own arrays, or add items to arrays, etc.
numbers+"+"+"*"+"while"=Turing-complete, IIRC.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

Dacyn wrote:
Dave wrote:The bigger problem is that even though we've been saying WML is turing-complete, I don't think it is. Its array handling isn't sufficient for turing-completness, because you can't create your own arrays, or add items to arrays, etc.
numbers+"+"+"*"+"while"=Turing-complete, IIRC.
Its been a while since I studied parsers and languages formally, but I'm pretty sure you'd need a general array mechanism.

Hmm....then again, it might be possible to kludge a general array mechanism into WML. :)

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

Elvish Pillager wrote:
Dave wrote:Oh, and of course, I think users would notice when their AI runs 10,000 times as slow ;)
How slow is WML, anyway?
If you tried to write something like an AI in it, it'd probably be seriously 10,000 times slower than C++.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn »

Here is how you can get a general array mechanism with just "+" and "while":
- the set of all integers can be defined.
- the set of all prime numbers can be defined.
- exponentiation can be defined.
- An array from prime numbers->integers can be coded by the cumulative product of a prime number to the power of its value in the array.
- All arrays can be coded into prime number->integer arrays.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

Dacyn wrote:Here is how you can get a general array mechanism with just "+" and "while":
- the set of all integers can be defined.
- the set of all prime numbers can be defined.
- exponentiation can be defined.
- An array from prime numbers->integers can be coded by the cumulative product of a prime number to the power of its value in the array.
- All arrays can be coded into prime number->integer arrays.
The main problem with this is that WML integers cannot assume any integer. They are generally limited to 2^31, although it varies by C++ implementation.

With such a limited set of numbers, your arrays would have a very small maximum size, and although you could chain arrays together, unlike nesting of [while] loops, this would only increase the array size linearly.

An easier way to try to kludge in arrays would be build variable names out of other variable names.

Either way might 'kind of' work, so I guess yes, you can say it's Turing complete. In which case, yes, if you hard-coded in all the unit stats, terrain stats, map, etc, you could possibly code an 'AI emulator' in WML. You still couldn't get units to attack properly (since you couldn't animate things properly). It'd also run slowly. As in, if you started running it in a complex position now on a 32 bit machine, it'd be somewhere in the 1970s according to Unix time before it finished running ;)

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

Dave wrote:You still couldn't get units to attack properly (since you couldn't animate things properly)
Like I said, you can use items, delays, and redraws. You might need a lot of different items, but it can be done. Just like with all the other stuff. :twisted:
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

Elvish Pillager wrote:
Dave wrote:You still couldn't get units to attack properly (since you couldn't animate things properly)
Like I said, you can use items, delays, and redraws. You might need a lot of different items, but it can be done. Just like with all the other stuff. :twisted:
Nope, it can't.

Units appear outside of their hex when they attack. Items can't appear outside of their hex.

The only thing that can appear outside of a hex are haloes, but haloes can be turned off in preferences.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

Dave wrote:
Elvish Pillager wrote: Like I said, you can use items, delays, and redraws. You might need a lot of different items, but it can be done. Just like with all the other stuff. :twisted:
Nope, it can't.

Units appear outside of their hex when they attack. Items can't appear outside of their hex.

The only thing that can appear outside of a hex are haloes, but haloes can be turned off in preferences.

David
You forget that items can be placed in multiple hexes. Thus, multiple items can form an image one can't.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

Elvish Pillager wrote:
Dave wrote: Nope, it can't.

Units appear outside of their hex when they attack. Items can't appear outside of their hex.

The only thing that can appear outside of a hex are haloes, but haloes can be turned off in preferences.

David
You forget that items can be placed in multiple hexes. Thus, multiple items can form an image one can't.
True, but even then the draw-order wouldn't be correct. For instance attacking units are drawn above grid lines, but items are drawn below them.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Post Reply