From: Huw Collingbourne Date: 2008-02-21T06:41:54+09:00 Subject: Re: Beginner help - txt dungeon I understand your thoughts about singletons. In a sense, each game might be represented by a singleton. In my own simple Ruby adventure game system (mentioned earlier in this thread) I have three classes - Adventure (the game itself), Implementor (the thing that 'controls' the nitty-gritty details of the game) and the Map - all of which have only one instance. I haven't myself implemented them as singletons as I couldn't see any obvious benefit in doing so and I tend to think that singletons reduce the clarity of the class hiererchy so I don't use them habitually. I have also opted for an array for simplicity. A map can easily be created by having numbered rooms and attributes indicting the rooms to which they adjoin e.g. 1 -- 2 | 3 -- 4 In the above, room 1's east attribute is 2, its south attribute is 3 etc. The attraction of a hash is that the key would not need to be a number - it could actually the name of a room { :east => :dungeon, :south => :cave } and so on. In fact, I wrote a simple example of a game framework in Smalltalk that uses exactly this method: map at: 'Station 1' put: 'Belsize Park'; at: 'Station 2' put: 'Chalk Farm'; at: 'Station 3' put: 'Camden Town'; at: 'Your destination' put: 'Mornington Crescent'. http://www.bitwisemag.com/copy/programming/smalltalk/smalltalk2.html This has some attractions of readability (names not numbers) but I'm not really convinced it is more practical than a simple indexed array. The secret is to draw out a map on a sheet of paper first, give all the rooms numbers, draw lines showing the exits and then create the array with all the correct numbers as attributes to show which room number is in which direction. best wishes Huw SapphireSteel Software Ruby and Rails In Visual Studio http://www.sapphiresteel.com -- Posted via http://www.ruby-forum.com/.