* Copyright (c) 1980 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)help.c 5.4 (Berkeley) 6/1/90";
** call starbase for help
** First, the closest starbase is selected. If there is a
** a starbase in your own quadrant, you are in good shape.
** This distance takes quadrant distances into account only.
** A magic number is computed based on the distance which acts
** as the probability that you will be rematerialized. You
** When it is determined that you should be able to be remater-
** ialized (i.e., when the probability thing mentioned above
** comes up positive), you are put into that quadrant (anywhere).
** Then, we try to see if there is a spot adjacent to the star-
** base. If not, you can't be rematerialized!!! Otherwise,
** it drops you there. It only tries five times to find a spot
** to drop you. After that, it's your problem.
{"first", "second", "third"};
/* check to see if calling for help is reasonable ... */
return (printf("Uhura: But Captain, we're already docked\n"));
return (printf("Uhura: I'm not getting any response from starbase\n"));
/* tut tut, there goes the score */
/* find the closest base */
if (Quad
[Ship
.quadx
][Ship
.quady
].bases
<= 0)
/* there isn't one in this quadrant */
for (i
= 0; i
< Now
.bases
; i
++)
dx
= Now
.base
[i
].x
- Ship
.quadx
;
dy
= Now
.base
[i
].y
- Ship
.quady
;
/* see if better than what we already have */
/* go to that quadrant */
Ship
.quadx
= Now
.base
[l
].x
;
Ship
.quady
= Now
.base
[l
].y
;
/* dematerialize the Enterprise */
Sect
[Ship
.sectx
][Ship
.secty
] = EMPTY
;
printf("Starbase in %d,%d responds\n", Ship
.quadx
, Ship
.quady
);
/* this next thing acts as a probability that it will work */
x
= pow(1.0 - pow(0.94, dist
), 0.3333333);
/* attempt to rematerialize */
printf("%s attempt to rematerialize ", Cntvect
[i
]);
/* ok, that's good. let's see if we can set her down */
dx
= Etc
.starbase
.x
+ ranf(3) - 1;
if (dx
< 0 || dx
>= NSECTS
)
dy
= Etc
.starbase
.y
+ ranf(3) - 1;
if (dy
< 0 || dy
>= NSECTS
|| Sect
[dx
][dy
] != EMPTY
)
/* found an empty spot */
Sect
[dx
][dy
] = Ship
.ship
;
/* the starbase must have been surrounded */
/* one, two, three strikes, you're out */