[mercury-users] Mercury Coding Challenge - Battleships

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Jan 31 10:04:03 AEDT 1999


On 30-Jan-1999, Ralph Becket <rwab1 at cam.sri.com> wrote:
> Peter Ross wrote on 18 Jan:
> > 
> > The challenge consists of implementing a server and players for the game
> > battleships.  For more information download battleships.tar.gz from
> > http://www.cs.mu.oz.au/research/mercury/download/files/battleships/
> 
> I've been having a go at this and got to the point where using random
> numbers would be fun for the robot player.  However, the modes for the
> random module and the modes for the player/1 typeclass predicates mean
> they can't be used together.  Player state is handled by threading
> (T::in, T::out) <= player(T) pairs throughout the player/1 interface.
> The random module predicates, on the other hand, are threaded with
> (random__supply::mdi, random__supply::muo) arguments.  Now I can't see
> a way of making a random__supply object part of a player/1 instance
> and satisfy the mode requirements of both the random module and the
> player/1 interface.  Tricky.

You can do this using copy/1 to make a new unique copy of the random__supply.
Not the most elegant solution, perhaps, but it should work.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh>  |   but source code lives forever"
PGP: finger fjh at 128.250.37.3        |     -- leaked Microsoft memo.



More information about the users mailing list