347Views83Replies

Author Options:

Failed Experimentation : AI : My new creature is alive ! Answered

.
It's alive !

Alive, yes, but not as much intelligent than expected ..........

Instead of watching a stupid movie at TV, I decided to write a tiny AI programme all in PHP.
My goal was to get some functionalities comparable to logic programming languages like Prolog.

In simpler words : I wanted to create a programme that could learn facts, and find the solutions to some logical problems.

For instance :

> blue is colour.Okay.> carrot is vegetable.Okay.> blue is colour ?Yes.> blue is vegetable ?No.> carrot is colour ?No.
etc.

So far, I can teach it facts in the form of 3-words-affirmations, and I can ask it questions and definitions, and the creature is able to find some connections between facts.

Experimentation #1 :
> red is colour.Okay> black is colour.Okay> orange is colour.Okay> orange is fruit.Okay
(Here, we have a trap : orange is both a color and a fruit.)
> red is colour ?Yes> black is fruit ?No> orange is colour ?Yes> orange is fruit ?Yes
(Good. The beast did not fall in the trap.)

> translate :  red- "colour"> translate : orange- "colour"- "fruit"> translate : colour- "red"- "black"- "orange"
Good ! The beast can give a sense to the words it learned.

Experimentation #2 :
> Paul is human.Okay> human eat fruit.Okay> apple is fruit.Okay> human is animal.Okay> animal eat meat.Okay> animal is mortal.Okay

Now, let's see if it can "chain" the facts in a logical manner :
> translate : Paul- "human"
Here it should have replied : "human", "animal" and "mortal", since human are animals, and animals are mortal ...
Let's see how it defines "Paul" :
> define : Paul- Paul is human
My creature seems obviously narrow minded ...

Let's quiz it now :
> Paul is apple ?No> Paul is fruit ?No> Paul is human ?Yes> human is Paul ?Yes> Paul is Paul ?Yes> Paul eat fruit ?Yes> Paul eat apple ?Yes> Paul is animal ?Yes> Paul eat meat ?No> Paul is mortal ?Yes

As we can see, it successfully (and surprisingly) replied correctly to each question by connecting facts together, excepted for "Paul eat meat ?".
At this question, it should have replied "yes", since it knows that "Paul is human", "human is animal" and "animal eat meat". But it did not ...

... and it's bizarre since it can reply correctly to "Paul is mortal ?", from "Paul is human", "human is animal" and "animal is mortal", or to "Paul eat apple ?" from "Paul is human", " human eat fruit" and "apple is fruit" ...

Interesting, isn't it ? =o)

If you want, you can submit your facts and questions to my experimental creature (which has no name yet) =o)

What would be interesting also, is to confront it to a "paradox" just to see how it behaves ! =o)


20080625 : For those of you who would like to have a look at the guts of the beast, here is available the source code.

However, keep it mind it's a spaghetti-code and many function names are in french (as well as comments).

Also, this version relies on MySQL to store and query facts (I'm planning to replace it with simple arrays though), which make the code slightly more complicated than required ...

The main code makes less than 250 lines =o)

There is no direct input interface : instead, it use scripts (exp_*.php) that call functions. For example :
declarer("red","is","colour"); // <---- declarationsdeclarer("black","is","colour");declarer("orange","is","colour");declarer("orange","is","fruit");verifier("red","is","colour"); // <---- questionsverifier("black","is","fruit");verifier("orange","is","colour");verifier("orange","is","fruit");
... which is slightly more complicated than what I showed above for the sake of comprehension and simplification !

50 Replies

user
wizerd 745 (author)2009-02-01

anyway you could do something like this with batch (easily)?

Select as Best AnswerUndo Best Answer

user
PKM (author)wizerd 7452009-02-02

To put it simply, no. Batch is a very simple language that doesn't have the data storage capabilities to do this type of task. I would guess that it is somehow possible, but it would be difficult even for a seasoned programmer, and strange almost to the point of perversity. I don't have a clue how I'd write this in batch, but I can see how I would do it in a more complete language like C.

Select as Best AnswerUndo Best Answer

user
Goodhart (author)PKM2009-02-02

To be very practical, the language has to be able to alter it's own functionality to learn, and as you wrote, it would be difficult if not impossible to do this in Batch, even with some of the more advanced Batch functions.

Select as Best AnswerUndo Best Answer

user
kelseymh (author)PKM2009-02-02

