Python rpg adivce? - python

I started coding an RPG engine in python and I want it to be very scripted(buffs, events). I am experimenting with events and hooking. I would appreciate if you could tell me some matured opensource projects(so i can inspect the code) to learn from. Not necessarily python, but it would be ideal.
Thanks in advance.

As Daenyth suggested, pygame is a great place to start. There are plenty of projects linked to on their page.
The other library that is quite lovely for this type of thing is Panda3D. Though I haven't yet used it, the library comes with samples, and it looks like there is a list of projects using it somewhere.
Have fun.

You might have a look at pygame, it's pretty common for this sort of thing.

Related

What is the best way to learn a framework / module in python?

Hey I am an Intermediate in python and I'm pretty comfortable with tackling any problem with python. But, I don't know what's the best way to learn how to use python modules or frameworks, like, PyGame, DJango, Flask, etc...
Can someone please suggest a way of learning a module quickly and efficiently.
I always found that the best way to learn a framework is by, well, using it. I know that's the most basic answer you can get, but getting stuck and reading documentation is the best way to learn something.
I also sometimes find myself (ctrl|command) + Left Mouse Button clicking through the source code of a library in VS Code just to get myself familiar with the library and how it's built. Also, calling dir(module) also gives some useful information about the module such as attributes and methods.

AI and Design of an El-fish like simulator environment?

first post here on stack overflow, hoping to get some advice on how to construct a simulation program akin to the 1993 maxis simulator known as El-Fish wiki here , Also, game info here .
Are there known "Simulation system" algorithm groups that can function and create real life interaction etc... e.g. the visualization known as 'flocking' ? Or, is there an open-source code base to study off of already in construction?
Programming wise, would this also be able to be easily done in a purely functional language? if done in an OOP way, i was thinking of prototyping it in python.
Anyways thanks for any direction in pointing me towards a good starting place. I hope to build a graphical view of an idea/data world. It will be hopefully controlled by underlying simulation AI(heuristics maybe?)
In terms of simulation systems, I recommend you search for "agent-based modeling" software. There are a lot of free toolkits available. The two I like the most are NetLogo and Repast.
Also, it looks like you are implementing a "genetic algorithm". There are many good books and pages on that topic.
Python is good, but so are many other languages.
Most of your time will be spent doing the graphics: animating the fish so they look realistic. Unless you can find a free fish-animation-library.
I recommend you try my own GarlicSim framework. It's written in Python and you'll be writing your specific simulation in Python.
It can definitely handle the kind of simulation you want. There are tutorials available which will teach you the basics of GarlicSim in 30 minutes. I'll be happy to help you build your simulation package, just say hello on the mailing list and I'll guide you from there.
I'm not sure about "real life", but there is a flocking algorithm called boids that might be a good example to start from. There are a couple python versions of it as well. There's one that is an example in the owyl project on google code.

Interpreter in Python: Making your own programming language?

Remember, this is using python.
Well, I was fiddling around with an app I made called Pyline, today. It is a command line-like interface, with some cool features. However, I had an idea while making it: Since its like a "OS", wont it have its own language?
Well, I have seen some articles online on how to make a interpreter, and parser, and compiler, but it wasn't really readable for me. All I saw was a crapload of code. I am one of those guys who need comments or a readme or SOME form or communication towards the user without the code itself, so I think that Stack Overflow would be great for a teenager like me. Can I get some help?
You need some grounding first in order to actually create a programming language.
I strongly suggest picking up a copy of Programming Language Pragmatics, which is quite readable (much more so than the Dragon book) and suitable for self study.
Once you are ready to start messing with parsers, ANTLR is the "gold" standard for parser generators in terms of usability (though flex+bison/yacc are quite capable).
I just came by Xtext, a language development framework. Perhaps that's something you might want to take a look at.
Considering Python you might find it instructive to implement a version of Logo. If you want, you can skip the parsing/lexing stage for now and come up with a object oriented version first to get you going if your OOP skills are up to it. Later on you can hook it up with some graphics library to actually draw something.
In addition to Logo you might want to check out L-systems. See particularly The Algorithmic Beauty of Plants for inspiration.
Like theatrus, I'd suggest starting with a good book on the subject. I can definitely recommend Language Implementation Patterns by Terence Parr (the man behind ANTLR, a common parser generator).
See Peter Norvig's Scheme interpreter in 2 pages of Python with plenty of explanation. There's also a fancier version linked from there, worth reading once you've grokked the simpler one.

How do I get an overview and a methodology for programming in Python

