Qbasicnews.com
September 21, 2019, 11:31:12 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Challenge: Creating AI that can "learn" through pr  (Read 5271 times)
otaku84
Member
*
Posts: 33


« on: October 15, 2003, 10:27:57 AM »

years ago, I saw a documentary, on Sentient AI. Personally I believe its impossible to create sentiency on a computer, no matter how powerful. Since computers, by their very nature are little more than glorified "pachinko machines", though most say thats a stupid analogy.

Anyway, I started toying with the idea, of creating a program, that would learn and develop after reacting to certain stimuli.
In my example, getting the + makes him more likely to go after it, until thats all the charatcers does, and getting touched by X teaches him to avoid X
Its not real learning, but the illusion is fun.

Can you come up with a program that gives the genuine impression of learning? Im expecting anyone who does, to do better than my attempt, since Im no mathmatician or master at programming.

heck, maybe someone could even turn these into a kind of "sandbox" game, where by altering something, the "avatar" will react differently. I mean, what if you controlled X in my example, you could almost lead him around. Or perhaps youd both be after the "+"?

rules:
1) no libs, pure QB only
2) Aesthtics unimportant
3) no connecting to other programs etc.
4) no prescripted long movements, or demos, the AI must think on its own, based on surrounding stimulus and variables.

Code:

'LEARNING AI
'This is a program to simulate learning and intelligence
'the smiley face needs to eat the "+"
'The X hunts the smiley face
'eating more food teaches him to go after food but makes him complacent about X
'getting attacked teaches him to avoid X but he frogets to eat
'feel free to tweak the AI and variables, or use this in making your own learning AI


RANDOMIZE TIMER
SCREEN 13
COLOR 7
INPUT "SUB LOOP WAIT = ", SP%
CLS
PRINT
PRINT
PRINT "         лллллллллллл"
PRINT "         л          л"
PRINT "         л          л"
PRINT "         л          л"
PRINT "         л          л"
PRINT "         л          л"
PRINT "         л          л"
PRINT "         л          л"
PRINT "         л          л"
PRINT "         л          л"
PRINT "         л          л"
PRINT "         лллллллллллл"

A = INT(RND * 10) + 4    'CHARACTER
B = INT(RND * 10) + 11
GA = INT(RND * 10) + 4   'GOOD
GB = INT(RND * 10) + 11
BA = INT(RND * 10) + 4    'BAD
BB = INT(RND * 10) + 11
GI = 10
BI = 10

DO
Q = Q + 1
IF Q > SP% THEN GOSUB MRV

LOCATE A, B
PRINT CHR$(1)
 LOCATE GA, GB
 PRINT "+"
  LOCATE BA, BB
  PRINT "X"
'LOCATE 1, 1
'PRINT "A="; A; "B="; B; "GA="; GA; "GB="; GB; "BA="; BA; "BB="; BB
LOCATE 18, 1
PRINT "GI="; CINT(GI); "   "
LOCATE 19, 1
PRINT "BI="; CINT(BI); "   "
LOCATE 16, 1
PRINT "SCORE:"; CINT(SC); "   "

IF A = GA AND B = GB THEN           'WHAT HAPPENS IF TOUCH GOOD
SC = SC + 1
GI = GI - 1
IF GI < 2 THEN GI = 2
BI = BI + .5
IF B > 25 THEN BI = 25
LOCATE GA, GB
PRINT " "
GA = INT(RND * 10) + 4   'GOOD
GB = INT(RND * 10) + 11
SOUND 200, .5
END IF

IF A = BA AND B = BB THEN          'WHAT HAPPENS IF TOUCH BAD
SC = SC - 1.4
BI = BI - 1
IF BI < 1 THEN BI = 1
GI = GI + 1
IF GI > 10 THEN GI = 10
LOCATE BA, BB
PRINT " "
BA = INT(RND * 10) + 4   'BAD
BB = INT(RND * 10) + 11
SOUND 50, .5
END IF

IF SC <= -25 THEN GOTO FIN
IF SC >= 25 THEN GOTO FIN

LOOP UNTIL INKEY$ <> ""
END

MRV:
Q = 0
LOCATE A, B
PRINT " "

GG = INT(RND * GI) + 1    ' GOTO GOOD , BASED ON GOOD INTELIIGENCE
IF GG = 1 THEN
IF A < GA THEN A = A + 1
IF A > GA THEN A = A - 1
IF B < GB THEN B = B + 1
IF B > GB THEN B = B - 1
ELSEIF GG > 1 THEN
RM = INT(RND * 4) + 1
IF RM = 1 THEN A = A + 1
IF RM = 2 THEN A = A - 1
IF RM = 3 THEN B = B + 1
IF RM = 4 THEN B = B - 1
END IF
 GGB = INT(RND * BI) + 1    ' AVOIDING BAD BASED ON BAD INTEL
 IF GGB = 1 THEN
 IF A > BA - 7 THEN A = A - 1
 IF A < BA + 7 THEN A = A + 1
 IF B > BB - 7 THEN B = B - 1
 IF B < BB + 7 THEN B = B + 1
 END IF

