[Kde-games-devel] Konquest - patch for distance function

Jack Grahl mnvl16 at yahoo.co.uk
Sun May 20 01:34:45 CEST 2007


Hi there,
I've written a modification to the 'distance' function in Konquest, which calculates the distance between planets. The new function is essentially the same, but changes the order of operations to better conserve accuracy. The accuracy isn't critical since the number of turns ships take to travel between planets is obviously an integer. However the new function is more understandable (when using the ruler) and easier to estimate by eye (since it is closer to usual distance in the plane). Of course this changes the strategy, but not critically since the relative distances of the planets are more important than their layout in the plane.
I was also wondering whether this game is being actively maintained at the moment. Someone submitted a nice patch several years ago which improved the AI for the game and would have simplified improving it further, by abstracting it from the core game engine. This patch doesn't seem to ever have been applied. There are also several more modifications to this game I'd like to do gradually - mainly to do with useability. Perhaps someone could let me know what the situation is?
Best wishes,
Jack Grahl
  

--- kdegames-3.5.5/kdegames-3.5.5/konquest/gamecore.cc  2007-05-19 21:26:38.000000000 +0100
+++ kdegames-3.5.5-dist/kdegames-3.5.5/konquest/gamecore.cc     2005-09-10 09:18:23.000000000 +0100
@@ -49,10 +49,10 @@
 double
 CoreLogic::distance( Planet *p1, Planet *p2 )
 {
-    int k = (p1->getSector().getRow() - p2->getSector().getRow());
-    int l = (p1->getSector().getColumn() - p2->getSector().getColumn());
+    int k = (p1->getSector().getRow() - p2->getSector().getRow()) / 2;
+    int l = (p1->getSector().getColumn() - p2->getSector().getColumn()) / 2;

-    return (sqrt(double((k*k) + (l*l))) / 2);
+    return sqrt(double((k*k) + (l*l)));
 }

 double





      ___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/ 


More information about the kde-games-devel mailing list