Silverfrost Forums

Welcome to our forums

Client-Server game of TicTacToe?

26 Oct 2012 6:56 #10924

Best way to realize two player Client-Server game of TicTacToe using FTN95, ClearWin+ and .NET?

I have written this game before for Inferno using Limbo programming language. It was quite easy task because of lightweight threads (procs), blocking channels for thread synchronization + communication and filesystem interface for network sockets.

Available here, if someone is interested

For FTN95-version of a game I thought about using .NET framework for threading and socket connection handling.

For server, I guess I will be using three threads:

UI_thread: Handles user interaction. Starts the Listen_thread (don't want to block the UI_thread).

Listen_thread: Listens and accept opponents connection. Starts the Worker_thread and then goes away.

Worker_thread: Handles opponents connection, moves and messages.

For player turn and thread synchronization, I thought about using just a variable:

Lets name the variable: lambda

Lambda can have values: '1' or '-1'.

'1' means local players turn and '-1' means opponents turn. If we mark the local players pieces on the game board with '1' and opponents pieces with '-1', then we can test if a game piece on the board belongs to the current player or for the opponent by just multiplying piece value by lambda. Positive value means current player and negative value means opponent. So, no need for separate testing functions for each player.

Since lamba variable needs to be accessed from the two different threads: UI_thread and Worker_thread, is it enough just to use LOCK when writing to a variable or do I need more sophisticated locking?

5 Nov 2012 8:11 #10974

Inferno Limbo...hollly....Experience says that the more marginal languages program uses the less will be its lifespan. The same functionality using only Clearwin/Fortran and may be just a Netcat or other client-server DLL wrapped into Fortran and only Fortran would be really interesting. Something alone the lines like in here https://forums.silverfrost.com/Forum/Topic/1169

Please login to reply.