Sign in to follow this  
TriKri

Best AI programming language?

Recommended Posts

Hi! I have thought of making some implementation of AI in chess (in the evaluation function), based on some form of artificial programming, maybe trial and error. First I thought of making one which uses Lisp, but then I thought that I should better check before if there is any better suited language, some that is more often used today than Lisp is... Do you know which language is most often used, or which is the best to use? If Lisp, which dialect should I use, CL or Scheme? And since I am new to AI and artificial programming, is there any good articles I should read about it before I give it a try? I know the basics of genetic programming, but I don't really see why I should keep more than one AI generated program at the same time when they probably will work in about the same way, at least not in this case. By the way, I read a book before sometime which contained a chapter about a computer or a computer program (don't know which) called Eurisko (you can see http://en.wikipedia.org/wiki/Eurisko). Ever heard of it? I think that used Lisp too, or at least something similar. That computer achieved some amazing things! Does anyone know how it worked? It would be really awesome if my program could do about the same thing!

Share this post


Link to post
Share on other sites
LISP has historically be considered The Language For AI, because its history and the history of early Natural Language Processing are deeply linked. Don't read too much into that, though. There is very little specific to AI which is uniquely well handled by LISP. I'll let others weigh in on the LISP variant war.

You should look into minimax, alpha-beta pruning, and transposition tables. Don't be seduced by the buzzwordiness of genetic algorithms and ANNs. They are not a panacea.

Eurisko is a cool technology, but it's probably not particularly applicable to chess, since (IIRC) it has limited formal look-ahead ability. I could be wrong about this, though.... I haven't really looked at it in a while.

Share this post


Link to post
Share on other sites
Not to be trite, but this is similar to asking "what is the best language for writing song lyrics?" The best programming language for AI is the one that the rest of your application speaks. If you are going to be writing the rest of your stuff in C++, why bother with LISP? If you are going to be coding in Java, why would you use VB? Exceptions to this are things that are designed to go together such as Lua plugins to C++.

General AI concepts are highly language-independent. Use whatever you are comfortable with that is capable of supporting what you need to do. (e.g. if you need recursion or flexible container classes, then the language must support those)

Share this post


Link to post
Share on other sites
Thanks. I know about alpha-beta pruning, and also about transposition tables. I am going to use these too. Well, I look at this project more as an attempt to create something that is creative, that can come up with ideas about what a good position should look like. If it is possible to do it at all with artificial programming.

I have an idea of how this can be done:

I start by creating a very basic evaluation function of course (which will make the program able to play a somewhat reasonable game that is not totally random). Then a number of random but common game positions (maybe from past games or the previously played one) is taken. All of these positions will have their own values, given by the estimation function.

However, these values are just estimations of the current state of the game (which player has the advantage and how big), and we want them to be better. And that is achieved by looking several moves ahead, although looking only a few moves ahead will also improve the estimations. So, every position is given a new value, taken from looking one or two moves ahead (depending on if it necessary that it is the same players turn again, or not), using min-max or alpha-beta pruning (these values can act as "true values", for example if a neural network and backpropagation would have been used instead). It is probably also possible (it should be in some way) to try to make small modifications of the evaluation function, to better match the new values. If such a modification is found, it is applied to the evaluation function. This is however only a method for improving the evaluation method, then it is used as normal when a real game is played.

Does this make sense at all?

Otherwise, it could just try modifying the code a little bit and play one or a few games against the old code, to see if it improved.

The reason I asked about what language to use is that I want to find an easy language to implement it in. With Lisp for example requires quite little (I guess) to write the interpreter (and also the code generator) in comparison to if other, more complex languages like C, or worse, C++, are used. The generated program still has to be able to perform well though.

Share this post


Link to post
Share on other sites
This is potentially an interesting project. The best attempt at this kind of thing I've seen was some paper in the early 90s where they converted positions into graphs (where a link represents a piece attacking a square) and then trying to automatically generate a database of useful patterns with associated values. The evaluation function would then consist of identifying the patterns that might be present and adding their values up.

Another, more limited approach was KnightCap, which used TD learning to auto-tune parameters in its evaluation function.

The tough part about this is what algorithm to use, not what language to express it in. I would do it in C++ because that's what I am more used to, but you can use anything else.

Share this post


Link to post
Share on other sites
I have never heard about C++ script before. Is it common to use it? I have heard that C++ is a very difficult language to parse, if you compare it to for example C. That is if you are going to use classes, templates and polymorphism of course, but what good is it without all that?

C seems complex enough to make a script language of. Is it sure it isn't easier making it in Lisp, I mean, you basically just got a loot of parenthesis in Lisp, and you don't have to bother about precedence or associativity of the operators. Lisp only allows one operation, or "function", at each depth in an expression.

Then of course, you are the game programmers, so you probably know better! I guess many of you have been coding in some project which used scripting. Which language did you script in; is it possible to script in C++? Did you use your own parser (script interpreter) or did you use an external one? Is there any good parsers out there that you can use?

Just exploring!

-Kristofer

Share this post


Link to post
Share on other sites
Quote:
Original post by TriKri
Hi! I have thought of making some implementation of AI in chess (in the evaluation function), based on some form of artificial programming, maybe trial and error.


I wouldn't start with chess, it's a very complex game. In fact, most classic board games (chess, checkers, backgammon, go,...) are very complex. Even if you spend a lot of time, you're AI will most likely either play very bad or take a very very long time to think.

As for programming language: It doesn't really matter! Pick the one you know best, unless you want to learn a new language in the process, then pick one you'd like to know.

[Edited by - Rattenhirn on October 8, 2009 3:03:39 AM]

Share this post


Link to post
Share on other sites
If I understand TriKri correctly, he thinks that the code for artificial inteligence needs to be generated dynamically (that's why he's talking about parsing C++ and lisp and such things).
TriKri, you should read some more before starting coding this, as it seems you dont graps the basic ideas at all.

Share this post


Link to post
Share on other sites
Quote:
Original post by Relfos
If I understand TriKri correctly, he thinks that the code for artificial inteligence needs to be generated dynamically (that's why he's talking about parsing C++ and lisp and such things).
TriKri, you should read some more before starting coding this, as it seems you dont graps the basic ideas at all.


Can you please explain that a bit further, why don't I have to generate code dynamically? That is exactly what I want to do. What I want to achieve is a "creative" AI, and that can only be done by letting it formulate new ideas (and try them out), in this case code.

Share this post


Link to post
Share on other sites
Ideas don't have to be expressed as code. They can be data that states how to combine pre-existing behaviour. In fact I would say code is a poor representation for creative ideas because it isn't sufficiently constrained to the problem domain.

Share this post


Link to post
Share on other sites
If you want your program to be creative, first you need to know what you mean by that. Is Rybka creative? What test would you use to determine it?

I am a natural Wittgensteinian, and I only understand words in their context. I don't think "creative" is a word that means anything when applied to a chess program. It makes sense to use it for human chess players that can think of things other humans miss. "Creative moves" can also be simply surprising moves that happen to work only because their opponents don't know how to counter them. When applied to programs, it's a metaphor at best.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kylotan
Ideas don't have to be expressed as code. They can be data that states how to combine pre-existing behaviour.


That sounds interesting. How do you mean combine pre-existing behaviour, can you give an example of it? Can it for example be applied to chess? Or to any other interesting game?

Quote:
Original post by alvaro
If you want your program to be creative, first you need to know what you mean by that. Is Rybka creative? What test would you use to determine it?


alvaro, I haven't heard about Rybka before, actually I'm not that into chess myself, I just use it because I find it an interesting game. Hm, the strongest chess engine in the world? I'd better check it out!

I do think creativity can mean something when applied to a chess program as well. For sure, there has to be some kind of definition of what creativity is, and that has to be applicable to a computer program as well. My idea of creativity is that a person who is creative comes up with new ideas all the time, which he doesn't know if they are going to work or not, and tries them out. Regardless of if his ideas worked or not I think that is creativity, because he is sooner or later going to find something that will work. In other words, what I am being now. What is your idea of creativity?

[Edited by - TriKri on October 9, 2009 2:01:48 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by TriKri
What is your idea of creativity?


I sort of answered that in my previous post. I think words are only meaningful only in the context in which they are normally used, and the search for human attributes like creativity or consciousness in machines is futile if you don't clearly define what you mean by them in this new context, in a testable way.

Share this post


Link to post
Share on other sites
Instead of being creative - if you're doing research why not try to 'solve' the chess problem. It's been done for checkers, so now someone should do it for chess. The link for checkers if you haven't seen is http://www.cs.ualberta.ca/~chinook/

Share this post


Link to post
Share on other sites
If you want a game to simply make things up until if hones in on a "creative solution" (and I agree that is kinda nebulous), why not use a GA whose genes represent a sequence of potential actions? What actions? Depends on what you are trying to do. Can you do it in chess? Not even remotely.

I concur with what was mentioned above... methinks you need to read a lot more and do some "normal" AI programming before you start trying to accomplish something that no one has done before.

Share this post


Link to post
Share on other sites
TriKri,

It sounds like you might be trying to bite off more than you can chew. Chess is a very difficult game to work with, even without the complication of a 'creative' AI component.

Dynamically generating code is also very complicated; dynamically generating meaningful code even more so!

If you had some chess experience already then I'd say 'Go for it', but you don't, so I won't. :)

As much as I hate saying this, I think InnocuousFox is right and you'll probably be much happier with yours results if you take his advice about the GA and potential actions.

Share this post


Link to post
Share on other sites
Quote:
Original post by TriKri
Quote:
Original post by alvaro
And why would you?


You can gladly come with some constructive comment, but right now you are not contributing to anything.


Actually, that could be seen as constructive in the sense that the poster is communicating that he wants the poster to which he's responding to think about why he would use something, since really that's the more important thing in this case than why he would not use something. The question is basically "Why would you [use Prolog instead of Lisp or Lua or Python as an AI scripting language]?" It's a legitimate question-response.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this