Unable to avoid the networking issue any longer, I have made a couple of forays into how to add networking to “Pitcher’s Duel”. One way or another, Twisted will be involved, as they have a very reputable code base, and using the standard lib modules does not seem to have any relative merits. They all have the same major limitations.

The principle limitation is that the network ‘library/engine/framework’ wants to own the main loop. That is fine for a server, it is a PITA for other sorts of software. I wrote a post on the pygame mailing list this morning summarizing the approaches to networking that I have identified, and may copy that post into the blog.

For now, I wish to describe one architecture for accomodating Twisted’s ownership of the main loop. Since the reactor, once started, never returns, the game logic has to be managed via callbacks from the reactor. Game state must be maintained in class variables, object instance variables, global variables, or generator local variables. Generators provide a relatively graceful way to code the ‘main’ function, where game state for the whole game is maintained in locals.
(more…)

Leo , the ‘literate editer / outliner’, has been around for years, and is up to version 4 something.

Googleing ‘python Leo’ gets scads and scads of listings, but not much diversity of source. 95% of the Google finds are by Ed Ream, the author of Leo. Most of these are mailing list pages. I have to give the guy credit for being persistant at promoting his product, but where are the users? Where are other people offering cookbook items on how to use it usefully, or even people giving it ’signature-line’ promotion?

I have installed it, more than once, but each time had difficulty getting traction. The benefit to me that justifies the learning curve is not apparent. Just the fact that you have to ‘untangle’ the document to get a source file that python can run is a deterrent. A Leo that reads and writes plain text files implicitly, and keeps its organizational stubs in another file would be more attractive.

For my recent web programming work, I was also looking at web application toolkits.  The big names, like Django, Turbogears, and Pylons, seemed like quite a commitment. They have per-site configuration tools, and a whole directory structure preconfigured.

Web.py looked interesting, but it still looked too broad, including database access and templating.  I’d rather not start a project by having to disassemble my toolkit to remove parts I don’t need. 

I settled on Colubrid as having the right amount of sophistication for my needs.  It is a WSGI application builder, putting a nice usability veneer on WSGI, without going so far as to suggest templating or database selection.   It includes several different Application base classes, and each handles the fundamentals of making input data available in a request object, and returning the output appropriately formatted for the WSGI handler.   It handles forms and file uploads with grace.

See it at:  Pocoo

I’ve had opportunity to do some web programming in Python recently, and experimented with a few python templating libraries, and settled on Twiddler.   It is a DOM type library, which reads an html/xml page into a tree-data-structure, allows manipulation of that tree in Python, and then re-renders the modified tree back into html or xml.

Your template file can be plain looking html, with id tags for the elements that matter, and the script can copy, fill, replicate, or delete those elements by their ids. 

The only documentation available was a newsgroup email summary, and the documentation in the archive.  Now, there is a jottit page at ‘http://twiddler.jottit.com’ with the documentation files added.  I hope to add more pages as I learn more.  I would like to see this library be more widely known and used.

The batter and the pitcher demos have been improved, again, and released.  This time they are both released in the same file. 

 pduel_setup.0.8.1.exe This release is a Windows self-installer, which installs both demos, and includes an uninstaller.

http://downloads.sourceforge.net/pduel/pduel_setup.0.8.1.exe?modtime=1194898820&big_mirror=0

Improvements to the batter include:

  • Bat magnetism, pulls the bat closer to the ‘ideal’ contact position, than your input would have accomplished.  This means more contact with the ball, and more hits.
  • Improvements to the swing timing, so that hits are possible to all parts of the field.
  • A GUI that supports batter-position adjustments, as well as replay and ‘nearest-contact’ inspection.

Improvements to the pitching demo include:

  • A GUI that allows selecting the level of play (MLB, College, HS), as well as the style, intensity, and location of the pitch;  also allows for replays and strike-zone path inspection.
  • Multiple different pitchers, with different arm motions such as overhead and sidearm.
  • Three different pitches, fastball, curveball, slider.

 This game is designed to be a ‘twitch’ skill game, minimizing the influence of random chance in the outcome of each action.  The batters stroke is entirey consequent to how the player ‘aims’, with no random component whatsoever.  The pitcher’s pitch placement interface jitters or flutters, adding some ‘noise’ to the location.  However, at the moment the mouse button is clicked, the pointer points precisely at the pitch destination, so the precision of placement is dependent on your reflexes.

Michael Yon : Online Magazine

Mike Yon reports from Iraq, traveling with US Military personnel.   This blog is apparently his sole publication.  If you are interested in the war (and you should be), take a look.

