Posts
Guess the Number, Part 5 - letting the player guess with cond and keywords
In this final part, we’ll finish the game by adding a second game mode which lets the player guess a number that the computer has thought of. We’ll also allow the player to choose between the two game modes. Along the way, we’ll do some reorganising of our code and learn a few new forms.
Code cleanup So far, we’ve done all our work in the -main function of core.
Posts
Guess the Number, Part 4 - looping
Currently, our Guess the Numbers game only works for 1 round: the computer makes a guess, the player answers, and the game ends. In this tutorial, we’ll keep the game going until the answer is reached, which we can accomplish using a loop.
Basically, we would like to accomplish this repetitive behavior:
I've thought of a number between 0 to 99... can you guess it? > 45 Bigger! > 78 Smaller!
Posts
Guess the Number, Part 3 - conditionals
In this part, we’ll have the computer react accordingly to the player input.
Conditional statements: if In programming, we use conditional statements to decide how the program will proceed when given a certain condition. Clojure supports conditional branching via a number of forms: if, while, cond, condp, and so on. The most basic of the forms is if.
(if (= 5 (+ 2 3)) "5 is equals to 2 plus 3" "5 is not equal to 2 plus 3") Try the above snippet in the REPL to see how if works.
Posts
Guess the Number, Part 2 - Computer's first guess, the REPL, and let
In this tutorial, we will get our feet wet with the Read-Eval-Print-Loop (or REPL for short) while creating the first part of our game, which is to let the computer guess the number that the player is thinking of.
The Logic To play the game, the computer has to guess a number between 0 to 99. One approach could be for the computer to keep on picking a random number until it gets the answer, but we would like for it to always get the right answer eventually.
Posts
Guess the Number, Part 1 - Hello, World!
Guess the Number is a very simple game where you try to guess the number that the opponent is thinking of. The opponent will then tell you whether your guess was bigger or smaller than the actual answer.
In this project, we will create a Guess the Number game where both you and the computer can take turns coming up with the number. Here’s what the game will look like after it’s done:
Posts
Getting Set Up with Clojure
Before you begin writing Clojure, you’ll need to equip yourself with some tools first.
Installing Java Clojure runs on top of the Java Virtual Machine (JVM). The JVM can be obtained by installing the Java Runtime Environment (JRE) or the Java Development Kit (JDK). Strictly speaking, you can run and do development with Clojure using the JRE alone, but it’s a good idea to install the JDK as it’s needed by leiningen (see below).
Posts
Making Portcullis
(In the game, you are a town guard who has to control which visitors can enter a town. Some want to help the town while others have evil intentions, so the town’s progress depends on how many “good” visitors you identify and let in.)
This year, I found out about the One Game A Month challenge, and thought it would be fun to participate. Like many gamers who happen to be software developers, I’ve always wanted to implement my own game ideas.
Posts
Beginning Practical Common Lisp
Spent last night reading Practical Common Lisp, stopped at chapter 3. Found chapter 2, creating a simple database with Lisp, quite exhilarating as I was taken from Hello World right up to defining macros, with simple (albeit contrived) examples of how they could help with code compression. I’ve always been kinda confused by their inner workings, but Peter Seibel’s explanation of explanation of how macros worked almost made sense to me, although that could be just due to the late hour.
Posts
Deploying Django with Git
This post explains how I set up a linux server such that I can deploy changes to a django application just using a git push. This is just what works for me, at the moment. In addition, the entire content is based on the article “Using Git for Deployment” from Dan Barber, so it is required reading as well.
Like Dan Barber, I set up two repositories on the server: