Jump to content
  • Advertisement
Sign in to follow this  
Roots

Lisp and Scheme, do you use them?

This topic is 5014 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know that the AI course at Purdue University uses Scheme, while the AI course at UT Austin uses Lisp. So out of curiousity I ask to you game developers, have any of you used either of these two languages in your AI routines? I remember hearing sometime ago that the only reason that Lisp and Scheme are broadly used by the academic AI community were strictly historical reasons (the fact that Lisp existed at the "right" time ) and not because either of these languages have an obvious benefit over others. What are your thoughts?

Share this post


Link to post
Share on other sites
Advertisement
I actually hear that people are starting to turn towards using Java or something similar like C# for AI.

Unfortunately, I really don't like the syntax of either Scheme or Lisp. I would rather use something else.

Share this post


Link to post
Share on other sites
My best, most complicated project so far was in Lisp, and I succeeded in bringing it as far as I did because of Lisp. Lisp is king.

Share this post


Link to post
Share on other sites
While Lisp dialects (a Scheme dialect is also a Lisp dialect!) are definately a good thing, they are somewhat dificult to use effectively depending on what your trying to archive.

If you are writing *nix software then there are many well developed solutions available for you to embed in your application allowing you to write your ai code in Lisp. However, for other platforms all of the solutions I'm aware of are commercial and may be dificult to obtain if you do not own an American credit card!

NOTE: CLISP is available for windows and it is apparently compatable with VC, I was unable to understand their terminology and linking mechanism to accomplish this, however. If you do not use VC this might be easier to archieve.

As for AI ruitines, they can usually be written in any well engineered programming language, and since most gamecode will inevitably have to link to C code (perhaps even C++ code!) Lisp will be out of the realm for many budding hobbiest game developers for some time yet. A dialect of Scheme was used as a complete scripting solution for a commercial game, however! This may or may not have included their AI ruitines.

As for Lisp having advantages, this is most certainly true and has to do with the design philosophy of the language, and its ability to adapt to almost any programatic problem that is not hardware bound (newer implementations of Common Lisp avoid this by providing extensions for mnemonic operations, allowing assembler capabilites without even leaving the language itself!).

As I stated before however, AI is about the algorithms and not the languages, therefore you should pick the language that best suites the task. If your engine is in C++, since it is very hard to extend C++ with other languages it may be easiest to use C++ to write your ai code, if you were working in C however it may be more pertinent to use an embeded Scheme dialect since it will make the algorithms easier to write and test quickly and is very easy to embed on *nix platforms and some Win32 platforms (depends on the dialect you choose).

Share this post


Link to post
Share on other sites
I use scheme for my Othello program. This is because scheme lets me explore the problem more easily than most other languages. I can experiment with different ways to call my search routines for instance, without having to change anything in the actual code or go through an annoying compile cycle.

When the execution fails somehow the state is preserved so I can examine and change all data to help me find out where the bug is. For instance once when the search did not terminate I could just look at the stack which I saved moves on, to see that what the search was doing was just making and un-making pass moves. Very helpful. With C++ I would have had no way to tell why it was stuck.

Furthermore scheme lets me write more compact code in many cases. For instance, in other languages negamax is often used instead of minimax because it makes the code shorter, but in scheme the minimax version is just as short (I think mine is 9 or 10 lines), since you can use higher order functions to express the two cases (maximizing and minimizing).

Some reasons I like scheme:
+ it facilitates incremental bottom-up development
+ can be compiled to machine code or (java or scheme) byte code
+ it usually takes less code to achieve your goals
+ no crashes.
+ there are many independent open source implementations for different needs
+ the language is quite well-defined (formal semantics)
+ 100% portability

Some negative things about scheme:
- the standard library is too small
- no standard way to create new data types

edit: clarified a few points

[Edited by - Scientifish on September 22, 2004 6:43:40 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Roots
I remember hearing sometime ago that the only reason that Lisp and Scheme are broadly used by the academic AI community were strictly historical reasons (the fact that Lisp existed at the "right" time ) and not because either of these languages have an obvious benefit over others. What are your thoughts?

I remember hearing that about the popularity of C, C++, Java, C# and VB.

I've used MzScheme to embed scheme into a C++ game. I've used Corman Lisp with SDL/OGL to make some relatively simple applications.

Pick up a non-AI book on Lisp/Scheme and you'll probably "get" why people love (and hate) it.

Share this post


Link to post
Share on other sites
I use Lisp and prolog because I have to for college, but my professor said that current real A.I. projects are done in C++, so I have no real intentions of sticking with either.

Share this post


Link to post
Share on other sites
By the way, everything I love about Lua I learned first in Lisp or Scheme. Closures, dynamic typing, hash tables, coroutines, generators, the REPL loop. One thing Lua doesn't have is the wonderful syntax of Lisp and the benefits that it yields (code is data, functions that can easily parse and modify code)

Share this post


Link to post
Share on other sites
Quote:
Original post by digitec devil
my professor said that current real A.I. projects are done in C++

Did he happen to mention why?

Share this post


Link to post
Share on other sites
Well, there's a big difference between the university definition of AI, and what game developers mean when they discuss AI. For the former, I believe Scheme (or Lisp) is very useful, but it might be a bit messy for use in game development. (The problems you want to solve are simpler, and you want more performance, and finally, getting different languages to talk to each others is always tricky)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!