Google Docs

 For a while, I used Google Docs to keep my Russian study materials organized.  I would upload the documents and tag them with keywords like ‘verbs of motion’ or ‘genetive case’.   Then when I was struggling with putting a noun in genetive case, I could (with one click) pull up all the study materials covering genetive case.   It was very handy.

Unfortunately, during the month of August, Google Docs just spontaneously dropped all my labels.  The labels had survived a previous interface change that converted them to folders, but in August they just disappeared.  An inquiry in to Google technical support got an evasive response, and searching online yielded no insight into any backups or backup methodology.

I am not terribly inclined to re-enter all my labels, without the ability to back them up somehow, and knowing Google Inc will not assist with future problems…, and I recommend you, too, not use Google Docs for anything durable.

I might still use it for a weeks collaborative effort, where the benefit of shared documents outweighs the loss-risk.

Buyer beware.

 David

Good things happened this weekend!

Firstly, the Philadelphia Phillies (the local team) qualified for the playoffs by winning the NL East Division, and qualified without the one game tie-breaker. This team does not have the best pitching staff in the league, but complemented by their extraordinary offense, the team is good enough to win the World Series.

Secondly, another major milestone was reached in the development of Pitcher’s Duel. The pitching demo was rereleased. A prior release (in 2005 !) was just an animation demonstration, and did not have an interface to speak of. This release has a GUI and the ability to choose and throw pitches, some retrospection features, and is better looking.

The batter demo is almost done; in fact it was done, but I somehow overlooked releasing it, and now it needs a little sprucing up to match the pitcher demo.   There were a few releases months ago, but without the GUI and some features designed to aid hitting.  This week, I will get it fixed up, and then I will release it as well. I hope to get some good feedback on each, and I may well release an upgrade or two for each, to test any improvements we come up with.

Those are the two largest components of the game. After getting the batter demo online, I will be working on the network library (I have discussed various considerations on this blog before), and then assemble the three components into a playable inter-player game.

Anyway, enough chicken counting….

The demo (version 0.3) is at:

http://sourceforge.net/project/showfiles.php?group_id=110483&package_id=119360

Some description and background is at http://pitchersduel.python-hosting.com .

 

The demo is available as a self-contained Windows installer, and as a source zip.

The source zip needs pygame, pyopengl, and ocemp gui 0.1x preinstalled.

 

If you are a baseball fan, or a sports-game fan, give it a try.

 

DavidScreenshot

Greg Ewing has released his GUI for Pygame, under the name ‘Albow’.

It includes a demo, which shows it off quite well.  It is an attractive GUI package.

I set out to add it to my comparative review of pygame GUIs, but was disappointed that there was no readily apparent way to integrate it into a foreign main loop.   The documentation describes using it as the event loop.   I spent a few minutes looking at the RootWidget run method, thinking I might subclass a ‘callable’ root widget, but backed off from the complexity.

So I am not providing you a demo, but since I spent a few minutes looking it over, I will share my impressions with you.

The code is rather scant on docstrings, but the included html documentation seems complete and is clear.   Hopefully, he will put the documentation online somewhere where the curious can preview it.

The GUI in the demo is rather attractive, and has a theming system where you can change the look-and-feel to suit your game.

The range of input widgets is rather limited, with no checkbox, radio button or slider widget; it does have a set of input boxes, text buttons and image buttons. There are a few high-level widgets as well, including a file dialog, grid and palette widgets.

If your game can accomodate the GUI owning the main loop, give this kit a look.

http://www.cosc.canterbury.ac.nz/greg.ewing/python/Albow/

Lamina is a tool to facilitate displaying SDL raster displays in OpenGL displays.

A Lamina object (there are a couple of different flavors… read the docstrings) has a surface attribute, and a display method.  Write to the surface attribute using any old pygame draw routine, or pass the surface attribute to your GUI library, refresh() it, and then call the display method from your OpenGL display code.

This version uses partial texture updates, only updating the areas within a ‘dirty rectangle’ list.   Pygame sprite functionality and GUIs return ‘dirty rectangle’ lists as part of their functionality.  These partial updates are faster than complete regenerations, and the demo folder includes a comparitive timing script.

This release also adds a demo (pyg_lam.py) with no ‘extra’ dependencies, no dependencies beyond python standard dist, pyopengl, and pygame.  You can try it out without installing a  GUI.

 http://cheeseshop.python.org/pypi/Lamina/0.2

Developed and tested with Python 2.4, Pygame 1.7, and PyOpenGL 2.0

« Previous PageNext Page »