Re: OO and game design questions

2010-11-15 Thread Aahz
In article , Martin Gregorie wrote: >On Tue, 19 Oct 2010 19:49:20 -0400, Dave Angel wrote: >> >> Thanks, that is what I was trying to say. In the same sense that >> emptying a list makes it quite small, if it's a general purpose object, >> you just want to remove all the attributes. > >I think a

Re: OO and game design questions

2010-10-23 Thread Gregory Ewing
Jonathan Hartley wrote: One common way to store delayed actions is as a lambda (an anonymous function.) Although note that you don't have to use 'lambda' in particular -- functions defined with 'def' can be used the same way. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: OO and game design questions

2010-10-21 Thread Jonathan Hartley
On Oct 20, 12:11 pm, dex wrote: > On Oct 20, 12:25 pm, Jonathan Hartley wrote: > > > > > On Oct 18, 8:28 am, dex wrote: > > > > I'm building a turn based RPG game as a hobby. The design is becoming > > > increasingly complicated and confusing, and I think I may have > > > tendency to over-engine

Re: OO and game design questions

2010-10-21 Thread Jonathan Hartley
On Oct 20, 12:11 pm, dex wrote: > On Oct 20, 12:25 pm, Jonathan Hartley wrote: > > > > > On Oct 18, 8:28 am, dex wrote: > > > > I'm building a turn based RPG game as a hobby. The design is becoming > > > increasingly complicated and confusing, and I think I may have > > > tendency to over-engine

Re: OO and game design questions

2010-10-21 Thread Jonathan Hartley
On Oct 20, 12:11 pm, dex wrote: > On Oct 20, 12:25 pm, Jonathan Hartley wrote: > > > > > On Oct 18, 8:28 am, dex wrote: > > > > I'm building a turn based RPG game as a hobby. The design is becoming > > > increasingly complicated and confusing, and I think I may have > > > tendency to over-engine

Re: OO and game design questions

2010-10-20 Thread dex
On Oct 20, 12:25 pm, Jonathan Hartley wrote: > On Oct 18, 8:28 am, dex wrote: > > > > > > > I'm building a turn based RPG game as a hobby. The design is becoming > > increasingly complicated and confusing, and I think I may have > > tendency to over-engineer simple things. Can anybody please chec

Re: OO and game design questions

2010-10-20 Thread Jonathan Hartley
On Oct 20, 11:25 am, Jonathan Hartley wrote: > On Oct 18, 8:28 am, dex wrote: > > > > > I'm building a turn based RPG game as a hobby. The design is becoming > > increasingly complicated and confusing, and I think I may have > > tendency to over-engineer simple things. Can anybody please check my

Re: OO and game design questions

2010-10-20 Thread Jonathan Hartley
On Oct 18, 8:28 am, dex wrote: > I'm building a turn based RPG game as a hobby. The design is becoming > increasingly complicated and confusing, and I think I may have > tendency to over-engineer simple things. Can anybody please check my > problems-solutions and point me to more elegant solution?

Re: OO and game design questions

2010-10-20 Thread dex
On Oct 19, 6:54 pm, Dennis Lee Bieber wrote: > On Tue, 19 Oct 2010 01:19:48 -0700 (PDT), dex > declaimed the following in gmane.comp.python.general: > > > > > OK, imagine a MUD, where players can "dig out" new rooms. Room A has a > > door that holds reference to newly created room B. By "using" a

Re: OO and game design questions

2010-10-20 Thread dex
On Oct 19, 8:08 pm, Carl Banks wrote: > On Oct 19, 1:19 am, dex wrote: > > > > > > > > I'm not sure if it's a good idea to let an item disappear from your > > > inventory by a weak reference disappearing.  It seems a little shaky > > > to not know where your objects are being referenced, but that

Re: OO and game design questions

2010-10-19 Thread Martin Gregorie
On Tue, 19 Oct 2010 19:49:20 -0400, Dave Angel wrote: > Thanks, that is what I was trying to say. In the same sense that > emptying a list makes it quite small, if it's a general purpose object, > you just want to remove all the attributes. > I think a 'place' (to generalise it) is quite a small

Re: OO and game design questions