I've started to learn Python and programming from scratch. I have not programmed before so it's a new experience. I do seem to grasp most of the concepts, from variables to definitions and modules. I still need to learn a lot more about what the different libraries and modules do and also I lack knowledge on OOP and classes in Python.
I see people who just program in Python like that's all they have ever done and I am still just coming to grips with it.
Is there a way, some tools, a logical methodology that would give me an overview or a good hold of how to handle programming problems ?
For instance, I'm trying to create a parser which we need at the office . I also need to create a spider that would collect links from various websites.
Is there a formidable way of studying the various modules to see what is needed ? Or is it just nose to the grind stone and understand what the documentation says ?
Sorry for the lengthy question..
The MIT Intro to Computer Science course on the MIT OpenCourseWare website was taught using Python. There are 24 lectures available as videos that you can watch for free.
It's kind of academic to be sure, but it would give you a very solid foundation to start from.
Start working your way through the Essential Python Reading List, which has articles on how to code in Python and how to do it well.
If you like a more academical approach try Learning Python from Mark Lutz.
For the use of standard libraries, the official docs are very good. More hands on descriptions can also be found in PYMOTW from Doug Hellmann
It might be useful to get some information on Object Oriented programming (just what is the whole class thing about, and how do you tell if your classes are good/poor/indifferent). Mark Lutz' book Learning Python has an entire Part (several chapters) on OO. If this stuff is new to you, it might be helpful to take a look. Two other books I have found quite useful: The Python Cookbook (Alex Martelli, a prolific contributor here), and the Python Essential Reference (David Beazley).
Just do your project, learning what you need to along the way. By the time you do that a couple times, you'll "get" it. And you'll only improve from there.
You can also read other peoples' code: download X that looks interesting and read through the code to understand how it works.
Those two tips will help you learn any language. Aside from that, Dive Into Python is a great resource for learning a lot about Python.

Python programming general questions

I heard that Python is easy and powerful, but I don't know if I'm on the right track to learn it. I learn from online tutorials, I know basic maths calculation and printing strings, but how long will it take to develop something useful? I don't really know the exact uses of Python, though.
I'm not exactly sure what you're looking for, but I think one or more of the following may be the next step you're looking for.
Perhaps you would like to use a variety of different protocols for a networking program, you could check out Twisted.
Or perhaps if you would like to make a web application or blog you can check out Django.
Or perhaps you would like to make a GUI application, you could take a look at TkInter.
Or perhaps you would like to get into game programming, you could take a look at Pygame.
Or perhaps you would like to ... you can take a look at the Python Package Index.
How long will it take? This depends on your programming background in general. The best way is simply to jump into the topic you're interested in and start on a mini project.
Python is a general purpose language. You can use it to make a lot of different things, but it's best suited at stuff that doesn't require a lot of speed, since the high level features have a performance cost.
It's hard to tell how long it will take you to develop something useful. The other day I made a script to help on a small computer administration thing. You could do that with a week or two of experience (or maybe less), depending on your previous programming knowledge and the amount of time you put into studying. However, if you want to make something bigger (maybe an audio player, an IM client, mid-sized stuff like that), you probably need some weeks or months of practice. It depends a lot on the time and energy you invest in programming.
I'd suggest to follow either the official tutorial or Dive Into Python.
In general, it depends on you. Python can be used for simple or complex stuff, and for many different applications. It depends on what you want.
Have a look at Mark Pilgrim's freely available book called Dive Into Python. I think it's a better choice to start with than online tutorials. The best way to learn a language is to start to work on a project. As I read this book, I started to implement a simple image viewer. As I advanced with the book, I could refine the project progressively. Invent something that is interesting to you.
I also suggest you taking notes when you learn a programming language. When you learn something that can be useful later, make some notes with a simple example, e.g. how to read a text file line by line, convert int to str, convert str to int, basic list operations, etc. Later on you can use these building blocks in a larger project.
Like every other programming language In order to learn Python you need to write a program with it.
Find a pet project and use python to code it. I also recommend Dive into python" (like anyone else that answered your question).
A few months ago I've decided to learn IronPython (.NET implementation of python), I'vve started by reading "Dive into python" and a few tutorials and then I've started coding a simple board game using IronPython (you can read about it in my blog).
In order to learn a new programming language you need to use it and then you'll know how and where to use it.
The best way to learn how to do something useful is come up with something useful you want to do. Make sure it's not way out of your league, then do research to accomplish it. That's how a lot of programmers learn languages.
What other programming background do you have? What programming interests do you have -- web apps, numerical / scientific computations, games, ...? Python is good at many different things, for both beginners and experienced programmers, but the most fruitful approach(es) to it do depend on what you already know, and what really interests you!-)
Bram who invented bittorrent with python says python is good for writing protocols in addition to aforementioned webapps, games and general purpose. Compared to Java python solves same problem in less code and less ways in longer development and VM time where Java has more ways solve same problem in more code and faster VM and faster development time.
Making a comparison between Python, and other languages would not help, as there is always somebody who would find a reason to prefer one language instead of another.
If you want a scripting language that is powerful, but that it is easier to read than perl, that doesn't have a curly bracket syntax, and that allows you to learn something about object oriented programming, then Python is the language for you.

Categories