Quantcast

Maximum PC

It is currently Mon Sep 22, 2014 10:20 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: I have a Lisp
PostPosted: Wed Jan 16, 2008 6:38 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
So... any Lisp users around here? I am taking AI this semester, and we are using Lisp for our projects. Any comments? Am I going to be wanting to stab myself in the eye?

Is there any particular reason we might be using this instead of just writing C code or anything else? It seems to be a very basic evaluator, which I could do in any number of other languages.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 8:23 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
LISP is a very different programming language than C / C++.

While the project could be done in a variety of ways, I'm sure that your instructors chose lisp for a reason ... not least of which is the fact that Lisp is still used in AI programming to this day .. but also probably to teach you functional and reflexive programming. These are quite different than the iterative / procedural programming to which you are (probably) accustomed.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 9:04 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
I figured it was quite different, as it appears so. I was just curious as to what the benefits were over something C based, or whatever.

How is it used in AI applications? Does it provide some behind the scene logic processing that in it's nature is more effective than having a procedural set of rules to follow?

Has anybody here used it much? What uses does it have beyond AI?


Top
  Profile  
 
 Post subject: Re: I have a Lisp
PostPosted: Wed Jan 16, 2008 8:52 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
CrashTECH wrote:
Is there any particular reason we might be using this instead of just writing C code or anything else? It seems to be a very basic evaluator, which I could do in any number of other languages.

Oh, those are going to be some famous last words. =)

I'm actually pretty fond of Lisp. I would recommend watching the first couple of SICP lectures online (strangely, they use Scheme in the lectures, but call it Lisp -- I have no idea). That'll get you headed in the right direction and probably open your eyes to a couple of other ideas as well.

As far as a Lisp environment, in Linux I would use Gnu Common Lisp. On Windows, I use a program called Lisp Box.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 9:14 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
CrashTECH wrote:
How is it used in AI applications? Does it provide some behind the scene logic processing that in it's nature is more effective than having a procedural set of rules to follow?

For undergrad AI courses, Lisp is often one of the traditional languages taught in the course. Nine times out of ten, the instructor will probably be very familiar with Lisp (and usually not fond of C). You'll probably also be exposed to Prolog (or some other logic language) and maybe an expert system along the way. Indeed, this is what was covered in the undergrad AI class that I dropped (due to the teacher).

Surprisingly enough, you'll also see Java in quite a few AI classes these days due to 'agents'. Java's OOP and multi-threading support provide a nice environment for agent based programming.

CrashTECH wrote:
Has anybody here used it much? What uses does it have beyond AI?

Lisp is a great language -- period -- AI or no AI. In addition to the SICP lectures, I would also recommend reading some of Norvig's essays on Lisp. Probably the most powerful language feature in Lisp is the ability to do language abstraction. In a nutshell, Lisp makes it easy to write mini-domain specific languages to solve a variety of problems. I have been contemplating (for quite some) writing a computational geometry language and library in Lisp.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Jan 21, 2008 1:14 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Yeah... I know nothing about it. This prof is different than the one my buddy had for it and they used Prolog. As far as the prof being familiar with it, he seems "okay" but it doesn't seem like he is super familar with it. Over the two lecture demo he gave us, he goofed up a few things that to me, seemed like basic operations

I am sure it is very powerful, I guess I am just at the point in my academic career where I want out, and a break from class. I haven't had a semester off since 2003, and I have been working close to full time for the majority of the time since then.

It sounds horrible, but I don't want to "learn" anything this semester.

I am sure I will bring some "real" questions by once we start doing something. I am going to get started on our first "lab" which is basically "do these three tutorials step by step and write a paragraph about it..." seems lame, busy work to me. I would have rather been given an actual assignment with it and given another to do it than do three different tutorials.

I will look into using a different enviornment, but as per the lab/project instructions we have a env that he has picked out for us to use already. So we have to at least use that for this go-around.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Jan 21, 2008 9:42 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
CrashTECH wrote:
I am sure it is very powerful, I guess I am just at the point in my academic career where I want out, and a break from class. I haven't had a semester off since 2003, and I have been working close to full time for the majority of the time since then.

Sounds like it is time for a break. Taking time to recharge the batteries is important. Go write a bunch of web apps and come back when you're rested. =)

CrashTECH wrote:
I will look into using a different enviornment, but as per the lab/project instructions we have a env that he has picked out for us to use already. So we have to at least use that for this go-around.

In that case, you should probably use the environment they have chosen, but do yourself a favor and learn how to use it well by looking up some tutorials etc on the manufacturers site.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Jan 23, 2008 7:39 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
A break would be nice, but it is the last semester, I just need to power through it then I can "work" for a while :)

It is kinda crap though. It was crashing on my buddy while he was working through the assignment, and it apparently has a time limit to how long you can have the env open! LispWorks personal (cuz its free). I am kind of annoyed with it myself.


Top
  Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 8:23 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24224
Location: Granite Heaven
Last term! Woot! Give'er! Good luck, bud. :)


