12monkeys
Prince
--------------------------------------------------
Name : AStar Pathfinder + Move Highlighter
Version : v1.1
Date : 12.03.06
Author : 12monkeys (@civfanatics + @apolyton)
--------------------------------------------------
Motivation :
-------------
- The initial idea was born in a thread in the C&C forum, when The Great Apple posted a small feature which highlights the move area of an unit. After some tries and discussions this great idea stucks due to the lack of a usable function to calculate the movement costs for a unit between plot A and B. Because thebuilt-in path finding function is not usable from python, I didn't though that we could solve this problem. Then belizan stated, that a path finding algorithm is quite a usual problem in that it could be as fast as the in built one. That gave me the push! After some investigation I found the A* path finding algorithm and started to create this small component.
Features :
-------------
AStarTools.py provides two classes for external use:
- AStar() :
contains some functions to calculate the shortest path between two plots for a specific unit. Although the calculated path is different from the one the built-in pathfinder creates, the calculated movement costs are the same (at least during my tests). The built-in pathfinder, creates more smooth pathes, while my one creates more zig-zag pathes. It also provides you with functions to calculate the area a unit can move to within its remaining movement points.
- AStarMoveArea() :
contains a function to highlight/dehighlight the area a unit can move to. The area will be calculated by class AStar(). It is highlighted with colored brackets, where the color codes some information about the plot itself. The function takes consideration of not revealed plots and visible or invisible units (as subs and spies).
For details about the usage of the two classes, have a look in the code example attached and into the AStarTools.py file itself. In the header of each class as well as in the definition of the main methods is some more information.
CvHighlightEvents.py is a sample implementation for the AStar classes as well as a small modcomp. As soon as you click on an already selected unit, all plots the unit can move to are highlighted. Ther single plots are color coded and have the following meaning :
- white : neither units not foreign territory on that plot
- cyan : indicate barbarians, where darkcyan is barbarian toeeritory (huts) and cyan are barbarian units.
- red : indicates enemies, where darkred is enemy territory and red are enemy units.
- yellow : indicate neutrals, where darkyellow is neutral territory and yellow are neutral units.
Files :
-------------
\MonkeysTools\AStarTools.py :
- contains the above mentioned classes. In former versions the folder was named "MyTools".
\CvHighlightEvents.py :
- the movement highlighter. Contains the acall of the AStar methods. Idea and implementation copied from The Great Apples code.
\entrypoints\CvEventInterface.py :
- has to be modified to hook up CvHighlightEvents.py (again, copied from The Great Apple)
\INIParser\* :
- code by Dr. Elmer Jiggle to retrieve data from INI file. Attention : found a small bug in there which I corrected. Now it is are able to retrieve data from INI files in your "My Documents" folder, when you changed the default installation directory to something else than "Sid Meier's Civilization 4" (as I did ).
Requirements :
-------------
- Civ4 patch 1.52 or 1.61
Installation :
-------------
- copy the files from the ZIP into their corresponding folders in the "My Documents\My Games\Civilization 4" folder. Installation at own risk!. If you have already a modified versions of any file in this mod, you can manually merged them by looking for the comments "12monkeys - <mod name> - begin/end"
Copy the AStarTools.INI into the folder "My Documents\My Games\Sid Meier's Civilization 4" (or how ever its is named on your computer )
Issues :
-------------
- when there is a foreign submarine in sight of a unit which usually is not able to detect subs, it will be detected (colored frame) as soon as there is an own destroyer nearby, although the sub is not in sight of the destroyer. Currently no idea how to fix that.
- the paths created by my A* algorithm need to be more smoother, although the results is cost optimized.
Ideas for future realeases :
-------------
- needs to be expanded to handle unit stacks
Release Notes :
-------------
v1.1 :
- added color configuration by INI file (thx TheLopez for this idea)
- fixed a bug which causes a crash under special circumstances (thx Belizan for reporting it)
v1.0 :
- initial release
Credits :
-------------
- The Great Apple
for the inital idea and motivation
- Belizan
for giving me a "push"
- Patrick Lester
for his webpage describing the A* algorithm
- nameless other people
for creation of the A* algorithm
Name : AStar Pathfinder + Move Highlighter
Version : v1.1
Date : 12.03.06
Author : 12monkeys (@civfanatics + @apolyton)
--------------------------------------------------
Motivation :
-------------
- The initial idea was born in a thread in the C&C forum, when The Great Apple posted a small feature which highlights the move area of an unit. After some tries and discussions this great idea stucks due to the lack of a usable function to calculate the movement costs for a unit between plot A and B. Because thebuilt-in path finding function is not usable from python, I didn't though that we could solve this problem. Then belizan stated, that a path finding algorithm is quite a usual problem in that it could be as fast as the in built one. That gave me the push! After some investigation I found the A* path finding algorithm and started to create this small component.
Features :
-------------
AStarTools.py provides two classes for external use:
- AStar() :
contains some functions to calculate the shortest path between two plots for a specific unit. Although the calculated path is different from the one the built-in pathfinder creates, the calculated movement costs are the same (at least during my tests). The built-in pathfinder, creates more smooth pathes, while my one creates more zig-zag pathes. It also provides you with functions to calculate the area a unit can move to within its remaining movement points.
- AStarMoveArea() :
contains a function to highlight/dehighlight the area a unit can move to. The area will be calculated by class AStar(). It is highlighted with colored brackets, where the color codes some information about the plot itself. The function takes consideration of not revealed plots and visible or invisible units (as subs and spies).
For details about the usage of the two classes, have a look in the code example attached and into the AStarTools.py file itself. In the header of each class as well as in the definition of the main methods is some more information.
CvHighlightEvents.py is a sample implementation for the AStar classes as well as a small modcomp. As soon as you click on an already selected unit, all plots the unit can move to are highlighted. Ther single plots are color coded and have the following meaning :
- white : neither units not foreign territory on that plot
- cyan : indicate barbarians, where darkcyan is barbarian toeeritory (huts) and cyan are barbarian units.
- red : indicates enemies, where darkred is enemy territory and red are enemy units.
- yellow : indicate neutrals, where darkyellow is neutral territory and yellow are neutral units.
Files :
-------------
\MonkeysTools\AStarTools.py :
- contains the above mentioned classes. In former versions the folder was named "MyTools".
\CvHighlightEvents.py :
- the movement highlighter. Contains the acall of the AStar methods. Idea and implementation copied from The Great Apples code.
\entrypoints\CvEventInterface.py :
- has to be modified to hook up CvHighlightEvents.py (again, copied from The Great Apple)
\INIParser\* :
- code by Dr. Elmer Jiggle to retrieve data from INI file. Attention : found a small bug in there which I corrected. Now it is are able to retrieve data from INI files in your "My Documents" folder, when you changed the default installation directory to something else than "Sid Meier's Civilization 4" (as I did ).
Requirements :
-------------
- Civ4 patch 1.52 or 1.61
Installation :
-------------
- copy the files from the ZIP into their corresponding folders in the "My Documents\My Games\Civilization 4" folder. Installation at own risk!. If you have already a modified versions of any file in this mod, you can manually merged them by looking for the comments "12monkeys - <mod name> - begin/end"
Copy the AStarTools.INI into the folder "My Documents\My Games\Sid Meier's Civilization 4" (or how ever its is named on your computer )
Issues :
-------------
- when there is a foreign submarine in sight of a unit which usually is not able to detect subs, it will be detected (colored frame) as soon as there is an own destroyer nearby, although the sub is not in sight of the destroyer. Currently no idea how to fix that.
- the paths created by my A* algorithm need to be more smoother, although the results is cost optimized.
Ideas for future realeases :
-------------
- needs to be expanded to handle unit stacks
Release Notes :
-------------
v1.1 :
- added color configuration by INI file (thx TheLopez for this idea)
- fixed a bug which causes a crash under special circumstances (thx Belizan for reporting it)
v1.0 :
- initial release
Credits :
-------------
- The Great Apple
for the inital idea and motivation
- Belizan
for giving me a "push"
- Patrick Lester
for his webpage describing the A* algorithm
- nameless other people
for creation of the A* algorithm