.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 2: The Ascension Wars

Reply
 
Thread Tools Display Modes
  #1  
Old June 15th, 2004, 03:23 AM

nakomus nakomus is offline
Private
 
Join Date: Feb 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
nakomus is on a distinguished road
Default Random map files and annotations: Python

A while back I posted in a thread about Gandalf’s random map generator; I commented that I had tried writing a similar program in Python but failed. Soon after I reattempted the problem, and was successful in generating simple random opponents.

I was also thinking about the semi-random map idea and what one would need to be able to do to make semi-believable random maps. In order for a program to modify the map file in a believable way I concluded it really ought to have an model of the world internally, based on the information in the mapfile.

Anyway, the point is I have a I have Python code that reads in a mapfile and extracts province numbers, terrain types, and neighbors. Each province is an object with terrain and connection data associated with. Human and AI player information is in another object.

I can form provinces into lists or unordered sets pretty easily and work with them; for example, I could look at the set of provinces with the water terrain flag to see if the map has enough water provinces to allow water nations as AIs.

Currently I have two problems:
1) It doesn’t really do anything. I can pull all this information out of the map file, but I don’t have any real great idea for what to DO with it after that.

2) Its not packaged for distribution, I call use it from an interactive python session. It wouldn’t be too hard to make it into a script that could be called from the command line with arguments once I can do more than just make random opponents; although the odds of seeing a standalone executable in the near future is poor.

So what I’m wondering is, what should I do with all this map information? (I could parse more map commands if it was interesting, also). I can do things like #nostart provinces that don’t have enough (or too many) neighbors. With a bit of work I could assign the AI and/or human starting provinces (this would be nation-specific) and guarantee that no one starts right next to someone else.

Going back to the semi-random-maps discussion, is anyone making armies or army/site combinations that could be dropped into a map file?

I know Gandalf and Lief(spelling?) have there own map-randomizers. I’m not sure how what I’m doing overlaps with what you are doing;

My impression from Poke in The Eye and family at least, is that those generators are not very context-aware, putting randomly generated troops in provinces where they will drown, for example.

SO: What sort of things would you like to be able to do based on terrain and neighbors? What level of interest is there?

If Anyone is interested, I can email you a copy of code although its not terribly user friendly at this point.
Reply With Quote
  #2  
Old June 15th, 2004, 03:36 AM
Pirateiam's Avatar

Pirateiam Pirateiam is offline
Corporal
 
Join Date: Jan 2004
Location: Upstate NY
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Pirateiam is on a distinguished road
Default Re: Random map files and annotations: Python

Actually I am trying to teach myself Python right now and would be interested in looking at your code. As long as you do not mind me possibly using some of it. I do have a few questions about Python. Do you reccomend any references for someone to help learn Python? What is the execution speed comparable to? What cross-platforms have you used with success? Sorry for the questions but I am inquisitive by nature. I will PM you my e-mail if you allow me to look at your code. Thanks
__________________
Every normal man must be tempted at times to spit upon his hands,
hoist the black flag, and begin slitting throats.
- Henry Louis Mencken
Reply With Quote
  #3  
Old June 15th, 2004, 05:32 AM

nakomus nakomus is offline
Private
 
Join Date: Feb 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
nakomus is on a distinguished road
Default Re: Random map files and annotations: Python

The number-one and only real reference I can suggest is the documentation section on python.org, the tutorial is quite good and the Library Reference has a lot of information. That’s what I personally used learning the language.

Pure Python code’s execution speed is generally poor, its fully interpreted and does not compile to native code. If performance is a serious problem there are several solutions. The first is to rewrite the program’s hotspots in C; Python is implemented in C and can easily integrate modules and functions from C to improve performance. In fact there are some automated tools to make python wrappers for C libraries. I’ve never extended tried to do this so I can’t comment much.

The other solution to performance issues is to use the excellent support libraries which are generally in C. For example, the Numerical Python libraries provide matrix and array operations if you need to do serious number crunching and are generally very fast.

Most of the code I’ve written runs faster than I can notice anyway.

I have used Python under Linux (Debian, Slackware, Red Hat) and Windows (98, XP). Python has been ported to a pretty wide variety of systems, I would not expect that would be a problem.


