Re: Code structure/design problems

2011-07-29 Thread Michael Gardner
On Jul 29, 2011, at 1:50 AM, Laurent PETIT wrote: > Without too much thinking about it, I would have thought monsters, players, > etc. need to be changed in a same "transaction", so would have by default > implemented them as refs instead of atoms. > > Could you elaborate more on the choice of

Re: Code structure/design problems

2011-07-29 Thread msappler
Yes. This game was me starting to learn clojure a year ago and I just made it sequential. So I used atoms :) So for making it run in parallel I would have to change the atoms to refs. For example movement-update would need to synchronize the grid-cells and the position of an entity as one atomic

Re: Code structure/design problems

2011-07-28 Thread Laurent PETIT
Hi, 2011/7/29 msappler > I am also developing a clojure rpg and have open sourced the last > alpha version: > > https://code.google.com/p/clojure-rpg/ > > ~ > > Basically I am using an atom for every entity in the game (monster, > player, projectiles, explosions...) and for every cell in the gri

Re: Code structure/design problems

2011-07-28 Thread msappler
I am also developing a clojure rpg and have open sourced the last alpha version: https://code.google.com/p/clojure-rpg/ ~ Basically I am using an atom for every entity in the game (monster, player, projectiles, explosions...) and for every cell in the grid of the map. There are a lot of functio

Re: Code structure/design problems

2011-07-28 Thread Oskar
On Jul 28, 6:40 pm, Islon Scherer wrote: > Hi Oskar, I've been a game programmer for more than 5 years going from > simple card games to 3D MMORPGs. > Even though you can make a simple game in a functional way it would be a big > challenge to do the same with a moderately complex game. >

Re: Code structure/design problems

2011-07-28 Thread Oskar
Wow, thank you everyone! Lots of great responses. I'm going to take some time to let it all sink in. > I'd say "yes" if only for the experience of writing a "purely functional" > game (minus the I/O, of course). I wrote a Pong clone in a similar way, > though I don't share that author's dislike

Re: Code structure/design problems

2011-07-28 Thread Islon Scherer
Hi Oskar, I've been a game programmer for more than 5 years going from simple card games to 3D MMORPGs. Even though you can make a simple game in a functional way it would be a big challenge to do the same with a moderately complex game. Games are all about state, your character if full of state,

Re: Code structure/design problems

2011-07-28 Thread Jack Moffitt
> Hm it seems like what he did was a bit extreme. Would you do it that > way? In Clojure you could just use atoms and all would be well, right? > My game is going to be quite a bit more complex than Pac-Man, the game- > state is going to be way more complex. His stated goal was to provide examples

Re: Code structure/design problems

2011-07-28 Thread Benny Tsai
Hi Oskar, My apologies; when I linked that series of articles, I did not mean to imply that 100% pure functional is the only way to go. In the handful of simple games I've written in Clojure (all of which are probably less complex than yours), I've also taken the hybrid approach others have ad

Re: Code structure/design problems

2011-07-28 Thread Michael Gardner
On Jul 28, 2011, at 1:44 AM, Oskar wrote: > I have a hard time coming up reasons why this would be better. My > function that I wanted that checks if two characters are close enough > to each other is just a very small part of my game. And I could make > just that function fuctional and my list of

Re: Code structure/design problems

2011-07-28 Thread Alex Osborne
Hi Oskar! Excellent questions. I totally agree with you that writing a simulation in a purely functional style is not the (only) answer in Clojure. After all the primary goal of the language is to deal with (necessary) state well, not to get rid of it or hide it. Oskar writes: > For the monst

Re: Code structure/design problems

2011-07-28 Thread Sergio Bossa
I also value pragmatism and code simplicity over everything else, so I'd say: keep your "shared" state into "shared" refs, write down a few functions to manage such a state and limit every state changing activity to them, writing everything else, in particular all algorithms and logic, in purely fu

Re: Code structure/design problems

2011-07-28 Thread OGINO Masanori
I agree with Oskar. We can separate codes into state managers and others and move something to the latter if we find its state is unnecessary. After all, it is good enough--it might be not best, but good enough--if it seems that state managers are small enough, IMO. Of course, if there is no state

Re: Code structure/design problems

2011-07-27 Thread Oskar
On Jul 27, 5:07 pm, Benny Tsai wrote: > Hi Oskar, > > I just came across this article yesterday, which I thought you may find > useful. It's a 4-part series where the author discusses his experience > implementing games in a functional style: > > http://prog21.dadgum.com/23.html > > He was using

Re: Code structure/design problems

2011-07-27 Thread Ken Wesson
On Wed, Jul 27, 2011 at 10:04 AM, Oskar wrote: > I have an atom with characters (a map of maps) in my main file. But > because I don't want to make that file too big I have, for example, a > file called "ai.clj" with AI stuff, that I require from the main file. > For the monsters' AI to work, the

Re: Code structure/design problems

2011-07-27 Thread Benny Tsai
Hi Oskar, I just came across this article yesterday, which I thought you may find useful. It's a 4-part series where the author discusses his experience implementing games in a functional style: http://prog21.dadgum.com/23.html He was using Erlang, but I think many of the same ideas apply her

Code structure/design problems

2011-07-27 Thread Oskar
Hi! I'm making a game with Clojure. And I have a few code structure/design problems. I have an atom with characters (a map of maps) in my main file. But because I don't want to make that file too big I have, for example, a file called "ai.clj" with AI stuff, that I requir