Python (civ4 scripting language) tutorial thread

I_pity_the_fool said:
http://www.pythonchallenge.com/

I think some people here might enjoy this series of puzzles - the first few require simple logic. The rest programs...
Just going through these the other day :eek: They are a real brain workout until you get the gist of the puzzles, and then they slam you with in-depth python knowledge!

This ain't no beginner challenge - but still fun, even with my limited experience.
 
I'll think about this. I have a ton of coding experience (21+ years), plus some dabling in Python, but not recently. In other words, my Python is one dead snake at this point. Any ideas on what modding projects you guys want to do?
 
Sorry I missed your post, TB (same initials as a bad disease? Just a coincidence). I hope you enjoy learning about python, as civIV's release approaches.

An interesting quote:
Our team is working around the clock to put the final polish on Sid Meier’s Civilization IV, scheduled for release this November. We’ve truly reinvented this classic game, while keeping true to what you and millions of gamers like you have grown to love. With a brand new 3D engine, built from day one to include dramatically improved multiplayer, modding capabilities that will break new ground in the strategy game world, and the introduction of religion and Great People, Civ IV represents the biggest leap forward in the series. The improvements are many: years of planning and design, evaluation of invaluable feedback from our incredible fans, and our own Civ wish list ensured the implementation of hundreds of significant improvements to the A.I., interface, and game flow. If you don’t mind us saying so, Civ IV looks better than ever, plays as intuitively and impeccably as you’d expect, and lives beyond the box like never before.
Breaking new ground? Can't wait to see what that means!
 
Thanks a lot for this tutorial, GB!
I am currently working on lecture 5.
So far, I have allready written a program that lists all primes up to a number that you can chose. Nothing fancy or special, but the first program I ever did, and I am glad it worked.
I`ll try to work something from every lecture in, what an awesome prime-number finder it will be in the end. :p
 
Taking the example from Zorn, I have a challenge for you all (if you choose to accept it):
1) Make a program that prints all multiples of a given number
2) create a timer to see how long the operation takes (HINT - import timer)
3) try to make your multiples program faster.
fastest program wins. I'll dig up some nice numbers to test it on - primes, few multiples and many multiples, big and small.
 
Gingerbread Man said:
Taking the example from Zorn, I have a challenge for you all (if you choose to accept it):
1) Make a program that prints all multiples of a given number
2) create a timer to see how long the operation takes (HINT - import timer)
3) try to make your multiples program faster.
fastest program wins. I'll dig up some nice numbers to test it on - primes, few multiples and many multiples, big and small.
I'll give it a try. :)
 
Just a quick question-

I'm just reading through the single posts that are linked to in the first post, is this enough, or should I read through this entire topic?

EDIT: :( I can't get this to work at all:

# this line makes 'a' equal whatever you type in
a = raw_input("Type in something, and it will be repeated on screen:")

# this line prints what 'a' is now worth
print a

It works if I copy it in, but as soon as I change "Type in something etc etc" to anything else, it stops working, even if I change it back. What the heck is going on?
 
IslandFox - just the lessons are enough to get started. Go to www.sthurlow.com (my website) if you want all lessons in one spot. They are also more up-to-date.

As for your raw_input issue, have you kept the quotation marks? Give me an example of what isn't working, and I'll have a look.
 
Gingerbread Man said:
Taking the example from Zorn, I have a challenge for you all (if you choose to accept it):
1) Make a program that prints all multiples of a given number
2) create a timer to see how long the operation takes (HINT - import timer)
3) try to make your multiples program faster.
fastest program wins. I'll dig up some nice numbers to test it on - primes, few multiples and many multiples, big and small.
I made my first program that does just that, but I don't know how to include a time.

Can I post the code or should I pm the code to you ?
I'm a rookie, so it ain't that good, I just have all the multiples sorted and printed and an endline stating how many there were.
On a larger number like "86925841319772000" nothing happens though :(
 
Ah ok.
Thanks...
Can you please explain how to include a timer ? I know my programm won't win it for sure, so I'm willing to share it :)
 
Yea, but he's offline and I think you know enough to judge whether this was a reasonable attempt ;)
So yes, PM'd it to you :)
 
Well yours is a whole lot cleaner and shorter then mine. Then again my variables arn't simply labeled "a". For example "current_number" is equal to the number that the loop is on.

Also there are a bunch of things you could do to make it faster. :)
 
SonicX said:
Ok thanks ... well, I ain't getting into "class" subjects yet, so I'll have to try something else then :)
Actually to make it faster just requires some basic math and basic knowledge of multiples.
 
I know what you mean. If you checked divisability by 2 and 3, you can leave 6 out.
If only I could come up with a way to implement that without doing the lost list of numbers over and over for different checks :)
 
Wohooa ... has been a long time since I visited this thread. I had to complete my job training and became occupied with WoW :D.
I will try to catch up with all the "new" posts :blush:.

Anyway ... I started to play with python again and I came across problem. I want the user to choose a directory and a file with a file/directory chooser dialog. I expected a standard implementation at least in Tkinter but I only found some information which at least sounds as if I could use it in connetion with Tcl(-script) ... I don't get it. This does not even seem to be python-code but it's documented in python-documentation:
http://www.python.org/doc/2.2.3/lib/node528.html
http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixDirSelectDialog.htm

In the python-doc shipped with python 2.4 I've red that tixDirSelectDialog is deprecated and that tk_chooseDirectory should be used. But I didn't find a documentation of that class in python-doc.

GBM do you know more about this?? Can somebody help me out?
 
Back
Top Bottom