You could do it in Perl trivially, or even in kshell. Use hash arrays to store each predicate, in particular use two inverse hash arrays so you can do queries in both directions. This still isn't going to solve your syllogism problem, which requires implementing an algorithm to either accumulate the full trees of relations at creation, or to figure them out on demand.

Select as Best AnswerUndo Best Answer

user
Labot2001 (author)2008-06-26

Would Mr. Choose teach Labot how to copy AI onto his computer to use?

Select as Best AnswerUndo Best Answer

user

You need a HTML server with PHP and MySQL servers, etc ...

If you're under windows, you could try : http://www.easyphp.org/

Once you'll have understood how EasyPHP works, you copy the source code in the appropriate folder, and you'll rename their .txt extension to .php5

=o)

Select as Best AnswerUndo Best Answer

user

>Once you'll have understood how EasyPHP works, you copy the source code in the appropriate folder, and you'll rename their .txt extension to .php5

Hmm, can you point me in a direction where I can learn about EasyPHP? For know, I'll start at Wikipedia, do some Google'ing, etc...

Select as Best AnswerUndo Best Answer

user

The site EasyPHP.org gives you all the required help related to how to install and setup the web servers (that's what EasyPHP is), and more.

About the PHP language itself, you could learn the basis at : www.w3schools.org

I'd recommend that you start learning HTML first ...

However, keep in mind that PHP is not really a "general purpose" programming language ...
The main purpose of PHP is to generate web-pages dynamically ...

If I used it for my experimentation, it was for the sake of laziness. =o)
(I already had all the servers installed on my system, and I was too lazy to code in C++ ...)

If you want to learn programming without having to install many tools, you're not forced to do that with PHP ...
You could begins with HTML and JavaScript for instance (You'd only need notepad and a web browser ( www.w3schools.org )).

And if you want to learn are serious programming language, you could pick C++, Pascal or Visual-Basic ...

Select as Best AnswerUndo Best Answer

user

Visual basic?? What century do you program in? :D

Select as Best AnswerUndo Best Answer

user

lol Actually, even Pascal is slightly out of fashion Xo)

Select as Best AnswerUndo Best Answer

user
Goodhart (author)chooseausername2009-02-02

Pascal is much older then VB for sure. As for C, I like C # myself ;-)

Select as Best AnswerUndo Best Answer

user
PKM (author)Lithium Rain2008-06-30

I have to code with VBA at work ;_;

Select as Best AnswerUndo Best Answer

user
Lithium Rain (author)PKM2008-06-30

Do you work in the eighteenth century?

Select as Best AnswerUndo Best Answer

user

>I'd recommend that you start learning HTML first ...

I can do intermediate HTML. What I'm really interested in is programming, not web design.

>And if you want to learn are serious programming language, you could pick C++, Pascal or Visual-Basic ...

I heard that if you want to learn programming, start with Python. What would your recommendation be, ups and downs of each of them, etc?

Select as Best AnswerUndo Best Answer

user

> I can do intermediate HTML. What I'm really interested in is programming, not web design.

I understand. However, HTML is the entry door for JavaScript and PHP (they all work together). That's why I told you to start with HTML (just in case ...)

But if you want to learn programming, then, you can start with Python if you want.

I tried many languages, but I don't remember I ever tried Python ... so I can't tell you anything about it, excepted that Whatsisface once said : «Or Python ! Python rocks!»

I tried various languages : many BASIC dialects, some Assembly languages, Pascal, C and C++, Euphoria, some Perl, some Erlang, LUA, C# and some D ... I even tried a language called "microbe" ... all of that, plus HMTL, XML, JavaScript and PHP indeed ...

The most used programming language around the world is probably C++.
That's also my main language when I want to code something serious.

Honestly, I think that whichever you choose to begin with, you'll always end-up trying a new one till you've found your "holy grail".
So, just pick up one of them and start with it : Why not Python ??

=o)

Select as Best AnswerUndo Best Answer

user

Aha! Thanks for all the wisdom.

And, um... n00b question... Is "C++" pronounced "See-Plus-Plus"?

Select as Best AnswerUndo Best Answer

user
Lithium Rain (author)Labot20012008-06-27

Yeah. And "C #" is pronounced "see-sharp".

Select as Best AnswerUndo Best Answer

user
Labot2001 (author)Lithium Rain2008-06-30

Really, now? Thanks, smart aleck.

Select as Best AnswerUndo Best Answer

user
Lithium Rain (author)Labot20012008-06-30

