[comp.sources.games.bugs] Lunar Lander

jt1o+@andrew.cmu.edu (Joseph L. Traub) (05/31/89)

I have a small problem with Lunar Lander.  The values M_PI and M_PI_2 are never
defined, and I don't know what they should be.  I am assuming that they are
3.14159 and 2 * 3.14159, but I would like a response to tell me what they shouldreally be.
Thanx in advance.
Joe Traub
jt1o@andrew.cmu.edu

falk@sun.Eng.Sun.COM (Ed Falk) (06/01/89)

In article <AYUnOZ200Xo=M41klw@andrew.cmu.edu>, jt1o+@andrew.cmu.edu (Joseph L. Traub) writes:
> 
> I have a small problem with Lunar Lander.  The values M_PI and M_PI_2
> are never defined, and I don't know what they should be.  I am assuming
> that they are 3.14159 and 2 * 3.14159, but I would like a response to
> tell me what they should really be.

They should be defined in <math.h>

-- 
		-ed falk, sun microsystems
		 sun!falk, falk@sun.com
		 card-carrying ACLU member.

tar@sirius.cis.ksu.edu (Tim Ramsey) (06/01/89)

In article <107518@sun.Eng.Sun.COM> falk@sun.Eng.Sun.COM (Ed Falk) writes:
>In article <AYUnOZ200Xo=M41klw@andrew.cmu.edu>, jt1o+@andrew.cmu.edu (Joseph L. Traub) writes:

>> I have a small problem with Lunar Lander.  The values M_PI and M_PI_2
>> are never defined, and I don't know what they should be.  I am assuming
>> that they are 3.14159 and 2 * 3.14159, but I would like a response to
>> tell me what they should really be.

>They should be defined in <math.h>

Not under System V, they aren't (at least ATT SysV Rel3.1).  Here's what
I used, and everything seems to be working fine:

#define M_PI	3.14159265358979323846
#define M_PI_2	1.57079632679489661923

Tim
--
Timothy Ramsey                               Kansas State University
BITNET:   tar@KSUVAX1              Dept. of Computing and Information Sciences
Internet: tar@ksuvax1.cis.ksu.edu
UUCP:  ...!{rutgers,texbell}!ksuvax1!tar       HUNT!  HUNT!  HUNT!

hanst@maestro.htsa.aha.nl (Hans Trompert) (06/01/89)

In article <107518@sun.Eng.Sun.COM> falk@sun.Eng.Sun.COM (Ed Falk) writes:
-> andrew (Joseph L. Traub) writes:
->-> The values M_PI and M_PI_2 are never defined. I am assuming
->-> that they are 3.14159 and 2 * 3.14159.
-> They should be defined in <math.h>

