Forum ActionScript 3.0 Double-blind turn based game

Problems and discussions relating to ActionScript 3.0 here.

Double-blind turn based game

Postby AniMoney » June 17th, 2013, 2:11 am

My goal is to make a double-blind game, one where both players make their decisions privately and then they are both revealed simultaneously. A simple example would be rock-paper-scissors, a more complicated example would be Kongai on Kongregrate.

I somewhat understand how to a regular turn based game, where one player goes and then the other. I looked through the tic-tac-toe example to try to understand it. I got the gist of it but wish it was better commented, especially since I'm new to C#.

Could anyone help me out in how to set this up? If someone has a rock-papers-scissors example or something that'd be even better.
AniMoney
 
Posts: 13
Joined: November 26th, 2012, 9:21 am

Re: Double-blind turn based game

Postby jbrettob » June 22nd, 2013, 9:05 pm

That's an cool idea!

My guess of coding this would be like:
1) Client A & B should tell the server which actions are being executed via a message using connection.Send("EventMessageTypeName", properties);
2) when server received both events from both the clients A & B, then only send a new event to both client to execute the events.

Of course depending on what game your turn based game idea is, it can change a lot with the code. This is somewhat a basic idea for your double-blind turn based game.


For tic-tac-toe it would be:
1) Client A sends a move via a message to the server.
2) Server receives message from client A and send this message to Client B.
3) Client B receive the message from the server and execute the action.
4) Client B can set it's turn and repeat from step 1, until someone wins or the game has ended to a draw.


I don't have a lot of spare time these days, because of my own projects, so I can't help you a lot with some useful code.
Game Designer & Developer | Flash | AS3 | Unity3D | C#
w: jbrettob.com | blog: blog.jbrettob.com | @jbrettob
User avatar
jbrettob
 
Posts: 19
Joined: April 9th, 2012, 3:51 pm
Location: The Netherlands, Europe

Re: Double-blind turn based game

Postby AniMoney » June 29th, 2013, 4:17 am

I'm still having trouble getting it working, I'm trying to edit the Tic-Tac-Toe project to make it a double-blind game instead, but I'm not very familiar with using MonoDevelop.
AniMoney
 
Posts: 13
Joined: November 26th, 2012, 9:21 am

Re: Double-blind turn based game

Postby AniMoney » July 1st, 2013, 7:13 am

I'm having a problem. I'm working on a mac using Xamarin (similar to monodevelop), and when I'm on the development server I get this problem. I will have one player create a room in the lobby, but my serverside code will initialize the player twice for some reason.

here is the relevant snippet from my serverside code, it's modified straight from the code in the tic tac toe example:
Code: Select all
      private void joinGame(Player user)
      {
         if(player1 == null)
         {
            Console.WriteLine ("There is no player1, so initializing a client as player 1.");
            user.Send("init", 0, user.ConnectUserId);
            player1 = user;
         }
         else if(player2 == null)
         {
            Console.WriteLine ("There is no player2, so initializing a client as player 2.");
            user.Send("init", 1, user.ConnectUserId);
            player2 = user;
         }
         else
         {
            Console.WriteLine ("Both players already exist, so adding client as spectator.");
            //Send current game state to spectators
            user.Send("spectator", player1.ConnectUserId, player2.ConnectUserId);
            return;
         }

         if(player1 != null && player2 != null)
         {
            Broadcast("join", player1.ConnectUserId, player2.ConnectUserId);
            user.Send("join", player1.ConnectUserId, player2.ConnectUserId);
            resetGame(user);
         }
      }


So I'll build and run the server, then open up my .swf (just one copy!) and create a room, and I'll get this output in my server

[01:57:34 in 'hxfmdcrpaku5mRUu3bn5gg'] => There is no player1, so initializing a client as player 1.
[01:57:34 in 'hxfmdcrpaku5mRUu3bn5gg'] => There is no player2, so initializing a client as player 2.

I don't get why this is happening. There is only one client connected but it seems to be calling the joinGame function twice? However when I uploaded the .dll to player.io and ran it off their server I didn't get this problem. I'm really getting fed up with Xamarin/MonoDevelop.
AniMoney
 
Posts: 13
Joined: November 26th, 2012, 9:21 am

Re: Double-blind turn based game

Postby AniMoney » July 1st, 2013, 7:17 am

Also I get this error in my console, but then it seems to run fine after. Do I need to use a different version of mono or open some ports or something? I've done some as3 programming before but I'm brand new to networking and I'm pretty lost with these errors. Any help is greatly appreciated.

