Python (civ4 scripting language) tutorial thread

I'll join. Maybe Friaxis could provide some details of the API as well (I think its called API... I'm just a computer nerd wannabe)

Experience: Some HTML, C++, Java. I'm not very fluent in any of them however
 
Let's see, I'll join up...I have no experience whatsoever.
 
yay, I am on the team, I have cable so I can participate every day ;)

Blitz is a programming language meant for making games. It is one of the best languages if you only want to make games (meaning dont ever want to get a job in programming, or code an operating system)
www.blitzbasic.com
 
Welcome CT, croxis, and bob rulz!

I'll post the first lesson in a few hours. And that doesn't mean that people can stop joining.

Also, I'll be tracking people's progress. At the start of each new lesson, I will post a list showing each person's progress in the lesson. That way, we'll stop some people getting left behind. You can choose to take the lesson, skip it, or do it later. I will adjust the list accordingly. Notify me if you are stuck at a certain point, too busy, or unable to complete the lesson. As a general rule, we'll wait for the people who are stuck at some point, and continue when they have somewhat grasped the idea (again, a general rule. NOT STRICTLY HELD BY!) I will then post it as:
Code:
Name        Progress
Person A    [b]WAITING[/b]
Person B    [COLOR=Blue]IN PROGRESS[/COLOR]
Person C    [COLOR=Yellow]SKIPPING[/COLOR]
Person D    [COLOR=Purple]COMPLETING LATER[/COLOR]
Person E    [COLOR=Red]STUCK[/COLOR]
Person F    [COLOR=Green]COMPLETED[/COLOR]
Links to all lessons will be at the top.

Wait a few hours, and we're ready to go!
 
LESSON 1:
What is python, and how to install it.

What is Python?
If you don't understand this, don't worry. Just skip it and move on.
Python is an interpreted programming language.
For those who don't know, a programming language is what you write down to tell a computer what to do.
However, the computer doesn't read the language directly - there are hundreds of programming languages, and it couldn't understand them all. So, when someone writes a program, they will write it in their language of choice, and then compile it - that is, turn it in to lots of 0s and 1s, that the computer can easily and quickly understand. A windows program that you buy is already compiled for windows - if you opened the program file up, you'd just get a mass of weird characters and rectangles. Give it a go - find a small windows program, and open it up in notepad or wordpad. See what garbled mess you get.

But that windows program is compiled for windows - no other machine can run that program, unless it has windows. What Python is, is a language which is never actually compiled in full - instead, an interpreter turns each line of code into 0s and 1s that your computer can understand this. And it is done on the fly - it compiles the bits of the program you are using as you are using them. If you were to quit the program and come back another day, it would compile the bits you are using, as you are using them, again. Seems a waste of time? Maybe, but the fact is that when you come back another day, you might be using a Windows instead of a Mac. You might send the program to a friend, who uses another type of computer. Or you might post your program on the internet, where everyone using all different types of systems might download it. That is the wonder of an interpreted programming language - it is like a language that EVERYONE can understand.

So why will cIV use Python?
Remember that garbled mess that you got when opening a program in notepad? Not much use to anyone, apart from the computer. And there is no reliable (or legal) way of turning that program back in to a programming language that you or I could understand.
The same is with Civ3 AI - it is compiled into a garbled mess. Nobody can understand it, and most of all, nobody can change it. Only Firaxis can change the AI, and they cant share the logic behind it with anyone.
With cIV, they decided to change that - they would leave the AI uncompiled in the language of Python, and have it compiled on-the-fly by an interpreter. This is so that Joe modder can look at the AI and change it, yet when it is neede to be used, the python interpreter turns it into 0s and 1s for your computer to understand. And it isn't permanently compiled into a garbled mess - you are still left with python code, that you can read, understand, and MODIFY!!!!!

How do you install Python?
First download Python-2.3.4.exe by following this link.
DAILUP USER'S WARNING - THIS FILE IS 9.4MB!
If you aren't using windows, tell me and I'll post instructions for Linux, or I'll google for Mac information.

Run the file you just downloaded, and follow the prompts.
(TODO - Details on the prompts)

OK! Hopefully now everything is good!