I'm not being a smart aleck! THAT'S HOW YOU SAY IT!!

Select as Best AnswerUndo Best Answer

user

And by the way, have you noticed my formidable pun ??? =o)

"holy grail" ... Python ...

Python ... and the "holy grail" ??

No ? nothing ? .........

Never mind ...

Select as Best AnswerUndo Best Answer

user

No, I didn't catch it at first. I've never seen the whole movie ~~and I didn't care for it~~ but I'll get to it one day.

Select as Best AnswerUndo Best Answer

user
zachninme (author)Labot20012008-06-30

"And if you want to learn are serious programming language, you could pick C++, Pascal or Visual-Basic ..."

Sorry chooseausername, but I wholeheartedly disagree. I would never start with VB, as it does not teach good programming practices. Pascal, maybe, but I wouldn't personally recommend it.

I'd also not recommend either Python or Java as a first language. This article makes a convincing point. (it applies equally to python, even though they do not mention it)

Select as Best AnswerUndo Best Answer

user

Oh, you know, that's not a subject I will argue about ... =o)

Honestly, if I told him C++, Pascal (or Delphi) and VB, it's mainly because (at my knowledge) they are 3 of the top most popular ones (many tutorials, many resources and many tools available) ...

Anyway, if I ruled the world, the only programming language would be C.
=o)

Select as Best AnswerUndo Best Answer

user
Labot2001 (author)whatsisface2008-06-27

Can you tell me enough about Python to get me on my feet?

Or at least crawling?

Select as Best AnswerUndo Best Answer

user
whatsisface (author)Labot20012008-06-28

I'm learning it from this site :http://www.freenetpages.co.uk/hp/alan.gauld/

It's a very good piece of text, well written and easy to understand. MAke sure you start at the start and don't skip anything.

Select as Best AnswerUndo Best Answer

user
Labot2001 (author)whatsisface2008-06-28

Ah, gracias, Sir Face. I shall "bookmark" it, yes?

Select as Best AnswerUndo Best Answer

user
NachoMahma (author)Labot20012008-06-29

. You might want to investigate [http://en.wikipedia.org/wiki/LAMP_(software_bundle) LAMP] or WAMP.

Select as Best AnswerUndo Best Answer

user
kelseymh (author)2009-02-02

What I think you're looking for is called "predicate calculus" in English.

I'm sorry that I don't know the technical term in French. Doing a Google Scholar search for research articles on predicate calculus might (or might not :-( ) lead to you to some useful algorithms for how to have your software make deductions and follow syllogistic chains.

Select as Best AnswerUndo Best Answer

user
Keith-Kid (author)2008-06-30

The comments in this thread are interesting, they seem to answer a lot of my questions. I'll keep an eye on this thread.

Select as Best AnswerUndo Best Answer

user

Are you planning to make a report ? =o)

Select as Best AnswerUndo Best Answer

user

I'd really like to learn about programming languages......

Select as Best AnswerUndo Best Answer

user

What would you like to programme for instance ?

Select as Best AnswerUndo Best Answer

user

Yeah....I'm not even sure what I wanna learn.......

Select as Best AnswerUndo Best Answer

user

Then, what are you sure about ??

Select as Best AnswerUndo Best Answer

user

I'm pretty sure I have internet connection........

Select as Best AnswerUndo Best Answer

user

Hm. That's a good beginning !

Select as Best AnswerUndo Best Answer

user
whatsisface (author)2008-06-24

Ah I see, I work on a helpdesk, dealing with people who aren't sure what a mouse is.

Select as Best AnswerUndo Best Answer

user

LOL You mean : the kind of persons that can successfully make life a nightmare, right ?? XoP

Select as Best AnswerUndo Best Answer

user
Goodhart (author)whatsisface2008-06-25

classic call: Um, my "cup holder broke.....". LOL

Select as Best AnswerUndo Best Answer

user
whatsisface (author)Goodhart2008-06-25

I had one person today who managed to say hello, then managed to put me on hold. They hung up and called back asking why their phone was broken.

Select as Best AnswerUndo Best Answer

user
Goodhart (author)whatsisface2008-06-25

called on the phone to ask why the phone is broken ? LOL oooo look at all the pretty colors....

Select as Best AnswerUndo Best Answer

user
Lithium Rain (author)whatsisface2008-06-24

Poor whatsisface. Poor, poor poor whatsisiface.

Select as Best AnswerUndo Best Answer