Loaded assembly: /Users/AniMittra/Flash/DoubleBlind/ServersideCode/Player.IO Test Server Project/bin/Debug/Test Server.exe
Loaded assembly: /Users/AniMittra/Flash/DoubleBlind/ServersideCode/Player.IO Test Server Project/bin/Debug/Player.IO Development Server.exe [External]
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll [External]
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll [External]
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll [External]
Loaded assembly: /Users/AniMittra/Flash/DoubleBlind/ServersideCode/Player.IO Test Server Project/bin/Debug/Player.IO GameLibrary.dll [External]
Thread started: #2
Thread started: #3
[02:13:22] Starting Development Server (v2.3.6.0)
ARG!: + System.UnauthorizedAccessException: Access to the path "/usr/share/GameServerCache" is denied.
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00064] in /private/tmp/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.12/_build/mono-2.10.12.git/mcs/class/corlib/System.IO/Directory.cs:118
at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in /private/tmp/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.12/_build/mono-2.10.12.git/mcs/class/corlib/System.IO/Directory.cs:83
at PlayerIO.ServerCore.identifier31.getCached[String] (System.String name, System.Func`1 create) [0x00000] in <filename unknown>:0
ARG!: + System.UnauthorizedAccessException: Access to the path "/usr/share/GameServerCache" is denied.
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00064] in /private/tmp/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.12/_build/mono-2.10.12.git/mcs/class/corlib/System.IO/Directory.cs:118
at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in /private/tmp/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.12/_build/mono-2.10.12.git/mcs/class/corlib/System.IO/Directory.cs:83
at PlayerIO.ServerCore.identifier31.getCached[identifier32] (System.String name, System.Func`1 create) [0x00000] in <filename unknown>:0
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/gac/System.Management/4.0.0.0__b03f5f7f11d50a3a/System.Management.dll [External]
ARG!: + System.UnauthorizedAccessException: Access to the path "/usr/share/GameServerCache" is denied.
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00064] in /private/tmp/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.12/_build/mono-2.10.12.git/mcs/class/corlib/System.IO/Directory.cs:118
at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in /private/tmp/source/bockbuild/profiles/mono-2-10/build-root/mono-2.10.12/_build/mono-2.10.12.git/mcs/class/corlib/System.IO/Directory.cs:83
at PlayerIO.ServerCore.identifier31.getCached[identifier33] (System.String name, System.Func`1 create) [0x00000] in <filename unknown>:0
Thread started: #4
Thread started: <Thread Pool> #5
Thread started: <Thread Pool> #6
Thread started: <Thread Pool> #7
Thread started: <Thread Pool> #8
[02:13:22] PolicyServer Error: Unable to start Flash policy server on port 843. Details: Access denied (Local Endpoint: 0.0.0.0:843)
[02:13:22] PolicyServer Error: Unable to start Silverlight policy server on port 943. Details: Access denied (Local Endpoint: 0.0.0.0:943)
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll [External]
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/2.10.12/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll [External]
[02:13:22] Server started. Logged in with account: AniMoney
Thread started: #9
Thread started: #10
Loaded assembly: /private/var/folders/oh/ohlHhGPOGEOOQGcE-YQhqU+++TI/-Tmp-/tempgame-86f1eefcabbe437cba115331ada1964e.dll
[02:13:23]
[02:13:23] Trying last loaded dll
[02:13:23]
[02:13:23] Using Game Dll: GameCode.dll
[02:13:23] ========================
[02:13:23] (dll: /Users/AniMittra/Flash/DoubleBlind/ServersideCode/Player.IO Test Server Project/bin/Debug/GameCode.dll)
AniMoney
 
Posts: 13
Joined: November 26th, 2012, 9:21 am

Re: Double-blind turn based game

Postby Henrik » July 1st, 2013, 7:59 am

AniMoney wrote:ARG!: + System.UnauthorizedAccessException: Access to the path "/usr/share/GameServerCache" is denied.

That's a file system permission error. You, or the user MonoDevelop is running as, doesn't have permissions to create that directory.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Double-blind turn based game

Postby AniMoney » July 1st, 2013, 10:01 am

Henrik wrote:
AniMoney wrote:ARG!: + System.UnauthorizedAccessException: Access to the path "/usr/share/GameServerCache" is denied.

That's a file system permission error. You, or the user MonoDevelop is running as, doesn't have permissions to create that directory.


I am on a MacBook Pro and I am the only user account, and therefore the admin, so it shouldn't be an admin privileges issue. I'm still getting that output in my console but it seems to be working anyways? I've sort of fixed the problem of it initializing one client twice by deleting the old .dll and updating the assembly settings. It works most of the time now, but still once in a while it will add one client as player 1 and 2. I really don't know why, perhaps it's registering two clicks on the create room button in the .swf or something, I'm stumped.
AniMoney
 
Posts: 13
Joined: November 26th, 2012, 9:21 am


Return to ActionScript 3.0



cron