Re: [Tutor] designing POOP
"bhaaluu" <[EMAIL PROTECTED]> wrote > PyUnit: > It really doesn't seem to be an "absolute beginner" technique. Unit tests and TDD is not a design technique per se. It is definitely not a technique for designing OOP programs its a programming technique that makes code more reliable (whether OOP or not). Where it does help in design is by focussing attention on how a class (or function) should behave from the consumers perspective. This is always a good thing. But TDD in itself will not help you identify classes or their interactions. It will help you build classes that are user friendly and work as expected. > The noun/verb/adjective technique seems to be geared > more towards beginners. I like the idea of that technique. It is completely intended for beginners. It is, in practice, a little too naive for production type use but it is a good starting point when you don't know where to go and don;t have lots of experience in the problem domain. What nouns/verbs does is identify candidate classes and operations. It says nothing about how those operations are to be coded or used. Once you know what classes you want to write TDD can help you build them better, but you have to identify them first! > One thing I'm encouraged by: in Alan's tutorial, he > says that I don't have to "see the light" to use POOP. Absolutely, you have been using string objects and file objects already. You can use classes to bundle data and methods together and use them in an object based approach without fully understanding OOP. But OOP does open up new avenues and possibilities and, particularly in larger programs, offers significant savings in effort and reuse. -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
Alan Gauld wrote: > Unit tests and TDD is not a design technique per se. > It is definitely not a technique for designing OOP programs > its a programming technique that makes code more reliable > (whether OOP or not). > > Where it does help in design is by focussing attention > on how a class (or function) should behave from the consumers > perspective. I agree that TDD is not a design technique, but it does strongly influence design by introducing testability as a design requirement. TDD strongly encourages loose coupling and reusability. - loose coupling because classes and functions that depend on many other classes/functions/modules are harder to test - reusability because of the loose coupling and because any code that has unit tests already has two clients - the production code and the tests. I like to say, no code is reusable until it has been reused. Although a bit of an overstatement, there is a lot of truth in it. It is very hard to anticipate how a bit of code might be reused without actual reuse. TDD provides an artificial second use which promotes reusability. TDD also promotes incremental development where the design evolves to meet current requirements. This is sometimes called Test-Driven Design: http://www.agiledata.org/essays/tdd.html http://www.salientblue.com/blog/?p=10 So TD development can be part of a process that includes design. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
bhaaluu wrote: > class Explorer(object): > """player""" > def __init__(self,name): > """initilaization method""" > self.__name = name > self.strength = 20 > self.wealth = 60 > > def get_name(self): > return self.__name There is no need for get_name(). Just refer to explr.name, the same as for strength and wealth. > class Light(object): > """light switch""" > > def __init__(self,light): > self.light = light > > def state(self): > if self.light == 0: > print (" IT IS TOO DARK TO SEE ANYTHING") > else: > print (" THE LIGHTS ARE ON, BUT NO ONE'S HOME") show_state() or print_state() might be a better name. If you call this method __str__() and just return the string instead of printing it, it will be called when you print switch > def cs(): > print "\n"*50 > > def main(): > tally = 0 > switch = Light(0) #instance > cs() # clear screen > name = raw_input(" WHAT IS YOUR NAME, EXPLORER? ") > explr = Explorer(name) > while True: > cs() # clear screen > print (" %s, YOUR STRENGTH IS %d" % (explr.get_name(), > explr.strength)) > print (" YOU HAVE $%d" % explr.wealth) This could be Explorer.__str__(): def __str__(self): return " %s, YOUR STRENGTH IS %d\n YOU HAVE $%d" % (self.get_name(), self.strength, self.wealth) Then the prints become just print explr > switch.state() > print > print > answer = raw_input(" WHAT DO YOU WANT TO DO? [Q|L]: ") > if answer.upper() == "Q": > break > if answer.upper() == "L": > if switch.light == 1: > switch.light = 0 > else: > switch.light = 1 > explr.strength -= 5 > explr.wealth -= 15 > if explr.wealth <= 0: > print > print (" YOU HAVE NO MONEY") > time.sleep(1) > if explr.strength <= 0: > print > print (" YOU DIED...") > time.sleep(1) > break This could be two Explorer methods: def change_wealth(self, incr): self.wealth += incr if self.wealth <= 0: print print (" YOU HAVE NO MONEY") time.sleep(1) Then call explr.change_wealth(-15) Strength is a little trickier because you need to break out of the loop. You could have def change_strength(self, incr): self.strength += incr if self.strength <= 0: print print (" YOU DIED...") time.sleep(1) self.alive = False Then in Explorer.__init__() set self.alive = True and change the loop from while True: to while explr.alive: This would give you an Explorer class that actually does something useful. Kent > else: > print (" INVALID CHOICE") > tally += 1 > print > print (" FINAL SCORE:") > print ("TALLY: %d" % tally) > print (" STRENGTH: %d" % explr.strength) > print (" WEALTH: $%d" % explr.wealth) > > if __name__ == "__main__": > main() > > Happy Programming! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
On Feb 8, 2008 3:24 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > > and change the loop from >while True: > to >while explr.alive: > > This would give you an Explorer class that actually does something useful. > > Kent > It also cleaned up main(), and put everything in well defined packages at the top of the program. I can see do difference in "game play". 8^D Here are your changes implemented, and working on my Linux system: #!/user/bin/python import time class Explorer(object): """player""" def __init__(self,name): """initilaization method""" self.name = name self.strength = 20 self.wealth = 60 self.alive = True def __str__(self): return " %s, YOUR STRENGTH IS %d\n YOU HAVE $%d" % (self.name, self.strength, self.wealth) def change_wealth(self, incr): self.wealth += incr if self.wealth <= 0: print print (" YOU HAVE NO MONEY") time.sleep(1) def change_strength(self, incr): self.strength += incr if self.strength <= 0: print ("\n\n YOU DIED...") time.sleep(1) self.alive = False class Light(object): """light switch""" def __init__(self,light): self.light = light def __str__(self): if self.light == 0: return " IT IS TOO DARK TO SEE ANYTHING" else: return " THE LIGHTS ARE ON, BUT NO ONE'S HOME" def cs(): print "\n"*50 def main(): tally = 0 switch = Light(0) #instance cs() # clear screen name = raw_input(" WHAT IS YOUR NAME, EXPLORER? ") explr = Explorer(name) while explr.alive: cs() # clear screen print explr print switch print print answer = raw_input(" WHAT DO YOU WANT TO DO? [Q|L]: ") if answer.upper() == "Q": break if answer.upper() == "L": if switch.light == 1: switch.light = 0 else: switch.light = 1 explr.change_wealth(-15) explr.change_strength(-5) else: print (" INVALID CHOICE") tally += 1 print print (" FINAL SCORE:") print ("TALLY: %d" % tally) print (" STRENGTH: %d" % explr.strength) print (" WEALTH: $%d" % explr.wealth) if __name__ == "__main__": main() Thanks Kent! I like these small incremental changes with explanations. I especially like the way you took blocks of code from main() and made methods out of them. The actual code itself, hardly changed! Happy Programming! -- b h a a l u u at g m a i l dot c o m "You assist an evil system most effectively by obeying its orders and decrees. An evil system never deserves such allegiance. Allegiance to it means partaking of the evil. A good person will resist an evil system with his or her whole soul." [Mahatma Gandhi] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] HTTPS file upload
I have a requirement to automate uploading files using https. The https server doesn't give a form or anything they just gave me a URL and said to "push" the files to the URL using HTTPS. Does anyone here have an idea how to do this. I have done some Python programming but nothing like this, and there is a fairly short turn around required on this one. I have done some searching on www and have found a few things that seem like they do something simular, but nothing that looked like the right answer to this. Thanks for any suggestions and/or advice that you can give. s ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
On Feb 7, 2008 9:40 PM, Tiger12506 <[EMAIL PROTECTED]> wrote: > There's a couple of errors in here that no one has addressed yet because the > question was geared towards programming style... So now I will address them. > Or undress them, I suppose. ;-) I didn't make much progress until I started thinking about the Explorer and Light classes as actual objects. I've tried to address what you undressed. 8^D Here is another version to undress: #!/user/bin/python import time class Explorer(object): """player""" def __init__(self,name): """initilaization method""" self.__name = name self.strength = 20 self.wealth = 60 def get_name(self): return self.__name class Light(object): """light switch""" def __init__(self,light): self.light = light def state(self): if self.light == 0: print (" IT IS TOO DARK TO SEE ANYTHING") else: print (" THE LIGHTS ARE ON, BUT NO ONE'S HOME") def cs(): print "\n"*50 def main(): tally = 0 switch = Light(0) #instance cs() # clear screen name = raw_input(" WHAT IS YOUR NAME, EXPLORER? ") explr = Explorer(name) while True: cs() # clear screen print (" %s, YOUR STRENGTH IS %d" % (explr.get_name(), explr.strength)) print (" YOU HAVE $%d" % explr.wealth) switch.state() print print answer = raw_input(" WHAT DO YOU WANT TO DO? [Q|L]: ") if answer.upper() == "Q": break if answer.upper() == "L": if switch.light == 1: switch.light = 0 else: switch.light = 1 explr.strength -= 5 explr.wealth -= 15 if explr.wealth <= 0: print print (" YOU HAVE NO MONEY") time.sleep(1) if explr.strength <= 0: print print (" YOU DIED...") time.sleep(1) break else: print (" INVALID CHOICE") tally += 1 print print (" FINAL SCORE:") print ("TALLY: %d" % tally) print (" STRENGTH: %d" % explr.strength) print (" WEALTH: $%d" % explr.wealth) if __name__ == "__main__": main() Happy Programming! -- b h a a l u u at g m a i l dot c o m "You assist an evil system most effectively by obeying its orders and decrees. An evil system never deserves such allegiance. Allegiance to it means partaking of the evil. A good person will resist an evil system with his or her whole soul." [Mahatma Gandhi] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
On Feb 8, 2008 4:46 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > bhaaluu wrote: > > > It also cleaned up main(), and put everything in well defined packages > > at the top of the program. > > Yes, good OOD puts things into cohesive, comprehensible packages. > > > I can see do difference in "game play". 8^D > > And that's a good thing, right? > > "Refactoring is the process of changing a software system in such a way > that it does not alter the external behavior of the code yet improves > its internal structure." -- Martin Fowler in Refactoring > > The refactoring you just did is called Extract Method: > http://www.refactoring.com/catalog/extractMethod.html > > Kent > This is something that one can only gain from experience? I really had to struggle to get the Light class to work at all. I have no idea how many times I started over. But I do feel that I am starting to learn some of this stuff. As "simple" as the adventure game is, I can see that it will provide lots of practice for me to design and code it in Python OOP. Thanks Kent! -- b h a a l u u at g m a i l dot c o m "You assist an evil system most effectively by obeying its orders and decrees. An evil system never deserves such allegiance. Allegiance to it means partaking of the evil. A good person will resist an evil system with his or her whole soul." [Mahatma Gandhi] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Is it possible?
Is it possible to write a program that you pipe other programs through and it measures the MBs per second of data moved? Like I could pipe it a cp and find out how fast the cp is working? Thanks, Nate ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
bhaaluu wrote: > On Feb 8, 2008 4:46 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: >> "Refactoring is the process of changing a software system in such a way >> that it does not alter the external behavior of the code yet improves >> its internal structure." -- Martin Fowler in Refactoring > This is something that one can only gain from experience? Experience and study. I don't think there is much substitute for experience to see *why* OOP and refactoring and clean design are useful. There is nothing like growing a program to the point where you don't know how it works or how to change it to make you appreciate good design :-) Studying gives you good examples to follow and new techniques to try. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
bhaaluu wrote: > It also cleaned up main(), and put everything in well defined packages > at the top of the program. Yes, good OOD puts things into cohesive, comprehensible packages. > I can see do difference in "game play". 8^D And that's a good thing, right? "Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure." -- Martin Fowler in Refactoring The refactoring you just did is called Extract Method: http://www.refactoring.com/catalog/extractMethod.html Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
> This is something that one can only gain from experience? > I really had to struggle to get the Light class to work at all. > I have no idea how many times I started over. But I do feel > that I am starting to learn some of this stuff. This surprises me... I guess it does take experience. What is the most basic thing you can describe about a light? Immediately I answer, "You can turn it on or off". This suggests methods, turn_on(), turn_off(), and something to maintain the state of the light attribute - i.e. whether it is currently on or not. I suggest practice practice practice. You should be able to look at anything in your house and be able to design a basic class for it. Some that come to mind as I look around the room. I've often thought of redesigning my entire house in OOP. ;-) (Granted - these examples aren't entirely useful, but they provide examples of practice with methods and attributes.) class Pen: def __init__(self): self.level = 50 self.on = False def click(self): self.on = (not self.on) def isempty(self): return (self.level > 0) def write(self): if self.isempty: return False if not self.on: return False self.level = self.level - 5 return True class Knob: def __init__(self, locked=False): self.locked = locked def turn(self): if self.locked: return False return True class Door: def __init__(self): self.knob = Knob() def lock(self): self.knob.locked = True def unlock(self): self.knob.locked = False def open(self): return self.knob.turn() Are some simple examples off the top of my head. It's not difficult to model real-life things with classes, but it is much more difficult to model them in such a way that you interact with them normally. (i.e. do you lock the door, or the knob? Does the knob contain a Lock, or does the developer only need to know that it has one and whether it is locked or not?) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Cobra
It's dangerous posting something like this on a python website. ;-) It has definite strengths over python, it seems, and some things I do not like. Particularly interesting is the compilation directly to exe. Damn. I'm am seriously impressed with that. Cobra appears too new to learn and switch to yet but, I think that will/would be the deciding factor for me when it grows a little older. I dislike the method for string interpolation, but I presume that's because I'm used to python and c... I would have to search through the docs of cobra, but my glance did not show me that it has the flexibility of python... The discussion of accuracy is meerly a preference. I personally would like my program to not virtualize every math operation i tell it to do. Sure, accuracy is useful in situations of finance or theoretical mechanics, but someone very wise once told me that significant digits mean more than abtract, unattainable accuracy. (Danny I think) Python's default to use integer arithmetic is supposed to be changed in the new release of 3.0. Also, I wish to mention that my first impression of cobra is that somebody didn't like python and customized it slightly. rip-off, in other words. But the exe compilation directly, using C#... That is different. Powerful. I like it. It has a definite future. > Peter Dilley posted these links on the python-list a few hours ago. > Cobra looks VERY interesting to me. > > Comparison to Python: > http://cobra-language.com/docs/python/ > > Main Page: > http://cobra-language.com/ > > Article that first caught my eye regarding Cobra: > http://www.computerworld.com.au/index.php/id;342684174;fp;16;fpid;1 > > Dick Moores > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Cobra
Tiger12506 wrote: > It's dangerous posting something like this on a python website. ;-) It is a bit off-topic, especially for this list. c.l.python is a little better but one of the general language forums would be more appropriate. > Particularly interesting is the compilation directly to exe. You might be interested in Boo, which is a language for .NET that is inspired by Python. It seems fairly mature and it can compile to .exe: http://boo.codehaus.org/ http://docs.codehaus.org/display/BOO/How+To+Compile Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Cobra
"Tiger12506" <[EMAIL PROTECTED]> wrote > It has definite strengths over python, it seems, and some things I > do not > like. My feelings too. My main gripes being that it is based on .NET/Mono and that it only supports OO, no procedural or Functional code. But it has enough positive features that it is definitely one to watch. -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] NYC Python Users Meetup February Meeting Announcement....
Please pardon the PSA: The New York City Python Users Meetup Group is planning on having our February meeting on February 12th, from 6:30pm - 8:00pm. For more information, please see: http://python.meetup.com/172/calendar/7082384/ Anyone in the NYC area interested in using Python, learning more about Python, or teaching others about Python is welcome to attend. Thanks, -jdc ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
"bhaaluu" <[EMAIL PROTECTED]> wrote There have been lots of comments about this already but I'm deliberately jumping in at this level because I want to pick up a few general points... > class Explorer(object): >"""player""" >def __init__(self,name): >"""initilaization method""" >self.__name = name >self.strength = 20 >self.wealth = 60 > >def get_name(self): >return self.__name Kent already pointed out this is not needed. But as a general rule consider what I said earlier about objects being based on behaviour. And that the data should be there to support the behaviour. So in this case ask: Why do I have a name, strength and wealth? What behaviour do these support? Behaviour is expressed as methods so I am expecting to see methods sof Explorer that use the attributes, otherwise the Explorer is just a data container like a list or dictionary. > class Light(object): >"""light switch""" > >def __init__(self,light): >self.light = light > >def state(self): >if self.light == 0: >print (" IT IS TOO DARK TO SEE ANYTHING") >else: >print (" THE LIGHTS ARE ON, BUT NO ONE'S HOME") You have a method here that reports the state but doesn't a light switch usually do something? Like turn the light on or off? Usually by a toggle operation? So maybe a toggle method would be good: def toggle(self): self.light == not self.light # make it a boolean Also remembering the principle that UI and logic should be separated it might be good to pull the printing out of the class and just let the method returmn the string. And as Kent already suggested for Explorer that could be done with an __str__ method so all you need do in the consumer is: print switch > def cs(): >print "\n"*50 > > def main(): >tally = 0 >switch = Light(0) #instance >cs() # clear screen >name = raw_input(" WHAT IS YOUR NAME, EXPLORER? ") >explr = Explorer(name) >while True: >cs() # clear screen >print (" %s, YOUR STRENGTH IS %d" % (explr.get_name(), > explr.strength)) >print (" YOU HAVE $%d" % explr.wealth) Kent has addressed this specifically but as a general rule remember the consumer should not have to get at the data attributes of an object. You should only need to send messages to the Explorer, in this case it's a status report - which we already said can be done via a __str__ method. >switch.state() >print >print >answer = raw_input(" WHAT DO YOU WANT TO DO? [Q|L]: ") >if answer.upper() == "Q": >break >if answer.upper() == "L": >if switch.light == 1: >switch.light = 0 >else: >switch.light = 1 And here is the toggle method, except its in your program rather than in the object. Let the object do it to itself, do not try to mess with the data directly if answer.upper() == "L": switch.toggle() >explr.strength -= 5 >explr.wealth -= 15 Now I'm not quite sure why you decrease these but again the Explorer should be doing it to himself - objects do it to themselves. If the Explorer always loses strengty and wealth after a turn then the method could be called newTurn() or somesuch. But I suspect there might be a more meaningful name we could use. >if explr.wealth <= 0: >print >print (" YOU HAVE NO MONEY") >time.sleep(1) >if explr.strength <= 0: >print >print (" YOU DIED...") >time.sleep(1) >break And all of this could be built into the explorer method above, maybe implemented as an exception? def newTiurn(self): self.wealth -= 15 self.strength -= 5 if self.wealth <= 0: raise ExplorerBroke if self.strength <= 0 raise ExplorerDied You control code then looks something like: if answer.upper() == "L": switch.toggle() try: explr.newTurn() except ExplorerBroke e: print e.message except ExplorerDied e: print e.message Or with a bit more intelligence in the __str__ method if answer.upper() == "L": switch.toggle() try: explr.newTurn() except ExplorerBroke,ExplorerDied: print explr Really the outside control code should be focused around the user interaction and senmding messages to the objects. It should not be pulling out data from inside the objects to do anything with it, that is the job of the objects. Occasionally we can break that rule if its just for printing or maybe to assign directly to another value. For example you could dir
Re: [Tutor] Is it possible?
"Nathan McBride" <[EMAIL PROTECTED]> wrote > Is it possible to write a program that you pipe other programs > through > and it measures the MBs per second of data moved? Like I could pipe > it > a cp and find out how fast the cp is working? Not in any kind of general sense. Even for cp its not clear what it would report. On some OS cp is often not actually moving any data but just readjusting file pointers within the directory structure. And thats even more true for mv. So would you count the size of the pointers changed or the size of the file being referenced? And what about a mv thats really a rename? And what about ls? It doesn't move any data but you might count the characters in the listing? Or the number of files? Or even the total sizes of the files listed? It would be very difficult to write a general purpose program that could cater for all of those. However you could do one for each specific case... Although in most cases there are already standard Unix tools that will do the job. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] designing POOP
> There is nothing like growing a program to the point where you don't > know how it works or how to change it to make you appreciate good design Amen. I was recently fighting with an example of a multi-client, simple server that I wanted to translate into assembly. Not only was the code unreadable, but they had tried to apply a functional programming technique that failed miserably. Final result: Less # of lines, better readability, and slightly more algorithm efficient. Even with that change of language to something horrendously verbose. Key idea: Choose a design wisely. Understand that if a design does not enhance readability or code reusability, it's a bad design. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Adding network play to an open source game.
Hi. First of all, I'm not an amazing programmer. But, I do have large goals, somtimes too large. There is an open source game, konquer, (it's on the ubuntu repos.) that I would like to extend with python to include a network based game. But, I only know how to do simple sockets Is this too big a project for first year programmer? (I've been programing for 3, but have taken classes only one year.)The program is like a board game. You move your fleets to different planets, one at a time. The game is written in C++(I think). Just as a preliminary thing, I will go through how I think it will work. One computer in the network will be designated as the 'server' that everyone will send information to. Each turn, four pieces of data will have to be sent to the 'server' that I can think of right now.: 1. how many fleets have left 2. from what planet 3. going to which planet 4.taking how long to get there. From there, the server will then issue those to each player, and tell which player is next, and wait for his reply. I don't really know how to start, so I guess I will start here. I appreciate your reply. _ Need to know the score, the latest news, or you need your HotmailĀ®-get your "fix". http://www.msnmobilefix.com/Default.aspx ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Adding network play to an open source game.
I wish to warn you that I've never done anything like this before, but I have a couple of thoughts here. First thought is, network games tend to be slow because sending state information to everyone with enough frames per second to make it decent game play is a lot of information to send... So the least information you have to send the better. Fortunately, now that I read a little more closely... A board game is not going to be bad about this... Second thought is... start with simple sockets, work with the server model and the clients, do not mess with the game at first. Get dummy data to behave properly first before you ever try anything with the game itself. Third thought. C++ is a different language from python. This will further intensify your trouble. In fact, depending on your knowledge of C++, this could greatly intensify your trouble. You could have step two there going just perfectly, but getting python and C++ to talk could throw you in loops. I would say that generally for a programmer of a year, this seems like a very significant goal. Not only do you have to understand quite precisely what the C++ program is doing, (difficult especially in a game, IMO), but you have sockets to deal with, client, server, and just as difficult, C++/Python interaction. Also, given that you didn't write konquer~ someone else's code is harder to read than your own. Trust me. My suggestion is, if you are going to tackle this, very definitely take it in very defined steps. Work on sockets here, then C++/Python here, etc. I don't wish to discourage you, but I wouldn't try this yet. (Of course, I've never taken classes...) ;-) > Hi. First of all, I'm not an amazing programmer. But, I do have large > goals, somtimes too large. There is an open source game, konquer, (it's > on the ubuntu repos.) that I would like to extend with python to include a > network based game. But, I only know how to do simple sockets Is > this too big a project for first year programmer? (I've been programing > for 3, but have taken classes only one year.)The program is like a board > game. You move your fleets to different planets, one at a time. The game > is written in C++(I think). > > Just as a preliminary thing, I will go through how I think it will work. > One computer in the network will be designated as the 'server' that > everyone will send information to. Each turn, four pieces of data will > have to be sent to the 'server' that I can think of right now.: 1. how > many fleets have left 2. from what planet 3. going to which planet > 4.taking how long to get there. From there, the server will then issue > those to each player, and tell which player is next, and wait for his > reply. > > I don't really know how to start, so I guess I will start here. > > I appreciate your reply. > _ > Need to know the score, the latest news, or you need your HotmailĀ®-get > your "fix". > http://www.msnmobilefix.com/Default.aspx > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Adding network play to an open source game.
Thanks for your advice. You're probably right, I do need to figure out sockets first... But it's a goal to work towards... I don't know if I would keep up computer programming if I didn't have a specific goal. A few things: I have the author's email of konquer (it was in the source). I don't think he's actively developing it, but once I get to a nice start, I could try a nice email to him about it. You're also right, I don't know C++, but would like to learn it. Anyone have any advice on good tutorials/books/examples of python network programming? I saw a cherryChat program that I can start to understand, anything else? > From: [EMAIL PROTECTED] > To: tutor@python.org > Date: Fri, 8 Feb 2008 22:26:12 -0500 > Subject: Re: [Tutor] Adding network play to an open source game. > > I wish to warn you that I've never done anything like this before, but I > have a couple of thoughts here. First thought is, network games tend to be > slow because sending state information to everyone with enough frames per > second to make it decent game play is a lot of information to send... So the > least information you have to send the better. Fortunately, now that I read > a little more closely... A board game is not going to be bad about this... > > Second thought is... start with simple sockets, work with the server model > and the clients, do not mess with the game at first. Get dummy data to > behave properly first before you ever try anything with the game itself. > > Third thought. C++ is a different language from python. This will further > intensify your trouble. In fact, depending on your knowledge of C++, this > could greatly intensify your trouble. You could have step two there going > just perfectly, but getting python and C++ to talk could throw you in loops. > > I would say that generally for a programmer of a year, this seems like a > very significant goal. Not only do you have to understand quite precisely > what the C++ program is doing, (difficult especially in a game, IMO), but > you have sockets to deal with, client, server, and just as difficult, > C++/Python interaction. Also, given that you didn't write konquer~ someone > else's code is harder to read than your own. Trust me. > > My suggestion is, if you are going to tackle this, very definitely take it > in very defined steps. Work on sockets here, then C++/Python here, etc. I > don't wish to discourage you, but I wouldn't try this yet. (Of course, I've > never taken classes...) ;-) > > >> Hi. First of all, I'm not an amazing programmer. But, I do have large >> goals, somtimes too large. There is an open source game, konquer, (it's >> on the ubuntu repos.) that I would like to extend with python to include a >> network based game. But, I only know how to do simple sockets Is >> this too big a project for first year programmer? (I've been programing >> for 3, but have taken classes only one year.)The program is like a board >> game. You move your fleets to different planets, one at a time. The game >> is written in C++(I think). >> >> Just as a preliminary thing, I will go through how I think it will work. >> One computer in the network will be designated as the 'server' that >> everyone will send information to. Each turn, four pieces of data will >> have to be sent to the 'server' that I can think of right now.: 1. how >> many fleets have left 2. from what planet 3. going to which planet >> 4.taking how long to get there. From there, the server will then issue >> those to each player, and tell which player is next, and wait for his >> reply. >> >> I don't really know how to start, so I guess I will start here. >> >> I appreciate your reply. >> _ >> Need to know the score, the latest news, or you need your HotmailĀ®-get >> your "fix". >> http://www.msnmobilefix.com/Default.aspx >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor _ Shed those extra pounds with MSN and The Biggest Loser! http://biggestloser.msn.com/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor