LoginLogin

DSAI

Root / Programming Questions / [.]

andritolionCreated:
Ok. I'm making a AI called DSAI. (Still under debate... You can suggest a name...) Now this will be a reboot of my unnamed AI that I made back in 2016. Now I need help. I want it to say a response from a list of commands if you say something from a different list... Please help!

you could do something like this:
INPUT INPUT$
RESTORE @LIST
REPEAT
 READ CMD$
 DIM RESP$[0] 'reset the list of responses
 WHILE 1 'read responses until you reach ""
  READ TEMP$
  IF TEMP$=="" THEN BREAK
  PUSH RESP$,TEMP$
 WEND
UNTIL INPUT$==CMD$ || CMD$=="" 'repeat until you find a match or reach the end of the data
PRINT RESP$[RND(LEN(RESP$))] 'print a random response from the list

@LIST
DATA "command1","response1A","response1B",""
DATA "command2","response2",""
DATA "command3","response3A","response3B","response3C","response3D",""
'etc.
DATA "","error: invalid command",""
After you input a command, it reads the data until it finds a match, then prints a random response.

Thanks!!! I'll put credit if you ask "Who made this?"