Python (civ4 scripting language) tutorial thread

Gingerbread Man

Dark Magus
Joined
Jun 9, 2002
Messages
2,078
Location
Ooorstrailier!
Go to my python tutorial website for updated versions of all the lessons posted in this thread. The site also contains some other things that may be useful for your Civ Python modding adventures, so feel free to have a look, and ask questions in this thread if they arise.

Lesson Index:
(Opens in a new window. Post number Next to link)
Lesson 1 - What is Python, and how do I install it? Post 25
Lesson 2 - One-liners - very simple 'programs' Post 43
Lesson 3 - Programs in a file, and variables Post 70
Lesson 4 - Loops, Loops, Loops, Loops, Loops, Loops... Post 85
Lesson 5 - Oh, how functional! Post 105
Lesson 6 - Tuples, Lists, and Dictionaries Post 120
Lesson 7 - another loop, and a simple game Post 134
Lesson 8 - Let the classes begin! Post 153
Lesson 9 - 'Borrowing Other People's Stuff (with Modules) Post 187
Lesson 10 - File I/O Post 189
Lesson 11 - Exception Handling: dealing with the dumb Post 197

Firaxis made a daring and interesting move when they announced that much of the modding in cIV will be in Python and XML. Python is a well established language that is well known among server-side scripting and open-source communities. XML is a relatively new markup language, often mistaken for something like HTML, but actually has an entirely different purpose.

with Firaxis making this move, the civ modding community has an unprecidented opportunity - they can learn the modding language before the game evn comes out!

So, I'm thinking, with at least a year until cIV comes out, we should start learning python an XML now! By learning python, and focusing on the logic aspects of it that will be used in the AI, we may only need a slight learning curve to adapt it to cIV.

Here, I am periodically posting very easy, interactive, tutorials in python. Anybody can join, from a person with no programming experience, to a full-blown professional developer. Python and XML are both free, and easy to obtain.

And remember - This is a living tutorial, not some lifeless, static text book. Ask questions, share thoughts, grow your knowledge!
 
uhh, well i guess, i don't know, i;ll try, but i'll probably give uo, i know a bit of HTML abd that's it
 
Mr. Will - Dab of HTML, Dab of BASIC :lol: , Attempted Visual Basic
 
Extensive professional Python programming as well as use of XML for data storage. I don't know how much I'll be able to participate though...

To get started on this go to www.python.org for details on Python. If you know nothing about Python start here http://www.python.org/topics/learn/ This has links to excellent tutorials for all levels of programmers (including those who have never programmed before).

Go to http://www.python.org/2.3.4/ to get the latest version of Python. You may also want to get the win32all package for it. This is a Windows specific IDE that is very good.
 
Alrighty!
Thanks warpstorm for the links. I found that site, though didn't know if it was good or not.

As for your participation, do as much as is convenient for you. I was hoping for somebody with professional skills, to help us along when we get stumped. Just your prescence should make it easier.
 
warpstorm said:
Extensive professional Python programming as well as use of XML for data storage. I don't know how much I'll be able to participate though...
Be able to or want to? ;) :)

I suppose I'll join up. I know VB, C++, some C, some XML and some Python (I don't count HTML as a real language ;)).
 
Welcome aboard, Trip! It's great to have people with previous knowledge help.

When this starts, should we move it to the Computer Talk forum, or leave it here? I figure seeing it will be civ-focused, it should stay, but that will be a decision for the mods.
 
Oh, I know Java also. Almost forgot about that. That and I know HTML and BASIC quite well, if you want a complete list of my knowledge.
 
By the way, I think this is a really good idea. Having a communal learning effort is a really good idea, it'll help me as I continue to learn Python and how it is similar and differs from the other languages I know. ;)
 
Yeah, this will also be really good for my software classes that I am starting in school next year. They dont actually teach you a language - you have to pick one, learn it, and apply the theory you learn in class to a program you make. I figured I'd learn python with you guys who will probably be interested in learning it for cIV, and kill two birds with one stone :D
 
I want to join
I have 3 years expreience in C++ and VB and Blitz. I know some java and html.
I dont know what xml or python is though.
 
There's a FAQ here, but it mostly describes XML's application in an internet-based environment.

http://www.ucc.ie/xml/

For CIV it will be used to store variables of various sorts that modders can change in order to create mods/scenarios.
 
JAVA, education.
Pascal, education (yak! :thumbdown )
C, I used to program my college student exercises.
C++, well know the syntax.
Perl, programmed some part for a system that track positions with GPS.
XML, used it in above system.
HTML, I know how to echo it from a php file. :blush:
JAVASCRIPT, JSCRIPT ASP.
PHP, using it right now.

Oh and I love to discuss AI architecture and design :)

Havent got much time to teach.. I am a bad teacher anyway ;)

Now where is the thread where we start designing the AI?? :goodjob:
 
Welcome MMAfan!

I'll be starting the thread where we learn Python in about 24hrs - we need to give other people the opportunity to join.

We'll start programming AIs as soon as we are fluent enough in Python. I think we might make a very simple game (no more complex than pong) and make an AI for that as a start. Once we get that, we'll move up to another level. But that will be a while - some of us haven't learnt python at all yet.
 
I'll join up. Make a nice tutorial thread, and I'll sticky it.
 
Top Bottom