Top
  Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 6:46 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Jipstyle wrote:
Last term! Woot! Give'er! Good luck, bud. :)
Yeah... so far, it looks okay. Quantum Computing is actually pretty interesting, and it looks like it will be easy. Go figure! Engineering Statics is just a grind-me-through applied math, for crap I am never going to use in my professional career...

AI... I think, it might quite possibly kill me!

Edit: I removed the code. Apparently the prof is claiming that some of the students collaborated on the work. So I am removing it until this is resolved.

/sigh

Issues were cleared up! I am not sure what he did, because he never responded, but all of those involved got good grades on the coding portion (although some of the reports left things to be desired!

Code:
;; Function makes a random roll on a D6 (six-sided die)
(defun rolldie ()
   (setq x (random 6))
   (+ x 1)
)

;; This function will perform a craps roll of two dice and record the individual roll results
(defun rolldice()
   (let ((result nil))
      (push (rolldie) result)
      (push (rolldie) result)
   )
)

;; Function checks for double 1's
;; Roll is called snake eyes
(defun snakeeyes (x)
   (if (= (car x) 1)
      (if (= (second x) 1)
         T
      nil)
   nil)
)

;; Function checks for double 6's
;; Roll is called boxcars
(defun boxcars (x)
   (if (= (car x) 6)
      (if (= (second x) 6)
         T
      nil)
   nil)
)

;; Function checks for sum of 7 or 11
;; Determins if there is an instant win
(defun instawin (x)
   (if (= (+ (car x) (second x)) 7)
      T
      (if (= (+ (car x) (second x)) 11)
         T
      nil)
   )
)

;; Function checks for sum of 2 3 or 12
;; Determins if there is an instant loss
(defun instaloss (x)
   (setq sum (+ (car x) (second x)))
   (cond
      ((= sum 2) T)
      ((= sum 3) T)
      ((= sum 12) T)
      (nil)
   )
)

;; Display information for the craps function
(defun displaycraps (throw)
   (cond
      ((string= (instawin throw) T)
         (format nil "THROW RESULT: ~D AND ~D -- ~D -- YOU WIN" (car throw)
         (second throw) (+(car throw) (second throw)))
      )
      ((string= (instaloss throw) T)
         (if (snakeeyes throw)
            (format nil "THROW RESULT: ~D AND ~D -- SNAKEEYES -- YOU LOSE"
               (car throw) (second throw))
            (if (boxcars throw)(format nil "THROW RESULT: ~D AND ~D -- BOXCARS -- YOU LOSE"
               (car throw) (second throw))
               (format nil "THROW ~D AND ~D -- ~D -- YOU LOSE" (car throw) (second throw)
               (+(car throw) (second throw)))
            )
         )
      )
      ((format nil "THROW RESULT: ~D AND ~D -- YOUR POINT IS: ~D" (car throw) (second throw)
      (+(car throw) (second throw)) ))
   )
)

;; Function to run first roll of craps
(defun craps()
   (setq throw (rolldice))
   (displaycraps throw)
)

;; Function to handle display output for the trypoint func.
(defun displaytry (throw x)
   (setq tmpsum (+ (car throw) (second throw)))
   (cond
      ((= tmpsum x) (format nil "THROW RESULT:  ~D AND ~D -- ~D -- YOU WIN" (car throw) (second throw) tmpsum))
      ((= tmpsum 7) (format nil "THROW RESULT:  ~D AND ~D -- ~D -- YOU LOSE" (car throw) (second throw) tmpsum))
      ((format nil "THROW RESULT: ~D AND ~D -- ~D -- TRY AGAIN" (car throw) (second throw) tmpsum) )
   )
)

;; Function to handle the second roll in craps
(defun trypoint (x)
   (if (numberp x)
      (cond
         ((< x 1) "Not possible with two dice")
         ((= x 1) "Not possible with two dice")
         ((= x 2) "This was an instant loss")
         ((= x 3) "This was an instant loss")
         ((= x 7) "This was an instant win")
         ((= x 11) "This was an instant win")
         ((= x 12) "This was an instant loss")
         ((> x 12) "Not possible with two dice")
         ((setq throw (rolldice))
            (displaytry throw x)
         )
      )
      (error "Argument x is not a number")
   )
)


Last edited by CrashTECH on Thu Feb 14, 2008 6:16 am, edited 2 times in total.

Top
  Profile  
 
 Post subject:
PostPosted: Tue Feb 05, 2008 5:46 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
Nice -- I'll have to play some craps when I get a chance. =)


Top
  Profile  
 
 Post subject:
PostPosted: Tue Feb 05, 2008 7:37 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Gadget wrote:
Nice -- I'll have to play some craps when I get a chance. =)
I have changed a few things, but it works. I will be posting up my other ones as I write them... the 4th one... is to code A*.....

/wrist


Top
  Profile  
 
 Post subject:
PostPosted: Thu Feb 14, 2008 6:19 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Gadget wrote:
Nice -- I'll have to play some craps when I get a chance. =)
How did that go for you?


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group