Python Question


(CubeFan973) #1

I’m hoping to make a random level generating Python script. COuld somebody help, as I’ve never programmed anything and have no idea of how to do randomness?


(Schlops) #2

Grab yourself the API-Documentation over at http://www.python.org and take a look at the whrandom-module: random(), randint() or uniform is what your looking for.


(valarking) #3

http://216.40.249.192/mysmilies/cwm/cwm/cwm27.gif
http://www.gamers-forums.com/smilies/otn/realhappy/xxrotflmao.gif
http://65.68.63.156/mysmilies/contrib/dday/laugh.gifhttp://www.gamers-forums.com/smilies/ups/dvx_rune/lol.gifhttp://216.40.249.192/mysmilies/cwm/3dlil/laff.gif

ROTFLMAO

There is NO way you can just jump strait into Python and then have yourself a level generator. NO WAY. Take a look at the level generation code for NetHack. It isn’t pretty.
Do yourself a favor and go through Python books, and maybe a basic algorithms book.
For game development:


(Jamesk) #4

All paths to knowledge start with a single step towards the final goal.


(acasto) #5

All paths to knowledge start with a single step towards the final goal.[/quote]

Yes, but you must realize the point of this thread. It’s more or less to get someone to do the work for him. He must take the first step, but he hardly does.

COuld somebody help, as I’ve never programmed anything

I’m not saying that he couldn’t or that he won’t. He may very well surprise us all. And to Cubefan973, I don’t want to discourage you or anything, I would just like to see you at least start one of these things. You’ve talked about the movie thing, the anthology thing, and several other things I can not remember, and in all you ended up wanting people to do things for you. Now finishing something is different, we all have project we can’t and never will finish. If you came in here and said I wrote this (then showed it) and that you were having problems with it, then things would be a whole lot different.


(CubeFan973) #6

I’m attached to “Plotless Film,” AP1538, and this Python script idea. (BTW: The level generator is for Blender.) My problem isn’t a lack of motivation, it’s that I want to do all 3 at once. Impossible, even if I had 6 hands.

The idea is to make a tile-based (I think) level generator that adds everything from enemies to health packs to your starting point. The problem: I don’t know Python, though I’d like to learn it.


(valarking) #7

Let me put it this way. Learn Python. Study it. Know all of the syntax like the back of your hand. Only then, young jedi, will you be able to do this crap. Patience, young grasshopper.


(CubeFan973) #8

Unfortunately, my time is shrinking due to my obsessive “work” on “Plotless Film” and AP1538. I’d try, but the local library’s closed for repairs, and I’m not willing to buy a book about Python.

PS: Yay, the images are gone! Those were disgusting!


(meestaplu) #9

Each Python distro includes some really good documentation - and it’s well designed, so reading it on a computer monitor is not half bad.

I would recommend starting off by reading the tutorial section and taking a ton of notes on it. Then, once you have a basic idea of the syntax and general data types, you can take a look at the documentation on each of the libraries so you can learn how to do exactly what you need to do.

Don’t just try to learn the syntax of Python, though—make sure you learn the general computer science concepts behind everything. A lot of people in my AP Computer Science class don’t do that, so they cannot transfer any of their knowledge of Visual BASIC concepts into C++.

Good luck…
Matt


(haunt_house) #10

hi cube

If you want to learn python, let’s do it together.

HH


(theeth) #11

If you really want to learn Python, I suggest you start by the documentation at the Python site (http://www.python.org).

You could start with the links on the Python for Newbies page: http://www.python.org/doc/Newbies.html
Or start directly on the tutorial page: http://www.python.org/doc/current/tut/tut.html
For editing Python scripts, I suggest you use IDLE (useful GUI made in Python): A good starting guide for IDLE is this: http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html
And some Python humor for the breaks: http://www.python.org/doc/Humor.html

I hope that’s helpful.

Martin


(CubeFan973) #12

Okay, I’ve gotten a Python book for $15 at a bookstore, and I think it might help a little. The docs will help, too.

BTW: How do you do randomness in Python?


(haunt_house) #13

I ignite GOOGLE, I insert the words ‘PYTHON’ and ‘RANDOM’…

and then I use my ability to read in english.

Try it, it’s fun. :stuck_out_tongue:


(theeth) #14

even better. open up a “search file” kinda thingy and search in the python installation for a module with “random” in the file name. Then, open a Python console, import that module and print the docstrings like in the example below:


import whrandom
print whrandom.__doc__

Martin


(haunt_house) #15

don’t boast :stuck_out_tongue:


(valarking) #16

Ooooh, sombody got told. :wink:

Seriously, Cube, HH was just putting it nicely, but I’ll follow up on my tradition and spare you the smalltalk.

STFW
orrrr…, like theeth said…
RTFM


(SHABA1) #17

I too and trying to learn python, so can program the gameengine. I took my first programming couse 20+ year ago.(Basic on a tty line printer) But I have tried to keep up ever sense just by reading books on newer and more modern languages( C,Java,perl and now python) Trust me there is no magic bullet. You have to read and type and make mistakes. I am by no means and expert in any of these languages but I can seem to pick up the basics since I learned BASIC years ago.

On piece of advise no on is going to help you if they do not feel that you are TRYING to help yourself FIRST.

I read the tutorial at python.org and yes I found it confusing. Here is a reference for you that I find is a lot easier. It is online and in a downloadable and printable PDF if you want a hard copy.

http://greenteapress.com/thinkpython.html

It’s called Think like a Computer scientist-python. They also make on for Java

Good luck


(CubeFan973) #18

I am trying to help myself…

With a book called “Learning Python.” Unfortunately, it seems to be aimed torwards people who have learned programming languages before, which I haven’t done.

I should probably use that “Think Like A Computer Scientist” PDF, but I’m too lazy to click on the link to the PDF to print it out. It’d be nice if they made a printable HTML version.


(SHABA1) #19

All you have to do is go to the page. Point the mouse pointer over the link to the pdf and rightclick. Assuming you are using a windows system then click the menu choice ont he pop up window that say save target as. Chooe a directory to save the prf to then put it on your hard drive. The pdf will print out just as it is formated in the file. I know I did it.

Maybe you should start researching How to use the various parts of your OS rather then diving into python.


(Timonides) #20

I’m reading the: “Python 2.1 Bible” by D. Brueck and S. Tanner.

It’s a BIG book and it cost me around 40 EUR. But it’s really good and it doesn’t really assume that you have much previous programming experience…

But I must tell you, that in order to start writing serious programs, even with such an easy to learn language, you definetely need to start thinking like a Computer Scientist… Cause learning something is one thing and applying what you have learned is another…

I’d suggest, since you have no previous experience (as you told…), that maybe you should go to some school and take a course on programming, before starting any ambitious plans…

It would definetely teach you some good programming habbits and save you from frustrations…

Spyros.

P.S.: About randomness, if you are using Python 2.1, you should check the random module… The whrandom is now deprecated…