[net.sources.bugs] Ogre oscillation bug fix...

dan@rna.UUCP (Dan Ts'o) (11/22/84)

plugh

	Ogre turns out to be a cute little game - quite well done. However
I found that the oscillation bug (as mentioned in the manual page) makes it
considerably easier to the win game since the Ogre just oscillates back and
forth while you shoot. (A situation which makes it oscillate 90% of the
time is to put your CP in the upper right hand corner, place a howitzer a
few hexes to the left and force the Ogre to go in between the howizter and
the crater in front of the CP. The Ogre just can't bring itself to go closer
to the howizter.)
	I have made an attempt to fix this oscillation bug. The diffs are given
below. It basically remembers the previous direction the Ogre moved and
weights against moving in the opposite direction. This "fix" will not catch
oscillation which, for example, would cause the Ogre to move in a circle.
However I have never seen that happen. The Ogre has yet to oscillate with
this fix in.
	Someelse mentioned the bug which doesn't allow you to win even if
the Ogre's movement points are zero. I didn't see a fix for this bug (forgive
me if one was posted) so I made one up - a simple call to check_over() in
the resolve code.


					Cheers,
					Dan Ts'o
					Dept. Neurobiology
					Rockefeller Univ.
					1230 York Ave.
					NY, NY 10021
					212-570-7671
					...cmcl2!rna!dan

Fix for "can't win" bug: line 99 resolve.c

    /* dyt - check if over now */
    check_over();
}

Fix for oscillation bug:
*** ogrecom.c.org	Wed Nov 21 18:49:47 1984
--- ogrecom.c	Wed Nov 21 21:12:19 1984
***************
*** 30,35
      int i, max;
      char a, b;
      char olda, oldb;
  
      a = ogre.l_hex;
      b = ogre.r_hex;

--- 30,39 -----
      int i, max;
      char a, b;
      char olda, oldb;
+ /* dyt - prevent oscillation */
+     static int osccnt;
+     static int oscdir;
+     static int mapdir[7] = { 0, 4, 5, 6, 1, 2, 3 };
  
      a = ogre.l_hex;
      b = ogre.r_hex;
***************
*** 44,49
      weight[5] = getweight(a + 1, b);
      weight[6] = getweight(a, b - 1);
  
      max = 0;
      for(i = 1; i < 7; i++)
          if(weight[i] > weight[max]) max = i;

--- 48,56 -----
      weight[5] = getweight(a + 1, b);
      weight[6] = getweight(a, b - 1);
  
+ /* dyt - prevent oscillation - decrease weight if returning to old position */
+     weight[mapdir[oscdir]] -= 10 * osccnt;
+ 
      max = 0;
      for(i = 1; i < 7; i++)
          if(weight[i] > weight[max]) max = i;
***************
*** 47,52
      max = 0;
      for(i = 1; i < 7; i++)
          if(weight[i] > weight[max]) max = i;
  
      switch(max) {
  

--- 54,70 -----
      max = 0;
      for(i = 1; i < 7; i++)
          if(weight[i] > weight[max]) max = i;
+ 
+ /* dyt - record new direction */
+     if (max == mapdir[oscdir])
+      	  osccnt++;
+     else
+         osccnt = 0;
+     oscdir = max;
+ 
+ /* display(17, "max %d weight %d cnt %d odir %d ndir %d",
+ 	max, weight[max], osccnt, oscdir, mapdir[oscdir]);
+    cycle(); */
  
      switch(max) {