http://roguebasin.com/api.php?action=feedcontributions&user=Bencollver&feedformat=atomRogueBasin - User contributions [en]2024-03-28T12:34:17ZUser contributionsMediaWiki 1.36.0http://roguebasin.com/index.php?title=Common_Lisp&diff=36566Common Lisp2013-10-13T18:12:59Z<p>Bencollver: /* Known Common Lisp roguelikes */</p>
<hr />
<div>'''Common Lisp''' is a multi-paradigm programming language, which was used for programming roguelikes several times.<br />
<br />
==Known Common Lisp roguelikes==<br />
*[[LAngband]]<br />
*[http://groups.google.com/group/rec.games.roguelike.development/browse_thread/thread/5597ab6ddea1209a/407d6656e732b44d zombies 1drl]<br />
*[[Blast Tactics]]<br />
*[http://dto.github.io/notebook/void.html Void Mission]<br />
*[http://dto.github.io/notebook/sanctuary.html Sanctuary]<br />
*[[Invader Tactics]]<br />
*[[Laser Spigot]]<br />
*[[The Rougelike]]<br />
*[[The Sewer Massacre]]<br />
*[[Urban Warfare: The Escape]]<br />
*[http://sourceforge.net/projects/motm/ Menace of the Mines]<br />
*[https://github.com/nowl/detome detome]<br />
<br />
==The advantages==<br />
<br />
The ANSI standard of Common Lisp was written about 20 years ago. Let's look at the advantages that Common Lisp had and still has over most other programming languages.<br />
<br />
*Common Lisp is a high-level language. There is built-in support for various data structures: linked lists, arrays, hash tables, and so on, and the standard library contains a lot of useful functions to operate on them. Common Lisp is dynamically typed and garbage collected.<br />
*Unlike the recent trend of "scripting languages", Common Lisp code is compiled, and may achieve performance comparable to C and friends.<br />
*Common Lisp is partly functional. That means it allows many features not found in other languages, such as first-class functions. Unfortunately, that makes it harder to learn than most languages.<br />
*Common Lisp is partly object oriented. It has the most powerful object system known to mankind, CLOS, which supports multimethods, multiple inheritance, method combinations and is fully dynamic to boot.<br />
*Lisp programs are usually developed interactively. Instead of the usual edit-compile-run cycle, Common Lisp developer incrementally compiles, recompiles and tests individual functions to save his time. Lisp's famous REPL prompt allows to execute any Lisp code in the middle of writing your program. Using such tools as Emacs-based SLIME allows for even more progressive techniques.<br />
*The problem of repetitive code and "patterns" is solved by Lisp macros, which are much, much more powerful than their C counterparts.<br />
<br />
As you can see, Common Lisp was way ahead of it's time in 80s, and it's still ahead now. Maybe you could use this alien technology to get ahead of other roguelike developers?<br />
<br />
==Choosing an implementation==<br />
There are a lot of Common Lisp implementations, and they are mostly quite good. [http://sbcl.sourceforge.net/ SBCL] is an industrial-strength free implementation, and generally considered the best free Lisp for stuff like web-applications or where speed does matter. However, as a roguelike developer you'll want to choose [http://clisp.cons.org CLISP]. It is somewhat slower than SBCL, but two things set it apart: it runs quite well on Windows, and the executables it produces are not very big (<10 mb, compressed to ~3mb), unlike mammoth-sized SBCL images. Anyway, if you'll stick to ANSI standard and portable libraries, there's little difference between various Lisps.<br />
<br />
==Learning the language==<br />
[http://www.gigamonkeys.com/book/ Practical Common Lisp] is usually considered the best introductory book about CL. What's good about this book is how it really opens up the whole lot of possibilities, without the fawning advocacy that you'll find in some books on Ruby and similar trendy languages. <br />
<br />
Also check comp.lang.lisp Usenet newsgroup, which is frequented by the most skilled users of the language.<br />
<br />
==Can I use [[Curses]] on Lisp?==<br />
<br />
Yes, and you can use other C libraries (such as SDL and OpenGL) too. You can even use them more effectively, since you'll still have the advantages of interactive development (as with any Lisp program). This is done using Foreign Function Interface, such as [http://common-lisp.net/project/cffi CFFI]. You'll have to write a library wrapper that maps the functions of C library to Lisp functions, or use someone else's work. The wrappers for SDL and OpenGL are easily found through Google. The wrapper for PDCurses (and other curses variations) was written by [[Timofei Shatrov]] (get curses.lisp from the sources of his latest game). However it takes some work to set it up.<br />
<br />
By now, I'll assume you're using [http://common-lisp.net/project/slime/ SLIME] with CLISP. The basic setup ''won't'' work here, because curses and Emacs don't play well together. Here's a workaround: start CLISP separately and type:<br />
<br />
(load "/path/to/asdf.lisp")<br />
(load "/path/to/slime/swank.asd")<br />
(asdf:oos 'asdf:load-op :swank)<br />
(ext:saveinitmem "clispswank" :quiet t :norc t :executable t<br />
:init-function #'swank:create-server)<br />
<br />
Now, you'll have executable file called clispswank somewhere. Run it, and in Emacs type M-x slime-connect and press Enter until it connects. Now, you're in a good shape to start using curses. Load/compile CFFI, trivial-gray-streams and curses.lisp (you can automate this process by writing an appropriate asd file). Then you can start playing with it:<br />
<br />
(in-package :curses)<br />
(connect-console)<br />
(erase)<br />
(attrset :cpurple)<br />
(mvaddstr 2 2 "Hello World!")<br />
(refresh)<br />
<br />
Look how the text appears in the other window. You can start from here and incrementally develop the entire roguelike!<br />
<br />
[[Category:Programming languages]]</div>Bencollverhttp://roguebasin.com/index.php?title=Sandbox&diff=36565Sandbox2013-10-13T18:12:17Z<p>Bencollver: human</p>
<hr />
<div>I wish I knew what a newline is... since the help pages keep recommending that I use them.<br />
<br />
Not a bot too also...<br />
<br />
I am something not entirely unlike the complete opposite of a bot.<br />
<br />
Everyone else here is lying. Except me. I am not a bot.<br />
<br />
Nor am I for that matter<br />
<br />
I'm not a bot. kthx<br />
<br />
Not a bot also.<br />
<br />
Me neither.<br />
<br />
Why the room in the middle of the prints? Why not?<br />
<br />
Throwing sand in the Sandbox...<br />
<br />
Wonder if mathematical formulas, like this $E=mc^2$ work here?<br />
<br />
Or like <math>E=mc^2</math><br />
<br />
Let's see <br />
<source lang="java"><br />
package net.slashie.libjcsi.examples;<br />
<br />
import net.slashie.libjcsi.ConsoleSystemInterface;<br />
import net.slashie.libjcsi.wswing.WSwingConsoleInterface;<br />
<br />
/**<br />
* This shows a basic output window using the Swing interface.<br />
* @author Santiago Zapata<br />
*/<br />
public class SCBExample {<br />
<br />
public static void main(String[] args) {<br />
ConsoleSystemInterface csi = null;<br />
try {<br />
csi = new WSwingConsoleInterface("libjcsi example - Santiago Zapata", true);<br />
} catch (ExceptionInInitializerError eiie) {<br />
System.out.println("Fatal Error Initializing Swing Console Box");<br />
eiie.printStackTrace();<br />
System.exit(-1);<br />
}<br />
csi.cls();<br />
csi.print(1, 1, "Hello, Hello!", ConsoleSystemInterface.CYAN);<br />
csi.print(2, 3, "This is printed using the Java Console System Interface lib. (libjcsi)");<br />
csi.print(2, 4, "Swing Console Box Implementation", ConsoleSystemInterface.RED);<br />
<br />
csi.print(5, 6, "########", ConsoleSystemInterface.GRAY);<br />
csi.print(5, 7, "#......#", ConsoleSystemInterface.GRAY);<br />
csi.print(5, 8, "#......#", ConsoleSystemInterface.GRAY);<br />
csi.print(5, 9, "####/###", ConsoleSystemInterface.GRAY);<br />
<br />
csi.print(6, 7, "......", ConsoleSystemInterface.BLUE);<br />
csi.print(6, 8, "......", ConsoleSystemInterface.BLUE);<br />
<br />
csi.print(9, 9, "/", ConsoleSystemInterface.BROWN);<br />
<br />
csi.print(8, 8, "@", ConsoleSystemInterface.RED);<br />
csi.print(10,10,"A", ConsoleSystemInterface.GREEN);<br />
}<br />
}<br />
<br />
</source><br />
<br />
This is my first change.<br />
<br />
Sand boxes need sand castles<br />
<br />
There once was a user online<br />
<br />
Who surfed the web just fine<br />
<br />
Or so one thought until a bot<br />
<br />
Wrote all ur bases r mine<br />
<br />
<br />
<br />
4<br />
###<br />
### <br />
### <br />
### <br />
<br />
[[Roguelike Dev FAQ]]<br />
[[What a RL should be?]]</div>Bencollverhttp://roguebasin.com/index.php?title=Sandbox&diff=36564Sandbox2013-10-13T18:07:36Z<p>Bencollver: capcha</p>
<hr />
<div>I wish I knew what a newline is... since the help pages keep recommending that I use them.<br />
<br />
Not a bot too also...<br />
<br />
I am something not entirely unlike the complete opposite of a bot.<br />
<br />
Everyone else here is lying. Except me. I am not a bot.<br />
<br />
Nor am I for that matter<br />
<br />
I'm not a bot. kthx<br />
<br />
Not a bot also.<br />
<br />
Me neither.<br />
<br />
Why the room in the middle of the prints? Why not?<br />
<br />
Throwing sand in the Sandbox...<br />
<br />
Wonder if mathematical formulas, like this $E=mc^2$ work here?<br />
<br />
Or like <math>E=mc^2</math><br />
<br />
Let's see <br />
<source lang="java"><br />
package net.slashie.libjcsi.examples;<br />
<br />
import net.slashie.libjcsi.ConsoleSystemInterface;<br />
import net.slashie.libjcsi.wswing.WSwingConsoleInterface;<br />
<br />
/**<br />
* This shows a basic output window using the Swing interface.<br />
* @author Santiago Zapata<br />
*/<br />
public class SCBExample {<br />
<br />
public static void main(String[] args) {<br />
ConsoleSystemInterface csi = null;<br />
try {<br />
csi = new WSwingConsoleInterface("libjcsi example - Santiago Zapata", true);<br />
} catch (ExceptionInInitializerError eiie) {<br />
System.out.println("Fatal Error Initializing Swing Console Box");<br />
eiie.printStackTrace();<br />
System.exit(-1);<br />
}<br />
csi.cls();<br />
csi.print(1, 1, "Hello, Hello!", ConsoleSystemInterface.CYAN);<br />
csi.print(2, 3, "This is printed using the Java Console System Interface lib. (libjcsi)");<br />
csi.print(2, 4, "Swing Console Box Implementation", ConsoleSystemInterface.RED);<br />
<br />
csi.print(5, 6, "########", ConsoleSystemInterface.GRAY);<br />
csi.print(5, 7, "#......#", ConsoleSystemInterface.GRAY);<br />
csi.print(5, 8, "#......#", ConsoleSystemInterface.GRAY);<br />
csi.print(5, 9, "####/###", ConsoleSystemInterface.GRAY);<br />
<br />
csi.print(6, 7, "......", ConsoleSystemInterface.BLUE);<br />
csi.print(6, 8, "......", ConsoleSystemInterface.BLUE);<br />
<br />
csi.print(9, 9, "/", ConsoleSystemInterface.BROWN);<br />
<br />
csi.print(8, 8, "@", ConsoleSystemInterface.RED);<br />
csi.print(10,10,"A", ConsoleSystemInterface.GREEN);<br />
}<br />
}<br />
<br />
</source><br />
<br />
This is my first change.<br />
<br />
Sand boxes need sand castles<br />
<br />
<br />
<br />
<br />
<br />
4<br />
###<br />
### <br />
### <br />
### <br />
<br />
[[Roguelike Dev FAQ]]<br />
[[What a RL should be?]]<br />
<br />
There once was a user online<br />
Who surfed the web just fine<br />
Or so one thought until a bot<br />
Wrote all ur bases r mine</div>Bencollver