Page 1 of 1

Python

Posted: Sat Apr 26, 2003 11:52 pm
by Andrew_Baker
I've been studying the Python language lately. Basically, it operates as a wrapper for ANSI C on a number of different platforms, extensible to almost all commmonly used languages (and a few "weird" ones, too). I'm going to be doing some experimentation with templates in Python to emulate an "Adventure game interpreter". I was planning on doing something like this before... codenamed Simpleton... but that would have involved creating my own scripting language. I've been juggling Python and Pygame (the game library of modules for Python), and I've realized that it is powerful enough to create a modern adventure game.

Re:Python

Posted: Sun Apr 27, 2003 12:55 am
by Eero Ränik
Andrew_Baker wrote: I've been studying the Python language lately. Basically, it operates as a wrapper for ANSI C on a number of different platforms, extensible to almost all commmonly used languages (and a few "weird" ones, too). I'm going to be doing some experimentation with templates in Python to emulate an "Adventure game interpreter". I was planning on doing something like this before... codenamed Simpleton... but that would have involved creating my own scripting language. I've been juggling Python and Pygame (the game library of modules for Python), and I've realized that it is powerful enough to create a modern adventure game.
I know that Python is very powerful, but I don't want to study it... Maybe... Is there any good tutorials?
Anyway, if you want to make an adventure game engine, then go ahead... It is not so hard than most people would expect... ;)

Re:Python

Posted: Sun Apr 27, 2003 10:32 am
by jamescox3k
I like python because it can be integrated into your C/C++ apps. However it's not easy.

Re:Python

Posted: Sun Apr 27, 2003 2:56 pm
by SGreenslade
This thread title is misleading...I was expecting a topic about Monty Python or the actual reptile.

Re:Python

Posted: Sun Apr 27, 2003 5:48 pm
by AGI1122
SGreenslade wrote: This thread title is misleading...I was expecting a topic about Monty Python or the actual reptile.
Moved to a more appropriate board.

Re:Python

Posted: Sun Apr 27, 2003 11:32 pm
by sonneveld
Looked into pygame? Nat Budin's (worked on OpRecon) playing around with that too.

- Nick

Re:Python

Posted: Mon Apr 28, 2003 11:18 pm
by Andrew_Baker
Yeah, that's what I'll be using for the sprite, graphic, and audio controls. However, I'm having a hell of a time getting all of the dependencies set up on my box. However, right now I am focusing on the theory of it all, because I don't have a lot of time for practical application right now (Too busy with two jobs). Suffice it to say, though, I do have a number of ideas for the first game I'll want to make. One obvious one is a commercial sequel to Voodoo Girl, which I was originally going to code in Java.

However, before I even get into the making of an adventure game, I'm going to code an SDK to manage all of my game elements.

Re:Python

Posted: Tue Apr 29, 2003 7:38 am
by Eero Ränik
Is there any tutorials then? :D

Re:Python

Posted: Tue Apr 29, 2003 10:19 pm
by Andrew_Baker
Yes, on the Pygame website there are tutorials for USING the language but not properly installing it on your machine... *sigh*, I've been looking for some FAQS. However, this time, I'm in a situation where I'll be designing as much as possible first. I'm going to try to sketch a good graphical layout for a python-based adventure engine to post here.

Re:Python

Posted: Sun May 04, 2003 1:09 am
by Andrew_Baker
Hmmm... Python provides for everything I need for an AGI/SCI/SCUMM/etc. type framework. One thing that I'm a little bit insecure about is memory. Specifically, I could have rooms be imported as modules or classes. Either way, a module will be imported into run-time memory and a new namespace will be created (whether the objects are instantiated, destroyed or whatever). Apparently to me, this memory can't be deallocated, though. So my main concern is that a game with a significant number of "rooms" will eat up a bunch of memory. The only other option readily apparent is to embed a stack-based script into Python, but I'm using Python because I don't want to write my own scripting language. Anyone out there have any experience with Python who can sort me out here?

