Re: [Tutor] Adding network play to an open source game.

2008-02-09 Thread Michael Langford
Your game is perfectly within reach of a novice programmer. Board
Games are often used as the final project for early courses at Georgia
Tech that many people take who aren't going to be programmers for a
living. You're also going to chop up some code you didn't write and
make it do something fundamentally different than what it does now if
you do this in python. While that is fine, it is not a small task, but
it does work well. It may be faster to implement this in C++ as you'd
be changing C++ code a lot to do this, but you're going to learn a lot
more (in a good way) if you do it in python and attach python to it


While you could figure out the generic sockets interface (it's not
that hard, but does have some novel concepts in it), you may do better
to learn to use a remote procedure call (RPC) mechanism and code your
game on top of that. RPC looks like a normal call when you do it.

The RPC mechanism I've used a lot in python is XMLRPC. Don't worry,
you don't have to know anything about XML to use it, it all happens
magically under the hood. XMLRPC shines most when few pieces of
information are going across. Some references are:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81549
and this part of the larger article:
http://www.adobe.com/devnet/flex/articles/flex_ui_02.html


 A lot of games have this pattern of low-level languages for some code
plus high-level language for everything else. Civ4 used python for the
higher level language. Many games use lua. Most of EA games use an
Actionscript front end and a C/C++ backend. There are two ways to do
the game. Now there are two methods of combining python with the game:

1. You can turn the modules of the game into python modules, then
rewrite the main loop in python. This is essentially putting the game
into python.
2. You can embed python into the game in one place. The game will
still fundamentally run as it does now, but will have an added
scriptable part. This is essentially putting python into the game.

By doing approach #1, you may make future additions to the game a lot
easier. To do this method, you're going to generate wrappers around
the modules. You do that with something called SWIG.

That is going to hurt some. But then again, I think it is time the
tutor list sees some work with SWIG on here. SWIG is a toolkit that
generates wrappers on C/C++ code so languages such as Ruby, Perl and
Python can call it.

SWIG is not easy. It is difficult in same way that plastering a wall
is, lots of little problems, not in the big, complex concepts way that
integral calculus is. You will make SWIG do what you want it to if you
keep trying.
Here is the main page:
http://www.swig.org/

Here is the tutorial:
http://www.swig.org/papers/PyTutorial98/PyTutorial98.pdf

If you go that approach, when/if you get stuck, let us know. I've done
SWIG work several times. Someone else here may know of another
solution along that line


Approach 2 puts a python interpreter into the C/C++ program. It is
called embedding.

Guido's text on doing so is more than sufficient for most people.
http://www.python.org/doc/current/ext/embedding.html

While this will be much easier for you to do (especially if you start
extremely simply with something that looks like the very simple
example), you will fundamentally be leaving the structure of the game
a C/C++ game.

This will mean if you're going to change other parts of it, you will
have to do so in those languages, or you will have to finagle ways to
use the embedded python instance more. You're going to learn a lot
more doing approach 1 in my opinion. You'll be able to change the game
more ways easily, but approach 2 will get what you're trying to do
done quickest, and should be the way you do this if you do not intend
in changing the game any more than your networking additions. Approach
2 also requires much less rejiggering of the internals of the C/C++
program.

 --Michael

On Feb 8, 2008 11:21 PM, Timothy Sikes [EMAIL PROTECTED] wrote:


 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

Re: [Tutor] Adding network play to an open source game.

2008-02-09 Thread Kent Johnson
Timothy Sikes wrote:

 Anyone have any advice on good tutorials/books/examples of python network 
 programming?

The book Foundations of Python Network Programming ;-) is pretty good.
http://www.apress.com/book/view/9781590593714

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Adding network play to an open source game.

2008-02-09 Thread Alan Gauld

Kent Johnson [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Timothy Sikes wrote:

 Anyone have any advice on good tutorials/books/examples of python 
 network programming?

 The book Foundations of Python Network Programming ;-) is pretty 
 good.
 http://www.apress.com/book/view/9781590593714

Seconded! This is as near as I've seen to the classic Stephens'
books on networking but in Python.

Its never let me down yet.

Alan G. 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Adding network play to an open source game.

2008-02-08 Thread Timothy Sikes

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.

2008-02-08 Thread Tiger12506
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.

2008-02-08 Thread Timothy Sikes


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