A style question.
I've got a world data object, which I pass into my functions. It looks
like this:
```clojure
(def world
(atom {:flags #{:want-umbrella}
:location :home
:inventory #{...}
:map {:home {...} :patio {...}))
```
My default describe-room method
Excellent. Yeah, I was thinking I was probably going to too much trouble
to get the "nil" value. And the (derive) solution is very nice.
Thanks very much!
On Monday, April 2, 2018 at 11:30:53 AM UTC-7, Mikhail Gusarov wrote:
>
> Hello Will.
>
> You can simplify it further:
>
> 1. Define a
Hello Will.
You can simplify it further:
1. Define a multimethod always dispatching by room id.
2. Create a :default implementation. It will be called for non-
fancy rooms.3. Create an implementation for :fancy-room. It will be
preferred over
:default for it.
If you ever have a group of
Spent the weekend pondering all of this, and here's the way I think I want
to do it.
1. The world-state is stored in an atom, and updated much as Gary Johnson
suggests.
2. I define a multi-method, (describe-room [room world-state]), that is
responsible for computing the current description of
Thanks!
On Friday, March 30, 2018 at 11:12:04 AM UTC-7, Karsten Schmidt wrote:
>
> Hi Will,
>
> have a look at this workshop repository, in which we developed a
> simple text adventure framework:
> https://github.com/learn-postspectacular/resonate-workshop-2014
>
> Hth! K.
>
> On 30 March
Gary,
Thanks for the detailed answer.
What you're describing is pretty much exactly what I'm trying to do,
including the game loop you mention. The basic implementation is pretty
simple: a player who can move from room to room, picking up objects,
putting them down, and so forth, and the
Thanks! I've glanced at Land of Lisp, actually, some while back. I might
even have a copy.
To be clear, it isn't LISP that's giving me problems. I've been dabbling
with LISP on-and-off since the '80's, and I've read a couple of Paul
Graham's books. I understand code-as-data, and lambdas,
Thanks!
On Thursday, March 29, 2018 at 6:10:56 PM UTC-7, James Reeves wrote:
>
> Often it's better to store the entire game state as one large, immutable
> data structure.
>
> Atoms are usually preferred over refs in most cases.
>
> When you want polymorphism over a map, the most common solution
Howdy!
Yeah, I get this; and for most of the rooms it's plenty good enough. It's
the ones that are complicated that concern me. Writing text adventures has
been one of my standard ways of learning new languages, going back to the
mid-80s to a simple text adventure I wrote—in LISP,
Hi Will,
have a look at this workshop repository, in which we developed a
simple text adventure framework:
https://github.com/learn-postspectacular/resonate-workshop-2014
Hth! K.
On 30 March 2018 at 16:01, Gary Johnson wrote:
> Hi Will,
>
> Welcome to the wide world of
Hi Will,
Welcome to the wide world of functional programming, where data flows, and
functions transmute without destroying their inputs.
As some others in this thread have already suggested, a general approach to
viewing any problem space from a functional perspective is to imagine your
http://landoflisp.com/ is specifically about coding games in Lisp, in case
you're into books. :)
On Thu, Mar 29, 2018 at 6:45 PM, Will Duquette wrote:
> I'm an experienced programmer, but a Clojure newbie; as a beginner
> project, I'm looking into how one would
Often it's better to store the entire game state as one large, immutable
data structure.
Atoms are usually preferred over refs in most cases.
When you want polymorphism over a map, the most common solution is to use
protocols and records.
On 29 March 2018 at 23:45, Will Duquette
You often don't even need functions for this sort of thing. This is what is
often called "data driven" programs. Simply define this as a hashmap with
:description, :items, etc and then a single function that introspects this
data and figures out how to describe the room.
Also you might want to
Aha! How about this, to cut the Gordian knot:
1. The fancy room's :description isn't necessarily a simple string. It
can be a vector of specs, where each spec is a text snippet or a pair
containing a predicate function and a text snippet.
2. The (describe) function takes two
I'm an experienced programmer, but a Clojure newbie; as a beginner project,
I'm looking into how one would idiomatically write a text adventure of
sorts in Clojure. I'm less interested in producing a playable game than I
am in learning how to do such a thing in a proper functional style.
16 matches
Mail list logo