2010-10-19 Thread Dave Angel
On 2:59 PM, Terry Reedy wrote: On 10/19/2010 1:46 PM, Ian Kelly wrote: On Tue, Oct 19, 2010 at 5:37 AM, Dave Angel mailto:da...@ieee.org>> wrote: Simply replace room B with a "destroyed room" object. That can be quite small, and you only need one, regardless of how many rooms are

Re: OO and game design questions

2010-10-19 Thread Terry Reedy
On 10/19/2010 1:46 PM, Ian Kelly wrote: On Tue, Oct 19, 2010 at 5:37 AM, Dave Angel mailto:da...@ieee.org>> wrote: On 2:59 PM, dex wrote: Using strong references, I have to remove room B from list of rooms, and also remove door to room B, as it holds reference to room B.

Re: OO and game design questions

2010-10-19 Thread Carl Banks
On Oct 19, 1:19 am, dex wrote: > > I'm not sure if it's a good idea to let an item disappear from your > > inventory by a weak reference disappearing.  It seems a little shaky > > to not know where your objects are being referenced, but that's yout > > decision. > > OK, imagine a MUD, where player

Re: OO and game design questions

2010-10-19 Thread Ian Kelly
On Tue, Oct 19, 2010 at 5:37 AM, Dave Angel wrote: > On 2:59 PM, dex wrote: > >> Using strong references, I have to remove room B from list of rooms, >> and also remove door to room B, as it holds reference to room B. To do >> that, I have to keep list of doors that lead to room B. >> >> Using w

Re: OO and game design questions

2010-10-19 Thread Roy Smith
dex wrote: > I'm building a turn based RPG game as a hobby. The design is becoming > increasingly complicated and confusing Such is often the case in real life code :-) > In turn-based games, the order of action execution in battle can give > unfair advantage to players. [...] Is there a design

Re: OO and game design questions

2010-10-19 Thread Dave Angel
On 2:59 PM, dex wrote: I'm not sure if it's a good idea to let an item disappear from your inventory by a weak reference disappearing. It seems a little shaky to not know where your objects are being referenced, but that's yout decision. OK, imagine a MUD, where players can "dig out" new rooms

Re: OO and game design questions

2010-10-19 Thread dex
> I'm not sure if it's a good idea to let an item disappear from your > inventory by a weak reference disappearing.  It seems a little shaky > to not know where your objects are being referenced, but that's yout > decision. OK, imagine a MUD, where players can "dig out" new rooms. Room A has a doo

Re: OO and game design questions

2010-10-18 Thread Carl Banks
On Oct 18, 6:50 am, dex wrote: > > You're aware Python can collect reference cycles, correct?  You don't > > have to delete references; Python will get them eventually.   > > I'm not sure I understand this part? If I don't delete all strong > references, the object will not be deleted. > It will p

Re: OO and game design questions

2010-10-18 Thread Benjamin Kaplan
On Mon, Oct 18, 2010 at 9:50 AM, dex wrote: >> You're aware Python can collect reference cycles, correct?  You don't >> have to delete references; Python will get them eventually. > > I'm not sure I understand this part? If I don't delete all strong > references, the object will not be deleted. >

Re: OO and game design questions

2010-10-18 Thread dex
> You're aware Python can collect reference cycles, correct?  You don't > have to delete references; Python will get them eventually.   I'm not sure I understand this part? If I don't delete all strong references, the object will not be deleted. It will persist and occupy memory as long as there's

Re: OO and game design questions

2010-10-18 Thread Jean-Michel Pichavant
dex wrote: In each object's __init__() that object is added to game_object list, and in each __del__() they are removed from game_object list. This mechanism keeps them safe from garbage collector. How pythonic is this design? You don't have to manage memory with python, I don't know if you w

Re: OO and game design questions

2010-10-18 Thread Carl Banks
On Oct 18, 12:28 am, dex wrote: > Every item/character/room is a separate object. Items/characters need > to have references to room they are in, and room needs to have a list > of references to items/characters that are contained within. I decided > to use weak references. That way I can destroy

OO and game design questions

2010-10-18 Thread dex
I'm building a turn based RPG game as a hobby. The design is becoming increasingly complicated and confusing, and I think I may have tendency to over-engineer simple things. Can anybody please check my problems-solutions and point me to more elegant solution? Every item/character/room is a separat