Date:	Wednesday January 7, 2004 @ 20:42
Author:	unbelver

Update of /home/netrek/cvsroot/Vanilla/robots
In directory swashbuckler.real-time.com:/var/tmp/cvs-serv14253/robots

Modified Files:
	puck.c puckdefs.h puckmove.c 
Log Message:

Added in Psychosis' hockey code running on puck.psychosis.net.
Disabled by default, but useful to keep in the main tree.  3
differences.  

PUCK_FIRST:  Puck process runs first on each update.  Mainly for shots
on edge of shot range.  Puck isn't pressored out before puck notices
that it is shot.

FO_BIAS:  non-scoring team, or team that's more than 5 goals behind
get faceoff advantage.  Advantage settable with FACEOFF_HELP.

SITOUT_HURTS:  Normally a sitout puts you within 5 points of exploding
to avoid cheating.  Undefine this and sitout won't hurt.

--Carlos V.




****************************************

Index: Vanilla/robots/puck.c
diff -u Vanilla/robots/puck.c:1.4 Vanilla/robots/puck.c:1.5
--- Vanilla/robots/puck.c:1.4	Sun Jul 11 22:28:02 1999
+++ Vanilla/robots/puck.c	Wed Jan  7 20:42:20 2004
@@ -20,6 +20,13 @@
 #include "puckdefs.h"
 #include "proto.h"
 
+#ifdef PUCK_FIRST 
+#include <sys/sem.h> 
+
+struct sembuf sem_puck_op[1]; 
+int sem_puck;
+#endif /*PUCK_FIRST*/
+
 void config(int);
 
 extern int redrawall;
@@ -104,6 +111,17 @@
     myship = &me->p_ship;
     mystats = &me->p_stats;
     lastm = mctl->mc_current;
+ 
+#ifdef PUCK_FIRST
+    if((sem_puck = semget(PUCK_FIRST, 1, 0600)) == -1)
+      {
+	ERROR(1,("Puck unable to get semaphore."));
+      }
+
+    sem_puck_op[0].sem_num = 0;
+    sem_puck_op[0].sem_op = 1;
+    sem_puck_op[0].sem_flg = 0; 
+#endif /*PUCK_FIRST*/
 
     /* At this point we have memory set up.  If we aren't a fleet, we don't
        want to replace any other robots on this team, so we'll check the
Index: Vanilla/robots/puckdefs.h
diff -u Vanilla/robots/puckdefs.h:1.2 Vanilla/robots/puckdefs.h:1.3
--- Vanilla/robots/puckdefs.h:1.2	Fri Apr 30 15:19:07 1999
+++ Vanilla/robots/puckdefs.h	Wed Jan  7 20:42:20 2004
@@ -45,6 +45,18 @@
 
 #define NUMSKATERS	12
 
+                       /* With SITOUT_HURTS defined, sitout causes
+                          ships to be severely damaged (in order to prevent
+                          abuse of sitout to gain position). If undefined,
+                          sitout does not damage, but also does not
+                          change a ship's y-position (allowing ships to
+                          return to the rink quickly if a sitout wasn't
+                          really needed, etc, which happens far more often
+                          than abuse). Default was defined  */
+#define SITOUT_HURTS
+ 
+
+
 /* Some "computer speed" definitions */
 #define HOWOFTEN 1                       /*Robot moves every HOWOFTEN cycles*/
 #define PERSEC (1000000/UPDATE/HOWOFTEN) /* # of robo calls per second*/
@@ -78,6 +90,17 @@
 #define KLI_E (RINK_TOP    +   TENTH/2) /* end of Kli goal */
 #define KLI_B (RINK_TOP    + (RINK_LENGTH/3)) /* Kli blue line */
 
+                       /* FO_BIAS adds in code for biasing Faceoff against
+                          the scoring team, or a team ahead by more than 5
+                          points.  Leaving this undefined is the default 
+                          behavior of leaving puck in the center without
+                          FACEOFF_HELP code */
+/* #undef FO_BIAS */
+                       /* FACEOFF_HELP should be defined, either as 0
+                          to leave the default behaviour, or > 0 as the
+                          offset to apply to the puck's droppoint at faceoff
+                          to assist the losing team. */
+#define FACEOFF_HELP (TENTH*2/3)
 
 
 /* Some global puck variable definitions */
Index: Vanilla/robots/puckmove.c
diff -u Vanilla/robots/puckmove.c:1.8 Vanilla/robots/puckmove.c:1.9
--- Vanilla/robots/puckmove.c:1.8	Sun Dec  3 11:52:20 2000
+++ Vanilla/robots/puckmove.c	Wed Jan  7 20:42:20 2004
@@ -23,6 +23,13 @@
 #include "data.h"
 #include "puckdefs.h"
 
+#ifdef PUCK_FIRST 
+#include <sys/sem.h> 
+
+extern struct sembuf sem_puck_op[1];
+extern int sem_puck;
+#endif /*PUCK_FIRST */
+
 
 
 #define WEAKER_STR 2		/* integer factor to divide tractstr down */