Now, to test if that just worked, type this in your DOS window:
Code:
python -V
Remember to use a CAPITAL V. If everything is good, you should see:
Code:
Python 2.3.4
If you forgot a CAPITAL V, you will accidently load python in verbose mode. Give it a go, see what happens. Just press CTRL-D to quit, or type 'quit' for quit instructions.

Good work! Lesson 1 over! Next lesson, we learn our way around Python Interactive Mode, and write simple one-line pieces of code. I'll also have a lesson plan drawn up by then, so you can see where you are going. If any of our more experienced members have suggestions for the lesson plan, tell me!

Thanks to all, Gingerbread Man.
 
Interesting, sign me up. I'm not sure how much I can participate though.
I use c/c++ on a regular basis and I have som knowledge in assambler as well.

And I belive I have completed the first lesson :) (unless I missed something :blush: ).
 
Welcome aboard Harald!

I'll credit you as completed lesson 1 right away.

I'll remain as in progress until everyone is happy with how they've done in the lesson.
 
Downloaded it, not yet installed. Am constantly coding php/sql with some short breaks here on this forum to keep my head from exploding. :crazyeye: Dont even have the nights off... :(

I will probably install it after a coming backup (yes i am paranoid!)

I have 1 suggestion... Not with the python tutorial but another tutorial..
We should also gather information (and a tutorial if possible) of the abstract aspects of AI design. Not thing like A* pathfinding, since this stuff will be either hardcoded or predelevered by firaxis so anyone can use it without trouble. No, we have to get familiar with the higher level stuff of AI of strategy games.

It is a pity that there are no examples. to my knowledge no one, ever bothered to make a good AI. So:...

1. we cant copy anything
2. most stuff is theoretical
3. we will have to figure things out ourselves

back to work... :coffee:
 
I dont know what any other "dos window" is besides command prompt.
I had to open command prompt
type "cd\"
type "cd python23"
type "python -V"
Then I did it.
 
done (well downloading, but checking for version shouldn't be too hard )

Coorae: Command Prompt is XPs version of a dos prompt. Also to get it to work at any directory you are going to have to set the system variable, but I am not sure how to do this for python.
 
Gingerbread Man said:
Welcome MMAfan!
I think we might make a very simple game (no more complex than pong) and make an AI for that as a start.

To correlate to CIV, maybe a good example problem would be AI for something like RISK on a basic grid map.
 
I answered to the first post and it turned up to be off topic with the rest of thred so I am editing my post away.

Thanks for "Lesson 1", I have learnt something. I am a programmer in an interpreter language (Stata) and I did not know what an interpreter language was.

I won't join the course, but I still think it is a great idea :)
 
MMAfan said:
I have 1 suggestion... Not with the python tutorial but another tutorial..
We should also gather information (and a tutorial if possible) of the abstract aspects of AI design. Not thing like A* pathfinding, since this stuff will be either hardcoded or predelevered by firaxis so anyone can use it without trouble. No, we have to get familiar with the higher level stuff of AI of strategy games.

It is a pity that there are no examples. to my knowledge no one, ever bothered to make a good AI. So:...

1. we cant copy anything
2. most stuff is theoretical
3. we will have to figure things out ourselves

back to work... :coffee:
We will be designing some AI in this tutorial, and that includes for existing games. even if it is way later on.
Oh, and search SourceForge for open source games made in python. There are bound to be tonnes of them, even if they are mostly in linux (Which is easily portable, dont you worry...)

See, the open source community is good for everything!
 
Okay, I just skipped all of the thread after I joined, what's going on now, what are we learning, how do we do it, and what's with the status in the main post? Sorry, I don't have any time to read the thread now, about to rush out. Thank you.
 
I'll start the lesson tomorrow. Sorry for being late...
 
Gogf: read Post 24 to have the status thing at the top explained.

I will hopefully have the next lesson written in 24hrs, have it posted in 30hrs, but I'll still help those who are stuck on lesson 1. It takes < 10 minutes, it's not much to catch up on.
 
Finished Lesson 1!
 
Hi I would like to join and I have no experience what so ever. I completed the first lesson.
 
Top Bottom