Quote:
Originally posted by Pirateiam:
... I do have a few questions about Python. Do you reccomend any references for someone to help learn Python? What is the execution speed comparable to? What cross-platforms have you used with success? ...
Reply With Quote
  #4  
Old June 15th, 2004, 04:17 PM
Pirateiam's Avatar

Pirateiam Pirateiam is offline
Corporal
 
Join Date: Jan 2004
Location: Upstate NY
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Pirateiam is on a distinguished road
Default Re: Random map files and annotations: Python

Thanks for the reply nakomus! I am currently in the middle of the tutorial. Thanks
__________________
Every normal man must be tempted at times to spit upon his hands,
hoist the black flag, and begin slitting throats.
- Henry Louis Mencken
Reply With Quote
  #5  
Old June 15th, 2004, 07:19 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Random map files and annotations: Python

@Nakomus:
Well, if you take a look at some more of my stuff which is semi popular (www.dom2minions.com) you might get an idea as to how your gathering info from the map file will allow a program to do what I do, but better.

Such as.... I randomly scatter castles and monsters across the map. The result is land castles in water, water castles on land. Same with monsters which drown as soon as you attack the province.

If you paired your program gathering info about a map, with one which maintains the same info for castles, natives, monsters, sites, pre-made interesting provinces, province names based on terrain (woods, water, mountain, island, swamp).... then doing a BETTER random program might be very interesting.

[ June 15, 2004, 18:21: Message edited by: Gandalf Parker ]
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #6  
Old June 15th, 2004, 11:23 PM
PvK's Avatar

PvK PvK is offline
National Security Advisor
 
Join Date: Dec 1999
Posts: 8,806
Thanks: 54
Thanked 33 Times in 31 Posts
PvK is on a distinguished road
Default Re: Random map files and annotations: Python

My co-worker Jeff offers:

There appears to be a new edition of O'Reilly's "Learning Python", that is update for Python 2.3. http://www.oreilly.com/catalog/lpython2/

Overstock.com seems to have the best price
http://www.overstock.com/cgi-bin/d2....PROD_ID=625685
Reply With Quote
  #7  
Old June 16th, 2004, 02:19 AM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Random map files and annotations: Python

I have shelves and shelves of OReilly books. I dont recommend them for learning. On any new subject I get a yellow "for Dummies" book first. Those are great books. Even if all it does is convince me that I already knew more than I thought on the subject its a good start. (never get the orange "for Idiots" books)

In-between, a SAMs book is good for learning. QUE is great. WAITE is abit heavy but good.

OReilly you get Last. In my opinion its alot of help but only if you already know the subject. Plus its impressive on the bookshelf for those who know what an OReilly book is.
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #8  
Old June 16th, 2004, 02:41 AM
PvK's Avatar

PvK PvK is offline
National Security Advisor
 
Join Date: Dec 1999
Posts: 8,806
Thanks: 54
Thanked 33 Times in 31 Posts
PvK is on a distinguished road
Default Re: Random map files and annotations: Python

You could use the tutorial on the web at first, and a book like the O'Reilly for a reference and to figure out more details.

PvK
Reply With Quote
  #9  
Old June 16th, 2004, 04:18 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Random map files and annotations: Python

This is a FUN site. Anyone who has more than one programming language, or wants to, can have a good time here.
http://www.99-bottles-of-beer.net/

It shows the code for doing that song in 621 different programming Languages. It does alot in my opinion toward showing the difference between the efficient/good/marketable Languages and the ones that I can actually learn to produce something with now.
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #10  
Old June 16th, 2004, 05:12 PM
PvK's Avatar

PvK PvK is offline
National Security Advisor
 
Join Date: Dec 1999
Posts: 8,806
Thanks: 54
Thanked 33 Times in 31 Posts
PvK is on a distinguished road
Default Re: Random map files and annotations: Python

Hehe. Interesting.

By the way, another friend recommends a different Python book, although he says it is further in the serious/reference direction rather than the learning direction. There is still the good web tutorial, though:

My pal Paul wrote:
Quote:
IMO the 'Learning Python' book is not as good as the 'Programming Python' book. As the title suggests, the learning book is more of an introduction to Python whereas the programming book provides a deeper and broader coverage. I'd spend the bucks for the 'Programming Python' book. There's a second edition of it out too, although it looks like it covers only Python 2.0.
PvK
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 10:35 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.