@@ -161,7 +168,19 @@
 int team_offsides = 0;
 #endif
 
+#ifdef PUCK_FIRST
+void _rmove(void); /* original rmove we're hijacking */
+
+void rmove(void)
+{
+  _rmove();
+  semop(sem_puck, sem_puck_op, 1);  /* we're done, everyone else's turn now */
+}
+
+void _rmove(void)
+#else /*PUCK_FIRST */
 void rmove(void)
+#endif /*PUCK_FIRST */
 {
     extern struct Enemy *get_nearest();
     struct Enemy *enemy_buf;
@@ -174,6 +193,10 @@
 
     static int pauseticks;
 
+#ifdef FO_BIAS
+    static int faceoffbias = 0;
+#endif /*FO_BIAS*/
+
     /***** Start The Code Here *****/
 
     HANDLE_SIG(SIGALRM,rmove);
@@ -193,12 +216,18 @@
     /* This is done first to allow for a good short_game  */
     if (roboclock >= END_OF_PERIOD) {
         if (period >= PERIODS_PER_GAME) {
+#ifdef FO_BIAS
+            faceoffbias = 0;
+#endif /*FO_BIAS*/
 	    messAll(anncer->p_no,roboname,"#############################");
 	    messAll(anncer->p_no,roboname,"#");
 	    messAll(me->p_no,    roboname,"#  END OF GAME.");
 	    messAll(anncer->p_no,roboname,"#");
 	    woomp();
 	} else {
+#ifdef FO_BIAS
+            faceoffbias = 0;
+#endif /*FO_BIAS*/
 	    messAll(anncer->p_no,roboname,"#");
 	    messAll(me->p_no,    roboname,"#  END OF PERIOD.");
 	    messAll(anncer->p_no,roboname,"#");
@@ -288,7 +317,13 @@
 	    }
 	    messAll(me->p_no,roboname,"<thunk!>");
 	    me->p_x = 45000 + random()%10000; /* reappear */
+#ifdef FO_BIAS
+	    if (scores[KLI] >= (scores[ORI]+5)) faceoffbias = 1;
+	    if (scores[ORI] >= (scores[KLI]+5)) faceoffbias = -1;
+	    me->p_y = R_MID + FACEOFF_HELP * faceoffbias;
+#else /*FO_BIAS */
 	    me->p_y = R_MID;
+#endif /*FO_BIAS */
 	    me->p_speed = 0;	/* *** BAV *** */
             me->p_desspeed = 0;
             me->p_subspeed = 0;
@@ -378,6 +413,9 @@
         else{
 #endif
   	   do_goal(ORI);
+#ifdef FO_BIAS
+	   faceoffbias = -1;
+#endif /*FO_BIAS*/
 #ifdef OFFSIDE
 	}
 #endif
@@ -397,6 +435,10 @@
         else{
 #endif
            do_goal(KLI);
+#ifdef FO_BIAS
+	   faceoffbias = 1;
+#endif /*FO_BIAS*/
+
 #ifdef OFFSIDE
 	}
 #endif
@@ -949,11 +991,15 @@
     /*Place people on opposite sides of the rink*/
     if (j->p_team == KLI){
        j->p_x = track->t_x = SITOUT_X;
+#ifdef SITOUT_HURTS
        j->p_y = track->t_y = KLI_B + (random() % (2*DISPLACE) - DISPLACE);
+#endif /*SITOUT_HURTS */
     }
     else if (j->p_team == ORI){
        j->p_x = track->t_x = GWIDTH - SITOUT_X;
+#ifdef SITOUT_HURTS
        j->p_y = track->t_y = ORI_B + (random() % (2*DISPLACE) - DISPLACE);
+#endif /*SITOUT_HURTS*/
     }
     else 
        return;  /*Not ORI, not KLI, so do nothing... Weird*/
@@ -987,10 +1033,11 @@
     j->p_desspeed = 0;
     j->p_subspeed = 0;
     j->p_flags = PFSHIELD;               
+#ifdef SITOUT_HURTS
     j->p_fuel   = 0;                     /*Hah, you're hosed anyway */
     j->p_damage = j->p_ship.s_maxdamage - 5;
     j->p_shield = j->p_ship.s_maxshield; /*OK, a potential help     */
-
+#endif /*SITOUT_HURTS*/
   }
 
 void do_offsides(void)
@@ -1599,6 +1646,13 @@
 	    messAll(me->p_no,roboname,"#");
 	}
     }
+
+#ifdef PUCK_FIRST
+    if (sem_puck > -1) 
+      {
+	semop(sem_puck, sem_puck_op, 1);
+      }
+#endif /*PUCK_FIRST*/
     
     freeslot(me);
     freeslot(anncer);

_______________________________________________
vanilla-devel mailing list
vanilla-devel at us.netrek.org
https://mailman.real-time.com/mailman/listinfo/vanilla-devel