Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 76 lines (67 sloc) 6.426 kb
83567d09 »
2011-05-26 directory restructure
1 <html>
2 <head>
3 <title>Lesson 1 - Installing Python</title>
4 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
5 <meta name="keywords" content="civilization,civ2,civ3,civ4,civilization iii,civilization ii,civilization iv,mod,python,xml,script,install" />
6 <meta name="description" content="A Python and XML tutorial aimed at Civilization IV modding" />
7 </head><link rel="stylesheet" type="text/css" href="../../stylesheet.css" />
8
9 <body bgcolor="Teal">
10 <div align="center" class="SidePanel">
11 <div align="left" class="PaddingBig">
12 <div class="MenuSection">
13 <h1>Sthurlow.com</h1>
14 <h2>Civilization IV Python tutorial</h2><h3>The Python Tutorial</h3>
15 <p>The original sthurlow.com python tutorial</p>
16 <p>
17 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson01/">Installing Python</a></div>
18 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson02/">Very Simple Programs</a></div>
19 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson03/">Variables, Scripts</a></div>
20 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson04/">Loops, Conditionals</a></div>
21 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson05/">Functions</a></div>
22 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson06/">Tuples, Lists, Dictionaries</a></div>
23 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson07/">for Loop</a></div>
24 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson08/">Classes</a></div>
25 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson09/">Importing Modules</a></div>
26 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson10/">File I/O</a></div>
27 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/python/lesson11/">Error Handling</a></div>
28 </p>
29 <h3>The Civ4 Programming Tutorial</h3>
30 <p>All new Civ4 programming tutorial</p>
31 <p>
32 <div class="MenuItem">&nbsp;<a href="http://www.sthurlow.com/">Lesson 1 (not released)</a></div>
33 </p>
34 <br /><br /></div></div>
35 </div>
36
37 <div align="center" class="TextPanel">
38 <div align="left" class="Padding"><h2>Installing Python</h2>
39
40 <h3>What is python?</h3>
41 <p>If you don't understand this, don't worry. Just skip it and move on.</p>
42 <p>Python is an <b>interpreted</b> <i>programming language</i>. 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.</p>
43 <p>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.</p>
44
45 <h3>So why will civIV use Python?</h3>
46
47 <div align="center" class="ImageBody" style="float: right;">
48 <img src="../../images/01_garble.jpg" />
49 <div align="center" class="ImageCaption">Image 1 - The garbled mess of a compiled program</div></div>
50 <p>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.</p>
51 <p>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 can't share the logic behind it with anyone.</p>
52 <p>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!!!!!</p>
53
54 <h3>How to install python</h3>
55 <ol>
56 <li>First download <a href="http://www.python.org/ftp/python/2.4.1/python-2.4.1.msi">Python-2.4.1.exe</a> by following this link. If you are a dialup user, keep in mind that the file is around 10MB</li>
57 <li>Run the file you just downloaded, and follow the prompts.</li>
58 </ol>
59 <p>OK! Hopefully now everything is good! Now, to test if that just worked, type this in your DOS window:</p>
60
61 <div align="center">
62 <div align="center" class="CodeTitle">Code Example 1 - Testing the installation</div>
63 <div align="left" class="CodeBody">
64 <pre>
65 python -V
66 </pre>
67 </div>
68 </div><p>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.</p>
69
70 <h3>conclusion</h3>
71 <p>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!</p>
72 <p>Thanks to all,</p>
73 <p>sthurlow.com</p>
74
75 </div></div></body>
76 </html>
Something went wrong with that request. Please try again.