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...
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
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
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.
Last edited by OCteam on Mon Mar 06, 2006 11:38 am, edited 1 time in total.
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