Python (civ4 scripting language) tutorial thread

Trip said:
Yes, classes are integral in learning how to program.

If you don't use classes, you might as well not program in this day and age. Everything is about OOB.

I think that's OOP. :)
 
Good news! A revised, corrected and improved version of lessons 1 through to 8 are all available on my website, www.sthurlow.com. Seeing that there is nothing else on the site (yet), the python tutorial is right on the main page. Have a look, and give your comments!
 
I'm a little late to the game, but this is a great thread, and gave me the push to go ahead and learn a little bit o' python.

I've made a little statistics program for the interpreter that will do basic statistics calculations (mean, median, variance, st dev). It is attached, just remove the .txt extention. I wanted to play with lists and get a feel for it, and math is always my "first program" rather than "Hello World" which I don't think I've ever, ever written in any language. :)

I tinker in C++ and Java quite a bit, so this is fun for me (isn't programming always fun? --Maybe only when you don't get paid for it, because then it is a program you want to write!). I travel a lot so I can't keep up with the lessons in a timely format, but I will definitely be working on this in the background.

I'm impressed with its expressivity and simplicity so far, though obviously I haven't done much with it.
 

Attachments

  • Statistics.py.txt
    3.4 KB · Views: 266
erislover - incredible! You've obviously had experience in other programming languages, haven't you?

I like python's simplicity that still retains functionality as well. Maybe that's why they picked it for civIV scripting, from game events to the AI.
 
Yeah, maybe "tinker" isn't the right word, but I'm not super hip to GUI stuff so it is hard to know what else to call it, and I haven't written any code complicated enough to require subclassing and so on (except where the API demands it e.g. Java threading), but I have been teaching myself C++/Java on and off for a few years now. Recently wrote a simple SQL interface for an Oracle database, am working on another more expressive one now for work.

For the BS I do in temporary excel files, like statistics calculations, Python seems much, much nicer for tinkering. Simple, and expressive. Can't beat that combination. Semantics seem more intuitive than something like VB, too, which I've never really got the hang of. Weak types are really cool for quick and dirty stuff, and I saw from reading the documentation that you can still get type info if necessary... man, that's just great. I'll work on the rest of your assignments later this week/weekend. I really appreciate the work you put into this, I tried teaching someone an intro to console programming in C++ and it surprised me how much work/thought went into a "simple" lesson.

Keep up the good work, and I hope others here are doing okay with it. :goodjob:
 
Finally had a chance to read through the lesson... very nice work GBM. :) It's a shame more people aren't following along, you're doing great work. I imagine that this will be more popular later when it gets closer to release. :D
 
This is a great thing you guys are doing here. It'll teach people (me included) how to mod CIV so we are ready for it.

Great stuff!
 
Great to hear good feedback! And it is still alive, I'm just giving a lot more time between lessons (and also a lot more research - trying to explain harder and harder things ever so simply requires you have everything perfectly clear yourself).

I won't be able to do much with XML until I am given further details to how civIV will implement it, but I am working on a multiplayer text adventure game that uses an IRC client as it's interface - interesting new ground here, considering my newbieness to Python. You guys will learn as I do, and pick up things that you will be able to do with civIV (automatic, ingame IRC message generator for demogames, anyone? Duplication of a game on another person's computer, while you play? Adjust tax rates, city build queues, etc, from a chatroom? The possibilities are endless...).

I just can't wait 'till we can start modding!
 
I've included your tutorials in the prerelease info so that people who go there can check out what you have as well, if for some reason they don't come to this thread by themselves.
 
Trip said:
Finally had a chance to read through the lesson... very nice work GBM. :) It's a shame more people aren't following along, you're doing great work. I imagine that this will be more popular later when it gets closer to release. :D
Just went through the whole thread, you'd make a fine teacher GBM. :b:
Dammit Trip, why didn't you tell me this thread existed btw.

GBM, you don't have to sign me up but I'll be monitoring this thread frequently. ( already in my bookmarks). :)
I'm fluent with VB.Net ( starting with C# soon and ASP next week), some knowledge of Java. ( html, blahblahblah... )
--

I do think you lost part of your audience - especially the "never did any programming before" club - when you introduced inheritance and pointers though.;)
Those concepts are IMO too advanced to really pick them up after just a couple of lessons. Still, those that persist will enjoy them later on. :)
 
I finished the Loops and Classes lessons finally! This is great GingerBread Man and will help plenty but this thread keeps falling back. You should contact a mod to sticky this thread so you don't lose it. :goodjob: :)
 
Afternoon. After lurking for many moons, I've decided to become a member, thanks largely to GB's excellent python tutorial. I programmed uh...damn, has it been that long ago? Not since the late seventies? Anyway, I did Fortran 77, BASIC, COBOL, PL/1, Assembler, RPG, and God knows what else. I've been looking for a reason to learn Python, besides sheer intellectual curiosity, and now I've found one. CIV.

Can anyone recommend a good book on beginning Python and an equally good book in learning XML? I might want to try my hand and exercise my poor neglected brain at doing a CIV mod. I've played Civ I, II, III, AC, and X-fire and enjoyed every one of them.

* silverjim *
 
@silverjim: The best book on Python I've found is 'Learning Python by Lutz & Ascher. Amazon.com link

As for XML, I've never really tried to find good books on it, as the Beginners Guide section on XML.org did well enough to get me into it. :)


Oh, and I'll join up too. I've been lurking for long enough already. Brilliant thread. :goodjob:
 
Thanks for the links, Isak. I'll toss the Python book into the shopping cart and investigate the hell out of the XSL site.

* silverjim *
 
Top Bottom