AI System for Paper, Rock, Scissors. in Developer Help
|
|
Code:
var/list/Choices=list("Rock","Paper","Scissors")
mob/verb/Challenge_AI() var/AI = pick(Choices) if(usr.playing == 1) usr << "Your currently in the middle of a game" return else if(usr.playing != 1) usr.playing = 1 switch(alert(usr,"Rock, Paper, or Scissors?","Menu","Rock","Paper","Scissors")) if("Rock") usr.Picked = "Rock" if("Paper") usr.Picked = "Paper" if("Scissors") usr.Picked = "Scissors" if(usr.Picked == AI) usr << "Draw" else if(usr.Picked == "Rock"||AI == "Scissors") usr << "You win!" if(usr.Picked == "Scissors"||AI == "Rock") usr << "You loose.." else if(usr.Picked == "Paper"||AI == "Rock") usr << "You win!" if(usr.Picked == "Rock"||AI == "Paper") usr << "You loose.." else if(usr.Picked == "Scissors"||AI == "Paper") usr << "You win!" if(usr.Picked == "Paper"||AI == "Scissors") usr << "You loose.." usr.playing = 0
|
Problem description: You never loose, and hardly ever draw, I need it to be a full working AI system, with the AI's choice more random.
|
if(usr.Picked == "Rock"&&AI == "Scissors")usr << "You win!"
if(usr.Picked == "Scissors"&&AI == "Rock")
usr << "You loose.."
else
if(usr.Picked == "Paper"&&AI == "Rock")
usr << "You win!"
if(usr.Picked == "Rock"&&AI == "Paper")
usr << "You loose.."
else
if(usr.Picked == "Scissors"&&AI == "Paper")
usr << "You win!"
if(usr.Picked == "Paper"&&AI == "Scissors")
usr << "You loose.."
[EDIT: Also, don't you think the AI should have more skill? Look and see what the opponet uses the often, and judge upon that.]