IF A >= 14 THEN A = 13               'WALL COLLISION
IF A <= 3 THEN A = 4
IF B >= 21 THEN B = 20
IF B <= 10 THEN B = 11

BTM = BTM + 1
IF BTM >= 4 THEN GOSUB BMRV 'BAD GUYS MOVES EVERY 2 SUB LOOPS
RETURN

BMRV:
BTM = 0                           'ALL THIS IS BAD GUYS HUNTING
LOCATE BA, BB
PRINT " "
 RM = INT(RND * 7) + 1
 IF RM > 4 THEN
 IF BA < A THEN BA = BA + 1
 IF BA > A THEN BA = BA - 1
 IF BB < B THEN BB = BB + 1
 IF BB > B THEN BB = BB - 1
 END IF
 RM = INT(RND * 4) + 1
 IF RM = 1 THEN BA = BA + 1
 IF RM = 2 THEN BA = BA - 1
 IF RM = 3 THEN BB = BB + 1
 IF RM = 4 THEN BB = BB - 1
 IF BA >= 14 THEN BA = 13         'BAD GUY WALL
 IF BA <= 3 THEN BA = 4
 IF BB >= 21 THEN BB = 20
 IF BB <= 10 THEN BB = 11
RETURN

FIN:
IF SC <= -20 THEN PRINT "DEATH"
IF SC >= 20 THEN PRINT "EVOLUTION"
END


I knocked it up in about an hour and a half.
Feel free to mess around with it.
Logged

You can't get a job in the games industry, until you've had at least 2 years experience in the industry, which wont happen until you get a job in the industry. " - random recruitment agency
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #1 on: October 15, 2003, 11:15:38 AM »

It is easy to create a computer that learns just about anything.

Ask me again in three years, when desktop computers are 10ghz.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
otaku84
Member
*
Posts: 33


« Reply #2 on: October 15, 2003, 11:27:39 AM »

perhaps, but I argue theyll never gain proper sentiency, at least not in human terms. The illusion that they can think for themselves, perhaps, but not true self awareness.
Logged

You can't get a job in the games industry, until you've had at least 2 years experience in the industry, which wont happen until you get a job in the industry. " - random recruitment agency
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #3 on: October 15, 2003, 12:03:39 PM »

Humans are just blobs of stuff, so why can't computers simulate those blobs of stuff? They can. You will see it soon.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
otaku84
Member
*
Posts: 33


« Reply #4 on: October 15, 2003, 12:27:25 PM »

Ive actually got a glitch in my AI program. I couldnt quite get the avoiding the enemy coding right.

the smiley face is meant to avoid the enemy X only when the x is within a certain range. if the X comes within7, or maybe 5 blocks, the face is supposed to try and avoid him, based on the randomisation lines.

I dunno, I cant quite get it right. he either goes towards him, or simply doesnt avoid him. Im perplexed. any ideas?
Logged

You can't get a job in the games industry, until you've had at least 2 years experience in the industry, which wont happen until you get a job in the industry. " - random recruitment agency
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #5 on: October 15, 2003, 12:30:19 PM »

Make your if statements exit out of the subs....

Or use SELECT CASE.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
otaku84
Member
*
Posts: 33


« Reply #6 on: October 15, 2003, 12:36:12 PM »

I dont think select case would work here.

Code:

GGB = INT(RND * BI) + 1    ' AVOIDING BAD BASED ON BAD INTEL
 IF GGB = 1 THEN
 IF A > BA - 7 THEN A = A - 1     'its these 4 troublesome lines
 IF A < BA + 7 THEN A = A + 1
 IF B > BB - 7 THEN B = B - 1
 IF B < BB + 7 THEN B = B + 1
 END IF


its all the IF statements, regarding position of each co-ordinates.
for example, if the A coordinate is more than the enemy minus a bit, IE to his left, then go left until you are no longer in that area.

at least thats the way my mind calculates it.
Logged

You can't get a job in the games industry, until you've had at least 2 years experience in the industry, which wont happen until you get a job in the industry. " - random recruitment agency
Phydaux
Senior Member
**
Posts: 200



« Reply #7 on: October 16, 2003, 12:49:55 PM »

Firstly the +/-7 bit you have in your code, is just changing the co-ords of the X.

IF ABS(A - BA) < 3 AND ABS(B - BB) < 3 THEN
IF SQR((A - BA) ^ 2 + (B - BB) ^ 2) < 3 THEN

