Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8632) Easy way to set map size with auto ratios (setea
Home

[Freeciv-Dev] (PR#8632) Easy way to set map size with auto ratios (setea

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: mburda@xxxxxxxxx
Subject: [Freeciv-Dev] (PR#8632) Easy way to set map size with auto ratios (seteables if desired)
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 26 May 2004 22:28:18 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8632 >

Your mcd (maximum common denominator?) function isn't good.

- I've always seen it called gcf, greatest common factor. 
http://www.math.com/school/subject1/lessons/S1U3L2GL.html.  But gcd
would also be okay.

- According to Euclid's Algorithm (Euclidean algorithm):

gcf(a, b) = gfc(b, a-b)
gcf(a, 0) = a.

which gives:

int gcf(int a, int b)
{
  int min = MIN(a, b), max = MAX(a, b);

  if (min == 0) return max;
  return gcf(min, max - min);
}

Also...

INIT_TOPOLOGY_CASE shouldn't be a macro.  In fact you don't need a
switch statement here at all.  Make the list of default values an array
and just give something like

  if (map.ratio == 100) {
    set_ratio(default_ratio[map.topology_id]);
  } else {
    set_ratio(map.ratio);
  }

Which brings me to my next point that auto_ratio and user_ratio should
be merged.

I haven't delved too deep into set_mapratio yet though.

jason




[Prev in Thread] Current Thread [Next in Thread]