[plt-scheme] another game: pacman

From: Nikolay Artamonov (artamonov at newecoalt.ru)
Date: Fri Aug 18 07:43:07 EDT 2006

Hi all!

> Nice!  It worked out of the box for me, which is incredible
> (load of stuff doesn't work on my Linux box).  Game play
> was smooth, except for a few random pauses which I assume
> were caused by GC.
> I've had to write many similar programs for my PhD work,
> and I quite like the communicating sequential processes
> (CSP) style for this sort of system.  In the CSP style you
> have a bunch of threads that communicate via channels.  For
> Pacman you'd have a game world thread, threads for each
> ghost, and a thread for the player.  The game world thread
> is the boss and tells the other threads when to stop and
> start, and when to perform particular actions.  The other
> threads response to commands from the game world thread. 
> Each thread is a tail recursive loop. I find this style
> much easier to program reactive systems in than OO style. 
> There is much less explicit state, and you get your main
> loop back.  [This is basically the Erlang style, and also
> very similar to FRP]

I am relative newbie in the world of Scheme and MzScheme implementation. 
And now I am very interesting in ascertaining how is Scheme (in common 
sense) and MzScheme (in particular) matching to usage in production 
applications (not research, not experimental, and so on).

I tested pacman game and can't understand "a few random pauses", that 
was mentioned by Noel. My PC has PIV-1,6 Ghz with 512 Mb RAM + Win 2k3. 
And every 3-4 seconds game becomes "frozen" for nearly 1 second and game 
process continues. Then after 3-4 seconds game again suspends and then 
again continues. Ans so on.

Noel said that this is caused by GC. But is it normal? Pacman is very 
simple game. And I think that another similar game in Java, or even 
Python, will not interrupted by GC in such _explicit_ way (of cource, GC 
will work anyway, but more quickly). Even more: programmers write 
3D-games with Java! How it is possible to write applications with Scheme 
(and with MzScheme in particular) with predictable and smooth runtime 

May be it is not very good GC implementation in MzScheme? In that case 
can you advise me alternative scheme implementation with more friendly 
GC and more quickly runtime process?

May be any scheme implementations today are not so mature for production 

Thank you and excuse me if my questions are very naive.

Nikolay Artamonov

Posted on the users mailing list.