Words.tok equivalence

Posted: Tue May 06, 2003 1:27 am
by Andrew_Baker
To create the equivalent of a words.tok file in Python, you will need to use dictionaries. Dictionaries are the same as hash-tables in function, and use curly braces { } to encompass them. They are referenced by a key, which can be a number, character, or string. Dictionaries can also be nested, or in my case, a tuple could be nested in a string and referenced by an integer index.

EX.

words={'monkey':('gibbon','chimpanzee','capuchin')}

In this case, if you referenced the dictionary 'words' by the key 'monkey', you would get the tuple ('gibbon','chimpanzee','capuchin')}. You can then reference the tuple by integer (especially in a kind of loop).

Note... You can also use lists, which are dynamic, instead of tuples, which are static... this could be useful for players to define their own synonyms.

EX.

>>>print words['monkey'][0]

'gibbon'

Unfortunately, I don't know if there is a way to make a tuple or list a key for a predefined word.

EX.

>>> D={('if','and','but'):1}
>>> D['if']
Traceback (most recent call last):
File "<stdin>", line 1, in ?
KeyError: if

While I'm planning on making VG2 a non-text-parsed adventure, I could see great use in the dictionary built-in type for someone who wanted to do so within Python.

Re:Python

Posted: Wed Jun 04, 2003 2:44 pm
by Tux
I know that this board is about python, but I have some usable pure c++ libs. e.g.

int main()
{
Video video;
video.setmode();
//...Load pal and setup keyboard scanset
video.drawpixel(10,10,RED);
}

It actually is the Lib my OS uses. But if used to make a game, you could make a game that runs on Linux, Windows,Dos, and etc. The game is its own OS tho. It is easier to create a game that way FYI. But, the problem is you need to make your own plug in detection system.

Re:Python

Posted: Wed Jun 04, 2003 11:51 pm
by Andrew_Baker
When I release the game , I plan to do it commercially. Everything needed for the game will come "in the box". I'm not worried about the memory considerations, considering everyone has a ridiculous amount of hard drive space right now. I figure the extra memory consumption of providing all the necessary DLLs and stuff within the VG2 installation package will be worth more than forcing the user to hunt down a million different dependencies and install them all themselves.

My main concern is that each room will probably be a compiled Python module. When a module is called during run-time, all classes are read into memory. I need to figure out a reasonable way to benchmark this or properly deallocate memory so I can make sure that running VG2 isn't going to eat up all of their RAM.

I'm going to use SDL wrappers, most likely, to make my game. AGI runs fast, even though it's a little crude, so I figure the Python VM will be fast enough for an adventure game (although I'd be much more concerned about making something like an Abuse clone or something like that). However, I'm going to put in many more locations in VG2 than I did in VG:QotD. I know how to load/unload all of the necessary graphics and audio. My main concern is that I don't know much about the compiled bytecode. My reference/learning source deals mainly with trivial scripts and not full applications, so it doesn't offer any advice like this.

My question of the day is this: If any of y'all know about this kind of VM bytecode, how much ram would a common room module (assume at least twice the memory of an AGI "room") consume? Is this a trivial matter, or will I have to figure out how to deallocate module memory? I'm assuming a minimum of 256MB RAM.

Re:Python

Posted: Tue Jun 10, 2003 8:57 pm
by Tarison
This is bizarre. Aside from playing about with Qbasic and Pascal a long time ago, my start to game programming came with AGI. (The Lost Planet). In recent times, I've drifted away, touched on AGS, and lately (due to having to use it at work), begun looking at python.

While searching for scrolling info for pygame, I happened to stumble across Nat Budin's blog. Amidst thoughts of 'I wonder if...' in regard to the name, I did a search for python on these boards. Voila.

Anyhow my point.. I too have begun playing with Python/Pygame, though am firstly trying out a simple tile engine (which will be working a lot better once I set up Numeric). So I will be looking over here every now and then.


As for being able to help, I really can't. Ooops