forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Artificial intelligence in Lua

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
cools



Joined: 04 Mar 2006
Posts: 46

PostPosted: Sat Mar 04, 2006 1:21 pm    Post subject: Artificial intelligence in Lua Reply with quote

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
View user's profile Send private message
JorDy



Joined: 11 Dec 2005
Posts: 121

PostPosted: Sat Mar 04, 2006 10:59 pm    Post subject: Reply with quote

what is the game/program for? what do you want the AI to do? i can probablly help
Back to top
View user's profile Send private message
cools



Joined: 04 Mar 2006
Posts: 46

PostPosted: Sun Mar 05, 2006 12:46 am    Post subject: Reply with quote

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
View user's profile Send private message
OCteam



Joined: 05 Mar 2006
Posts: 7
Location: UK

PostPosted: Sun Mar 05, 2006 11:41 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
cools



Joined: 04 Mar 2006
Posts: 46

PostPosted: Mon Mar 06, 2006 12:27 am    Post subject: Reply with quote

Thanks OCteam, it helps alot! ( otherwise I would've been doing a whole bunch of math.random()'s! )
Back to top
View user's profile Send private message
OCteam



Joined: 05 Mar 2006
Posts: 7
Location: UK

PostPosted: Mon Mar 06, 2006 11:38 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group