discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNUstep cookbook: DO: Connect four.


From: Marko Riedel
Subject: GNUstep cookbook: DO: Connect four.
Date: Wed, 27 Oct 2004 16:36:26 +0200

Hi all,

I have added a new recipe to the cookbook. It uses distributed objects
to let two human players play connect four over the network. It is
based on the DO tutorials by Nicola Pero and Adam Fedor. I tested it
in a number of different settings and hope that it will work at your
end too.

The URL is http://www.gnustep.it/marko/.

Here is an excerpt from the cookbook that describes the recipe:

The idea behind this recipe is very simple: implement an application
that allows two human players to play ``connect four'' over the
network. The program displays the board to each player, who may drop
chips of his own color in any one of the seven columns. The player who
is the first to obtain four chips along a horizontal, vertical, or
diagonal line, wins the game. The application detects a win and uses
an alert panel to inform the players that the game is over. It also
detects ties. The application has three states: ``my turn'',
``opponent's turn'' and ``game over.''

This game provides an opportunity to illustrate the use of distributed
objects (DO) in an easy-to-understand application. There are two
classes: a controller that interacts with the application object
through delegation and a subclass of {\tt NSView} that implements the
board and the ``connect four'' functionality. There is one instance of
the board, which the controller vends to the network so that the
opponent may invoke methods to restart or quit the game, and record a
move, all of it through a proxy. These methods are grouped in the
protocol ``connect four.'' The protocol works both ways: each player
has a proxy of his opponent's board and uses it to communicate moves
and restart or quit events to the process of his opponent. The
connection is bi-directional rather than client-server. The name
chosen by the controller to vend the board object has the form
``connectfour-user-color'', where ``user'' is the name of the user
playing the game and ``color'' is the color the user chose (red or
yellow, red begins). Start the game from the command line like this:

         openapp DOConnectFour.app/ red 172.16.1.150 riedel


Let me know if there are any problems with the TGZ or ZIP files or the
recipe itself. BTW Nicolas -- maybe it's time for a new web edition?
That would be terrific.


Best regards,

Marko Riedel


-- 
+------------------------------------------------------------+
| Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de |
| http://www.geocities.com/markoriedelde/index.html          |
+------------------------------------------------------------+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]