They are NOT defined in <math.h>, but we included the following in land.c:
#define M_PI        3.141592654
#define M_PI_2      9.869604404
And it seems to work (it's a fun game).
-- 
)!&@%^$!@&(^*$*!&@^%$()!@&#$*)&(^A%()*&()*^%*()&!@$(*&@(!%*)&(*&@%*(&%(*&!%&*(*
& Hans Trompert                             # Disclaimer:                     %
| Algemene Hogeschool Amsterdam             ~     I don't know, you can shoot ^
\ Technische en Maritieme Faculteit         )     me in the partylights !     #
% E-mail: hanst@maestro.htsa.aha.nl         !     (partylights not included)  )
!@&*&^%_)@!%*@!&)^*&@$&^%!_(@$+~_@$+_)@!($+)_@!%$&@$(~)!@&+@%+)@!&+%)$(@+*&()$+

hans@duttnph.UUCP (Hans Buurman) (06/02/89)

In article <953@maestro.htsa.aha.nl> hanst@htsa.UUCP (Hans Trompert) writes:
>In article <107518@sun.Eng.Sun.COM> falk@sun.Eng.Sun.COM (Ed Falk) writes:
>-> andrew (Joseph L. Traub) writes:
>->-> The values M_PI and M_PI_2 are never defined. I am assuming
>->-> that they are 3.14159 and 2 * 3.14159.
>-> They should be defined in <math.h>
>They are NOT defined in <math.h>, but we included the following in land.c:
>#define M_PI        3.141592654
>#define M_PI_2      9.869604404

On a Sun running SunOs 4.0:
grep M_PI /usr/include/math.h

#define M_PI	3.14159265358979323846
#define M_PI_2	1.57079632679489661923
#define M_PI_4	0.78539816339744830962

Sorry. And I don't even run LL !
-----------------------------------------------------------------------------
Hans Buurman                   | hans@duttnph.UUCP
Pattern Recognition Group      |
Faculty of Applied Physics     | mcvax!hp4nl!dutrun!duttnph!hans
Delft University of Technology | tel. 31 - (0) 15 - 78 46 94

jeffs@wjvax.UUCP (Jeffery Siou) (06/02/89)

In article <2042@deimos.cis.ksu.edu> tar@sirius.cis.ksu.edu (Tim Ramsey) writes:
>In article <107518@sun.Eng.Sun.COM> falk@sun.Eng.Sun.COM (Ed Falk) writes:
>>In article <AYUnOZ200Xo=M41klw@andrew.cmu.edu>, jt1o+@andrew.cmu.edu (Joseph L. Traub) writes:
>
>>> I have a small problem with Lunar Lander.  The values M_PI and M_PI_2
>>> are never defined, and I don't know what they should be.  I am assuming
>>> that they are 3.14159 and 2 * 3.14159, but I would like a response to
>>> tell me what they should really be.
>
>>They should be defined in <math.h>
>
>Not under System V, they aren't (at least ATT SysV Rel3.1).  Here's what
>I used, and everything seems to be working fine:
>
>#define M_PI	3.14159265358979323846
>#define M_PI_2	1.57079632679489661923
>

 Well I've redefined the above M_PI and M_PI_2 and I got futher in my compiling
of the game, but now I've come across another problem,

  At the end of the compiling I get the message:

 _memset undefined


 What's wrong?   I know little to nothing about C programming except possibly
 compiling C sources.

 If someone could help me out, it would be greatly appreciated.

 Thanks in advance.



+---------------------------------------------------------------------------+
|  jeffery siou                                                             |
|  ...!{ !decwrl!qubix, ames!oliveb!tymix, pyramid}!wjvax!jeffs             |
|                                                                           |
|  the above opinions are mine alone and not, in any way, those of WJ.      |
|                                                                           |
+---------------------------------------------------------------------------+
|

bhj@bhjat.UUCP (Burt Janz) (06/03/89)

Here's an extract from ENIX math.h.  ENIX is System V.3.2.

(much other stuff omitted)
/* some useful constants */
#define M_PI	3.14159265358979323846
#define M_PI_2	1.57079632679489661923
#define M_PI_4	0.78539816339744830962
#define M_1_PI	0.31830988618379067154
#define M_2_PI	0.63661977236758134308
#define M_2_SQRTPI	1.12837916709551257390

Burt Janz

hayashi@ws.sony.junet (Kazunori Hayashi) (06/04/89)

In article <1571@wjvax.UUCP>,
	jeffs@wjvax.UUCP (Jeffery Siou) says:
>  Well I've redefined the above M_PI and M_PI_2 and I got futher in my compiling
> of the game, but now I've come across another problem,
> 
>   At the end of the compiling I get the message:
> 
>  _memset undefined
> 

	Memset is a routine which is supported in library on SYS-V.
	And BSD supports it as compat-sys5 in its library.
	Its specification is as follows:

	  memset(addr, fillchar, size)
		char	*s;
		int	fillchar, size;

	  The memset fills memories (first `size' starting at `addr') with
	  `fillchar', and returns `addr'.

	  Actual C-program may be:
--- CUT HERE ---
char *
memset(addr, fillchar, size)
	register char	*addr;
	register int	fillchar, size;
{

	addr += size;
	while (size-- > 0) {
		*--addr = fillchar;
	}

	return (addr);
}
--- CUT HERE ---

===
	Kazunori Hayashi
	Workstation Div. Supermicro Systems Group
	Sony Corporation
	6-7-35, Kitashinagawa
	Shinagawa-ku, Tokyo, 141 Japan
	hayashi@ws.sony.junet
	tel: 03-448-4015
	fax: 03-448-4216

hayashi@ws.sony.junet (Kazunori Hayashi) (06/04/89)

	I found minor BUG in Lunar Lander.
	In the source, it tries to open the score file two times
	at a time.  So, open file count will increase by one,
	every time you try to write the score file.
	It may cause EMFILE (Too many open file) to continue playing
	this game. But I've never tried, because, in our system,
	max open file count is 64.


void ScWrite(back_win)

WINDOW *back_win;

	{
	int items;
	FILE *fp;
	char *user;
	score_t score_pad[HS_ENTRIES + 1];
	void qsort();
	char *getenv();

	if (Score == 0)
		return;
*1	if ((fp = fopen(HSFile, "r")) == NULL)
		{
		ScDisplayErr(back_win, "Unable to read HS file.");
		ScDisplayErr(back_win, "Attempting to create HS file.");
		if (creat(HSFile, 0777) == -1)
			{
			ScDisplayErr(back_win,
			    "Unable to create HS file, check pathname.");
			return;
			}
		}
*2	if ((fp = fopen(HSFile, "r")) == NULL)
		{
		ScDisplayErr(back_win, "Unable to read new HS file.");
		return;
		}
	items = fread((char *)score_pad, sizeof(score_t), HS_ENTRIES, fp);
*1	fclose(fp);

+++++++++ This shoud be

	if ((fp = fopen(HSFile, "r")) == NULL)
		{
		ScDisplayErr(back_win, "Unable to read HS file.");
		ScDisplayErr(back_win, "Attempting to create HS file.");
		if (creat(HSFile, 0777) == -1)
			{
			ScDisplayErr(back_win,
			    "Unable to create HS file, check pathname.");
			return;
			}
!		if ((fp = fopen(HSFile, "r")) == NULL)
!			{
!			ScDisplayErr(back_win, "Unable to read new HS file.");
!			return;
!			}
		}
	items = fread((char *)score_pad, sizeof(score_t), HS_ENTRIES, fp);
	fclose(fp);

===
	Kazunori Hayashi
	Workstation Div. Supermicro Systems Group
	Sony Corporation
	6-7-35, Kitashinagawa
	Shinagawa-ku, Tokyo, 141 Japan
	hayashi@ws.sony.junet
	tel: 03-448-4015
	fax: 03-448-4216