either of these lines above will test for distance. It might also help you if you use more meaningfull variable names. Smiley


If you adjust you code so there is no +7/-7 and fix BI at 1 your character hunts down the X Tongue
This is because you have the +1/-1 at the end of each line mixed up. (in your 2nd code sample)


You'll also need to refine your code, as the creatures can move more than one square at a turn.

It might also be more interesting if the AI behaves differently, e.g. if the AI needs food, the hungrier it gets the more willing it is to dodge past the X and risk getting caught. meh... just thoughts... Smiley
Logged

url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][/url]
END OF LINE.
Mech1031
Na_th_an
*****
Posts: 1536



WWW
« Reply #8 on: October 16, 2003, 08:56:01 PM »

starting back to your first statement, that was a very good analogy (for those of us who have been to Japan :wink: )

::EDIT::
Wow, I'm a guru now! :lol:
Logged

the mind is a beautiful thing, use it and make the world a more beautiful place.
barok
Na_th_an
*****
Posts: 1727


How about a tasty lead sandwich?


« Reply #9 on: October 17, 2003, 12:39:24 AM »

hmmm.... sounds interesting.  

i believe SOMEDAY computers can gain sentience.  i remember in one of my popular science magazines, there was a program that had a stick man.  it had muscles, nerves and everything.  it was to walk across the screen, by stimulating it's muscles.  however, the  programmers didn't tell the program what muscles, so the program would create "generations" of stick men, that fired different sequences of muscles.  after a generation, it would record the results, and if had anything that seemed to be on the right track, it would save those characteristics for the next generation, so the program would basically pass down the good parts.  eventually, after many tests, the program learned how to walk.  It did many odd things as well, like bounce, crawl, etc. etc.  the technology was developed so people wouldn't have to waste time programming in each and every movements of characters for 3d movies, or something like that.

i myself am going to try to make a chat ai program.  it'll know a few words.  as you talk to it, it will dissect your sentences, and put the seperate words in categories (nouns, etc.) i also hope to make it   so it will be able to construct messages from scratch.  it'll take more than a day, i know, but hopefully it'll be worth it.  

my ultimate goal would be able to make it to develop a personality.  give it likes, dislikes, a way of speaking, etc. etc.  i'm probably WAY WAY in over my head with this, but it's interesting to say the least.
Logged

Jumping Jahoolipers!
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #10 on: October 17, 2003, 04:18:44 AM »

Quote from: "otaku84"
I dont think select case would work here.

Code:

GGB = INT(RND * BI) + 1    ' AVOIDING BAD BASED ON BAD INTEL
 IF GGB = 1 THEN
 IF A > BA - 7 THEN A = A - 1     'its these 4 troublesome lines
 IF A < BA + 7 THEN A = A + 1
 IF B > BB - 7 THEN B = B - 1
 IF B < BB + 7 THEN B = B + 1
 END IF


its all the IF statements, regarding position of each co-ordinates.
for example, if the A coordinate is more than the enemy minus a bit, IE to his left, then go left until you are no longer in that area.

at least thats the way my mind calculates it.


Case is >BA-7
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Spearor
Member
*
Posts: 50


« Reply #11 on: October 21, 2003, 06:40:45 AM »

I think to let a program learn you have to start with some 'world' rules which are constant. For example the cpu tries to eat everything which he sees for the 1st time. And if that failes he tries to use it for other things. So there must be some rules set up for the items too... hmm well just some thoughts.

It might also be an idea, to let the computer save the experiences in an outputted file, so it loads up the file and restore his experiences(or the things learned) again.

(play the game Creatures, it got some extensive AI in it)
Logged
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« Reply #12 on: October 21, 2003, 07:03:54 PM »

lol when i changed the ifs to selectcases he would run to a corner and get stuck...
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
qbiscool
Member
*
Posts: 56


« Reply #13 on: March 09, 2004, 12:55:58 AM »

Ya barok i tried making a chat program wich used premade sentences and the MID function. i had to give the user certain rules like "if your asking a question then put a ? at the end". It was funny becuase i only got about 1/4 of the way done and then i realized that it was useless.

PS. i dont think a computer can ever be "aware of itself" or "Aware of its workings"
Logged

pen your other eyes.........
barok
Na_th_an
*****
Posts: 1727


How about a tasty lead sandwich?


« Reply #14 on: March 09, 2004, 02:50:10 AM »

omg omg omg... someone give me strength... YOU REVIVED AN OLD TOPIC!  that's punishable by death.  we'll have to burn him at stake. or maybe we'll hang him. or chop off his head.

seriously though, don't revive old posts. if you want to say something to me, pm me.
Logged

Jumping Jahoolipers!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!