My first Hollywood based network game

Discuss any general programming issues here
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

My first Hollywood based network game

Post by jalih »

Hi all,

Since nobody volunteered to write the first Hollywood based network game and release the sources... ;-)

I still need to write a proper user interface for the game before releasing it. Networking part and game logic section is allready working fine. Special thanks goes to Bugala for sponsoring me the Hollywood 5 update!

Connected to and playing against my Inferno based server program
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

Re: My first Hollywood based network game

Post by xabierpayet »

can you put some source code?
i´m sure that will be very useful why the network chapter in the hollywood guide is not very well explained, lack of examples.
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: My first Hollywood based network game

Post by jalih »

xabierpayet wrote:can you put some source code?.
I will post the sources soon, when it's finished...

This game is quite simple to make, really:

Game board is stored in a two dimensional table. We make the table internally a little bit bigger than the real game board because we want to add extra border around the board edges. This is done, so we can save some comparisons when checking the winning position. There is no need to check if we are at the edge of the board. Extra border around the board will always terminate a search anyway.

Local player input is simply handled by building the game board grid as buttons and using event handler for handling the button presses. We simply use SendData() function to send the move as a line of text consisting button id to remote player. Remote player input is handled by using event handler for "OnReceiveData" event.

Synchronizing game turns is also simple. We use variable, which can have two states: 1 and -1. This variable is often called lambda and can have some clever uses. For an example we can use the same procedure for testing our own pieces and enemy's pieces in a game. If player1 plays on positive lambda with positive pieces and player2 plays on negative lambda with negative pieces, we can multiply value of the piece on board with lambda and result is always positive if the piece is owned by player whose turn it is.
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

Re: My first Hollywood based network game

Post by xabierpayet »

nice example, i will try it in my strategus game xD
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: My first Hollywood based network game

Post by jalih »

Almost finished... :)

Now game server and client are both Hollywood based and working nicely. Just need to draw better user interface and add some status texts, like turn indicators and connection status for an example.

Current status of the Hollywood Tic-Tac-Toe
tolkien
Posts: 190
Joined: Sun Oct 17, 2010 10:40 pm
Location: Spain

Re: My first Hollywood based network game

Post by tolkien »

Perfect explaining. Thanks you! We need more!
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: My first Hollywood based network game

Post by jalih »

I will try to add missing functionality later today and post the sources...

Meanwhile you can test these AmigaOS4 binaries and check, if you can break the networking stuff.

Note: uses port 2000 for networking.
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: My first Hollywood based network game

Post by jalih »

Sources available here

Written in a hurry... Code could use some comments, more structuring and procedures. I hope it helps someone... :D
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

Re: My first Hollywood based network game

Post by xabierpayet »

hello jalih, i have a timeout error ever when i try to connect with the client to the server, i need put an special hostname or else?
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: My first Hollywood based network game

Post by jalih »

jalih wrote:Sources available here
There is a small typo error in Client:

On button_handler(), change:

Code: Select all

Repeat				
	Local str$, ok = StringRequest("Connect to host", "Enter hostname:")
	If StrLen(str$) <> 0 Then Break
	If ok = False Then Return
Forever
To:

Code: Select all

Local str$, ok

Repeat				
	str$, ok = StringRequest("Connect to host", "Enter hostname:")
	If StrLen(str$) <> 0 Then Break
	If ok = False Then Return
Forever
I just noticed... Seems like Hollywood defaults to local host if address is Nil.

I will fix sources later today and will probably add double buffering as well.
Post Reply