| View previous topic :: View next topic |
| Author |
Message |
cools
Joined: 04 Mar 2006 Posts: 46
|
Posted: Sat Mar 04, 2006 1:21 pm Post subject: Artificial intelligence in Lua |
|
|
I need some help with artificial intelligence in lua. I just need a simple script that will add a certain amount of money for the computer. The code for the player is done, i just need some AI for the computer. Now I'm not 100% sure if Lua has AI abilities, or if it'll end up being a whole bunch of math.random()'s...
Heres the code so far:
| Code: |
black = Color.new(255,255,255)
playerMoney = 0
while true do
pad = Controls.read()
if pad:left() then
playerMoney = playerMoney+1
delay(1000)
end
if pad:right() then
playerMoney = playerMoney+5
delay(1000)
end
if pad:l() then
playerMoney = playerMoney+10
delay(1000)
end
if pad:r() then
playerMoney = playerMoney+50
delay(1000)
end
screen:clear(Color.new(0,0,0))
screen:print(200, 130, playerMoney, black)
screen.flip()
screen.waitVblankStart()
function delay( milli )
vs=math.floor(milli/60)
screen.waitVblankStart( vs )
end
end
|
|
|
| Back to top |
|
 |
JorDy
Joined: 11 Dec 2005 Posts: 121
|
Posted: Sat Mar 04, 2006 10:59 pm Post subject: |
|
|
| what is the game/program for? what do you want the AI to do? i can probablly help |
|
| Back to top |
|
 |
cools
Joined: 04 Mar 2006 Posts: 46
|
Posted: Sun Mar 05, 2006 12:46 am Post subject: |
|
|
| Its for my monopoly clone. I just need the AI to compete with how much money the player has offered. It has to go up by 1,5,10, or 50. If you need any more info just ask |
|
| Back to top |
|
 |
OCteam
Joined: 05 Mar 2006 Posts: 7 Location: UK
|
Posted: Sun Mar 05, 2006 11:41 pm Post subject: |
|
|
| cools wrote: | | Its for my monopoly clone. I just need the AI to compete with how much money the player has offered. It has to go up by 1,5,10, or 50. If you need any more info just ask |
AI is just a series of if statements that will intelligently process a given function. Just do it like you would anything else and ignore the term AI. Figure out the logic and then make it happen. _________________ PP121494863-PSP1001
www.illfoundedmind.com
Last edited by OCteam on Mon Mar 06, 2006 11:38 am; edited 1 time in total |
|
| Back to top |
|
 |
cools
Joined: 04 Mar 2006 Posts: 46
|
Posted: Mon Mar 06, 2006 12:27 am Post subject: |
|
|
| Thanks OCteam, it helps alot! ( otherwise I would've been doing a whole bunch of math.random()'s! ) |
|
| Back to top |
|
 |
OCteam
Joined: 05 Mar 2006 Posts: 7 Location: UK
|
Posted: Mon Mar 06, 2006 11:38 am Post subject: |
|
|
| cools wrote: | | Thanks OCteam, it helps alot! ( otherwise I would've been doing a whole bunch of math.random()'s! ) |
No problem -- you do want some random variables in there (just so the cpu's movements are not the same always) but worry about that after you get the basic functions down (it is easily to throw in a random statement). Good luck _________________ PP121494863-PSP1001
www.illfoundedmind.com |
|
| Back to top |
|
 |
|