Monday, February 22, 2010

GamesChart Number 1 for 4 weeks!

When I first saw the announcement on “Flash Game Developers” group on about the GamesChart beta program I immediately thought to participate. It was a surprise to me to find that my game Haunted House was at first position for the entire 4 weeks of the beta program!
Actually also my Alice Memory game is also on the chart, even if never more than in the 6th position.

What GamesChart (www. is about?
It’s another way to generate money from you Flash games. The nice thing is that it is not an alternative to the traditional banner you place during the loading of the game. But it goes together.
The main idea is to have publisher to “bid” for which game will be in the chart and this will generate extra revenue to the developer, to the publisher who correctly bid and of course to the GamesChart organization.

This is from Barry White directly from linkedIn group.
I thought I'd include some more information about how GamesChart can earn developers money:

+ Every game that has the GamesChart API embedded in it is tracked by GamesChart.
+ The developer can also choose to enable or disable a series of dynamic charts that actually display within the Flash game itself.
+ The most popular games each week make their way to the top of the charts.
+ Any gamers who click on a game listed in these charts is taken to play that game on another portal.
+ Publishers use an advanced pay per click bidding system to purchase this traffic and drive users back to their own sites to play the games they have bid on.
+ Games need to be uploaded to the Publishers portal before they can receive traffic. (great for seeding)
+ Developers receive up to a 50% revenue share of any outbound clicks generated from within their game should they choose to display the charts. (also full blacklisting available)
+ Publishers also receive 10% of total revenues generated from any GamesChart enabled games featured on their site.

I am going to explain the very easy steps to follow to have a game added to this GamesChart.
In order to do so I am going to provide my other game Tokyo Train with this service as well.
First thing you need to register as developer, if you don’t already. This is quite easy to do, just follow instruction on the site.

You then are prompted to add a game:

So do not hesitate: go to click the button and create the new game:

Instructions are easy and nice to follow: I have to admit they did a very good job on make your job easy.

You are now prompted with the game id that you need to put on the component property to have your game identified.
Of course first of all you need to download the API library from the “GamesChart Wiki” link (
You have the choice to get the component for Adobe Flash IDE or the complete API if you use FlashDevelop and for both choices you can choose between AS3 and AS2. My choice was for the component and AS3.

The very first time you download the zip pack, you need to double click on the GamesChartAPI-AS3.mpx:

This will install the component, and that’s the only thing you really need to install: brilliant.
Now open your FLA and browse for the components (Windows > Components menu): you will find the GamesChartAPI one.

Now, again it’s easy: drag and drop the component onto the stage (better if at the top layer):

Do not worry about the position: it will be hidden once the game starts.
Do you remember the game id? Go to grab it and past it in the component inspector:

That’s all! You can now publish the game: you will notice a small G icon on top right of the stage.

You can force to have this cute icon can be hidden or display when you want. Or you can also move it.
I would suggest you to leave it for the entire game and in that position: it’s the best position, just readjust your buttons if you have any conflict.
In this way a player can click on the icon anytime during the game. This will let him vote your game and show chart. In fact when the icon is clicked the chart will appear and will let you open a new window with the games on the list.

You need one more thing: to publish the game. You can get your SWF file or you can first upload on MochiAds with version control as I am doing. This is the best solution because your game will be updated all over the world with the cute G icon.
That’s all!

PS.: I just discovered that Haunted House is no more on first position! So let’s go there and click the cute “G” icon!!

Sunday, January 3, 2010

Come2Play multiplayer API

After the development of my first two games Tokyo Train and Haunted house I am interested in development of a multiplayer game. For this reason I started to study the Come2Play API.

Links to the project:

The goal of the tutorial is to show how to build a Tic Tac Toe game using these API.

The project can be downloaded from

These API are basically used to have a communication between one or more clients (in Flash AS3) and the Come2Play server to allow a multiplayer game.

There are 2 type of functions: operations and callbacks.

I am going to use two classes.

- MainTTTC2P that extends ClientGameAPI. This is the main class the acts as controller

- TTTC2PViewer that is the viewer class. In some way, because the game is simple and it is for tutorial purpose, this will work as model as well.

I am not using an event driven approach as in the tutorials from come2play project because I found this confusing the main focus that is to learn how to use the basic API by come2play.

For any reference to the API this is the link:

Let’s start from MainTTTC2P class.

This class is created in the first frame of the FLA file:

var game:MainTTTC2P = new MainTTTC2P(this)

The class is declared as:

public class MainTTTC2P extends ClientGameAPI

In the constructor I am going to get the calling movieclip and calling the super constructor (the constructor of the basic class ClientGameAPI.

Moreover I pass this movieclip to my viewer class that is created here.

The call to doRegisterOnServer is the way for the client to enter the lobby for this game. The call to this function should be done using AS3_vs_AS2.waitForStage function.

public function MainTTTC2P(stageMovieClip:MovieClip)



theViewer = new TTTC2PViewer (stageMovieClip);

keyMove= 0;


}// constructor

private function constructGame(){

doRegisterOnServer();//registers your game on the server


The first callback function that is called is gotCustomInfo. You need to remember that the callback functions inherited by the basic class ClientGameAPI must be declared as “override”.

override public function gotCustomInfo (infoEntries:Array):void


this.myUserId = T.custom(CUSTOM_INFO_KEY_myUserId,null) as int;


On this function you get back some custom information. Calling the helper class T you can get some information back from the server. One simple example is to use the constant string “CUSTOM_INFO_KEY_myUserId” to get your user id. Because this is a important information it’s useful to get this stored.

Remember that each player will receive from the server a unique id to be identified. It’s critical for the client flash game to know the user id. In some how this is telling the program who is it.

The second callback function the client will receive is gotMatchStarted. This is triggered as soon as the game is started.

In this function the most important information is the list of the user ids for all the players. Again this is critical to know so this is stored in an internal variable.

I found useful as well store immediately where in this array the client is. This is done using the already stored information about my id.

Let’s have an example. If myUserId =41 and the array received is allPlayerIds=[41,42], this client has index 0 in the array while my opponent will have index 1. Therefore myUserIndex=0; This is another way to know who the client is, in terms of index in the array of all players.

This is the time where to start the new board using theViewer.startNewGame. The viewer class should also know what is myUserIndex, therefore I am going to store this on that class.

override public function gotMatchStarted (allPlayerIds:Array/*int*/, finishedPlayerIds:Array/*int*/, serverEntries:Array/*ServerEntry*/):void


this.allPlayerIds = allPlayerIds;

this.myUserIndex = allPlayerIds.indexOf(myUserId);





In this function I also start a loop using the ENTER_FRAME event. This is a function that will be called periodically with the fps set up in the FLA. This is a way to check if the viewer class has set up any new moves. This is an alternative to the event driven solution found in the come2play tutorials.

We will discuss this later.

The last function is used to define the first player. Because the game is in turns, only one player can make a move. Therefore this information must be set up.

A simple way is to define as starting player the first player in the index of all user ids. This information is stored in the currentturnIndexPlayer in the viewer class.

You need to think to the 2 clients that received the same array of the player ids (allPlayerIds). Therefore both clients have the user ids in order in this array: the first element of the array (allPlayerIds[0]) will be the same for both clients.

The serve must be notified by all clients about the current player. To do this each client must call the doAllSetTurn function. This is the way the server can be sure that all clients agreed to have one current player.

private function setupFirstPlayer() {

var firstPlayerIndex: int = 0;

theViewer.currentturnIndexPlayer = firstPlayerIndex;



It is time now to see the viewer class.

In the constructor the movieclip is stored.

Then the board is created. I found useful to have a linear array of 9 elements instead of a double array 3x3. The index of the linear array will be:

0 1 2

3 4 5

6 7 8

In order to display an empty square or a square filled with the “x” or with the “o” I have created a Movie Clip symbol called Square and I have exported for Actionscript.

In the frame=1 there is an empty square. In frame=2 there is the “x”, while in frame=3 there is the “o”.

To create a new symbol it’s just enough to create a new instance of the class Square:

var squareNew = new Square();

The I set up the Square movieclip in the right position and to the right frame (squareNew.gotoAndStop(EMPTYFRAME);). Then I add this new symbol to the stage and to an arrayOfSquares that I use to keep track of the clicked squares.

To be noted I have used a dynamic property called “myBoardIndex” to store the index of the movie clip in the board. For example the first movie clip (on the left top corner) will have myBoardIndex=0. The one in the center of the board will have myBoardIndex=4, etc.

public function TTTC2PViewer (stageMovieClip:MovieClip)


this.stageMovieClip = stageMovieClip;

arrayOfSquares = new Array(9);


var squareNew = new Square();



squareNew.myBoardIndex= i;


squareNew.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler);

arrayOfSquares[i] = squareNew;


squareClickedIndex = NOCLICKEDSQUARE;


}// constructor

Each movieclip is registered with a MOUSE_DOWN event. The called function is clickHandler.

public function clickHandler(event:MouseEvent){

if (!isMyTurn()) return;

var clicked:Square = as Square;

if ((arrayOfSquares[clicked.myBoardIndex].currentFrame)==EMPTYFRAME){


squareClickedIndex = clicked.myBoardIndex;



This function is immediately exit if it is not the turn of this client. This is done comparing the myUserIndex value with the currentturnIndexPlayer value.

public function isMyTurn():Boolean{

return (this.currentturnIndexPlayer==this.myUserIndex);


Then the target of the event is used to know which square was clicked. Only if the square is empty (that is checked using the currentFrame of the MovieClip then the square is changed calling the function setSquare (this function will be called to set the square also to set an opponent move). This is done simply using the procedure gotoAndStop to the playerIndex value (added by 2 because the first symbol “x” is to the frame 2 as you can see in the timeline for Square).

public function setSquare(playerIndex:int, squareIndex:int){



The last action on the clickHandler function is to set the variable squareClickedIndex to the index of the board (value from 0 to 8). Normally this variable is set to -1 to indicate that no click is yet made. As soon as this variable is set to a different value, this indicates the place in the board where the click was performed.

This is the signal that the main class will check in the polling cycle inside the timerHandler. Actually there are 2 condition must be fulfilled: must be my turn and the theViewer.squareClickedIndex must be different than -1 (=theViewer.NOCLICKEDSQUARE).

public function timerHandler(event:Event):void {

if ( theViewer.isMyTurn() && (theViewer.squareClickedIndex!=theViewer.NOCLICKEDSQUARE) )



If so the sendMoveToServer is called. The main purpose of this function is to send to the server the message that a move was made by the current player using the function doStoreState.

public function sendMoveToServer(){

var myKey = this.myUserId+"_"+this.keyMove;

var userEntry:UserEntry = UserEntry.create(myKey,theViewer.squareClickedIndex,false);

var userEntries:Array = new Array();



theViewer.squareClickedIndex = theViewer.NOCLICKEDSQUARE;



The doStoreState function needs only one parameter that must be an Array of type UserEntry. Actually the array can contain only one element.

To create a variable of type UserEntry the static function create is used:

UserEntry.create(theKey,theValue,isSecret) where:

- theKey must be unique if you want to store a new message. If you use a key already present this will override the previous one.

- theValue is the actual message that you want to send

- isSecret indicates if the other clients will be allowed to see the message sent

Both theKey and theValue can be any Object. There are different way to choose how to create the key and the value. My choise was the following:

For the key I created a String of this type “myUserId_keyMove” where keyMove is incremented at each move (at each click). So for example with player with id=41 the first key sent will be “41_0”, the second “41_1” etc... While for the opponent (with id=42 for example) will be “42_0”, “42_1”, etc…

The value will be simply the index of the board where the click was performed. This is the critical information to send to the opponent so that the opponent can display the square with the right symbol.

After sending the message to the server , the incremental keyMove variable is updated. And the theViewer.squareClickedIndex variable is set to -1 so that next time (and when it will be again my turn) it will be possible to click again.

Now that the message is sent let’s suppose to move to the opponent client. This client must receive the message and display the opponent’s symbol on the board on the right position (board index).

This is done in the gotStateChanged function where the server sends to the client the serverEntries array containing the moves in terms of ServerEntry elements.

Because we sent only 1 message, only the first element serverEntries[0] will be used.

In this variable the property storedByUserId is the id of the client who sent this message. Because the client who actually sent the message is also receiving this information, we need to check if the message was sent by the client itself. Only if this was sent by the opponent the function theViewer.setSquare is called to display the opponent symbol.

While the client who sent the message is not doing this simply because we already set this on the clickHandler function. That was a choice. An alternative would have been to set the symbol for the client itself after he received back the gotStateChange event from the server.

override public function gotStateChanged(serverEntries:Array):void


var serverEntry:ServerEntry = serverEntries[0];

if (serverEntry.storedByUserId != this.myUserId){ theViewer.setSquare(allPlayerIds.indexOf(serverEntry.storedByUserId),serverEntry.value); }


// CHECK if the game is over

var winnerIndex:int = theViewer.winnerPlayer();

if (winnerIndex>-1) {




In any case the setNextPlayerTurn is called. First thing the currentIndexPlayer is updated with the next player. This is simply done adding 1 and set back to 0 the index in case it’s greater than the allPlayerIds array length.

private function setNextPlayerTurn(){


if (theViewer.currentturnIndexPlayer >= allPlayerIds.length)

theViewer.currentturnIndexPlayer = 0;



Then the doAllSetTurn is sent to the server with the id of the new active player. It is also possible to set a maximum number of millisecond for the move (or -1 to ignore this).

This soAllSetTurn function must be called by all the clients to have any effect. And this is the reason why the gotStateChange function this is called from both clients. This is also useful to have both clients updated in terms of current player index.

The last action in the gotStateChange is to check if the game is over. If so the setupWinner function is called.

The main purpose of this function is to call the doAllEndMatch function to inform the server the game is ended. Again, as all the doAll…. functions, this must be called by all the players.

private function setupWinner(winnerIndex:int){

var finishedPlayers:Array = new Array();

var playerMatchOver:PlayerMatchOver;

for (var i:int=0; i

if ( i==winnerIndex ){

playerMatchOver= PlayerMatchOver.create(allPlayerIds[i],100,100);


playerMatchOver= PlayerMatchOver.create(allPlayerIds[i],0,0);






The parameter sent to the server must be an array of type PlayerMatchOver. Each element must contain the id of all players that have finished the game. In our case both players end the game simultaneously.

Therefore there is a loop in the allPlayeIds array to create a variable of type PlayerMatchOver. Again the static method “create” is used with 3 parameters:

- userId

- theScore. Set to 100 if the player wins and 0 if the player looses.

- thePot. The pot is used if the game allows players to bet during the game. In our case this will be 100% if the player wins, and 0% if the player looses.

Friday, April 4, 2008

Bruno Faidutti wrote an editorial on his website about the language in which he wrote the rules of his prototypes.
Basically he says that "I’ve even found out that even French publishers prefer English language prototypes, since they make easier to playtest the game with foreign publishers".
This is certainly a good point. But I think that there is another good reason: it easier to involve foreign playtesters.
I like to have the chance to send mine prototypes to a complete different gaming group, possibly in different country.
I remember that for Oltre Mare in the first version I sent to Henning Kropke in Germay. He planned to visit Mik Svellov in Copenahagen for some gaming sessions. So the proto of Oltre Mare received some playtests in the north of Europe before to be released. I had also a good preview from Mik in his website
before the fair!

At the moment I have a prototype who was sent to the Gathering of Friends and hopefully will be playtested. Moreover I will attendee the Bruno Faidutti's Ludophatic Gathering during the next weekend. In both case an english rule is a good point.

I have to admit, anyway, that the language in which I write new ideas that come out from playtesting sessions are just in Italian. I found easier to formilize these ideas in my native language. At least for the moment.
It maybe also depends of the fact that I usually share these ideas with my gaming group members that are Italian.


Ideas strike back

Some game ideas come backs, sometimes.

It's the case of a game I designed more than 2 years ago. I presented to a big publisher during the Essen fair. But it was reject in the same meeting during the explanation!
"It's a good theme, I like it. But there is too much components, and I do not like ..." (follows some explanations).
Well, things that happens!

I had a similar experience with another publisher who first said: "This game seems too similar to one we already got in our program. Please verify and let me know!". In this occasion at least I got a new game for my collection. I really never played that game, and it really was not so similar! Well, both games use an auction mechanism and have cards. But there are many others out there that are similar in this way! :-)
Almost one year later the same publisher decided to give it a try, after my assurance the game was not so similar! And after some tests they decided they like it and they will produce!

A very happy ending. But for the "too much components" prototype it was not the same!...
... Until few weeks ago when another publisher asked me if I have ready a game with some particular characteristics (I am not authorized to give any details for the moment)... They were not worried about the components, because in very few time of playtest they decide it was a good game...

Well, I have to admit that I worked hard during the Easter weekend (I forced my father to play it just after the Easter lunch :-P
I changed enough things to have a really better game... with the same components anyway! I was much more soddisfy than before, so in this case time elapsed without thinking of it was a good point! And let me have a more exciting game that hopefully will be published.

There is another prototype, for which I had very good feedback from my playtesters. But it was rejected from 3 different publishers... I think this project is almost 5 years old.
I have worked a lot to find a good solution to problems arose.
I think some months ago I found the real problem. My opinion is that, during the years, I changed several things without focusing on the real problem.
That problem give only one way to play for the best strategy removing a lot of fun to a quite complex game!
Now that I have, hopefully, found the right issue, I'm confident I can find the solution to have a nice game!

Sometime ideas come back... sometime we only need time...


Wednesday, March 5, 2008

Theme and Mechanisms

This post is a kind of reply to the very interesting post by Jonathan Degann "What is this boardgame about" I suggest to read here.
Several times we consider Eurogames to have a theme pasted up to a set of mechanisms. It is so easy to change the theme because what a game is about, in my opinion, is the set of rules defined for it.
One friend of mine called the physic class, during the highschool period, as "the most detailed role play game".
So we can see Tychoon theme completely changed into El Capitan. Or Ra changed in Razzia (by the way I found the Mafia theme that suites better than the egyptian one).
I compare Amytis to Amune-Re (just to stay with the same authors and similar themes :-) because in order to win you need to have a look to all the aspects you try to manage. In Amyitis you have several ways to score (even if it is essential to plant and to irrigate as Cyril said) and several things to do in order to score! I am not sure about the so called "star structure", but it is not the focus of the design in my opinion and it was introduced by Cyril to reply to the BGG post.
In Amun-Re you also have several ways to score.. "too much" someone can say, and who said that it doesn't matter what you do because you score for everything, I supposed have not clear the game (or miserably loose :-).
But I have to admit that in Amun-Re is easier to play than Amytis because it is simply more easy to have a one to one match for a rule to the theme.
In Amun-Re you bid to conquer territories. You buy bricks for building pyramids and you blind-bid for offer to the god. It is probably more "linear" than "star", but it surely easier to grab when you learn the game.
Maybe in Amytis there is only a problem with the theme and how it doesn't find an immediatly correpond to the rules. It is not so easy to remember that the carovan is used for the plantion. Why do I need to move the carovan in order to have a new platation? Even because with the carovan you can also gain one of the special cards as building the Babylon gate. So what have in common to build the gate with the creation of a platation portion of the garden? Apparently nothing, and most of all has no thematic approach to the carovan!
In my opinion these missed associations between rules and theme let some players find diffucult to grab the rules.
You can find the same easy approach to the theme association to the rule to other mentioned (in the Jonathan article) games such as Puerto Rico and Caylus.
In my Hermagor some players were disappointed to the fact that the fantasy theme was not well suited to the game mechanism. They probaly expected sheep and wood instead of egg's dragon and relic.
When I am asked about "first theme or first mechanism" during the design process, I surely reply with "first mechanism". So I start from one or more mechanisms I would like to have in my new game.
For instance in Il Principe I wanted to use the roles (as in Puerto Rico), while the Building Cards selection mechanism was inspired by King Breakfast.
But when I develop a game I try to think about the theme as soon as possible. Sometime I also change the theme not only rules during the playtesting.
Thinking to the theme helps me to develop the rules. In fact if I have to add or remove some rules, or if I need to round out some rule mechanisms or some score systems the theme helps me a lot. And this process gives a more chance to have a good connection between rules and the theme itself.


Friday, February 22, 2008

Solutions not Pathces

Last evening I playtested one prototype of mine with my friend Stefano.
It is a game from 2 to 4 players, so we tried a 2 player game. It was the second playtest (the first one was in 4).

I'm not going to describe the game here, but I would like to point out about an aspect of the game that was not working and how I want to try to solve it.
The problem is about the mechanism of the combat: it is the first time I'm working on a game where it is possible to have a fight between players.
So I am a little bit worried about, even because fighting is not excatly a typical german game mechanism...

During the playtest simply the combat doesn't occur. The main reason was that it was not neccessary to figth because we had enough space where to expand our villages whithout moving in conflict. Maybe the board was too big for 2 players, so that it could be resolved by a fine tuning of the dimension. Or maybe both our nature let us finding alternative strategy other than a fight.

Because the combat did not occur we also avoid to choose the "warrior cards" during all the game. Warrior cards were an option during a specific phase of the game where a player is prompted to choose between different actions. One of these actions is to "hire" warriors and it was never used. From a design point of view this phase were weaker because of the reduced number of choices.

As Knizia wrote in an interesting interview reported into the book "Rule of play" when something goes wrong during a playtest, you have to search for a good solution, not for a patch. He was talking about the playtest of his "The Lord of the Ring" collaborative game and how he found good solutions to resolve several problems all in once instead of applying a patch for each issue.

In my situation I had 2 main problems:
- the combat never occured
- the choice in a certain phase is less interesting (due to the avoiding of combat)

But the game was quite good even without fights! And Stefano convinced me to remove from the rules the possibility of a combat.

Instead of trying to make a patch for the two problems I would like to search an alternative solution where these problems are simply no more reported!

Let's assume that it is possible to play, with fun, without any combat as Stefano suggested.
In this case I still have the second problem to resolve: infact if I have no more combat I have no more "Warrior cards". So I have less choice.
I need more choices during this phase in order to give more spice to the game.

Another thing I had notice is the lack of a final score system. Up now I have a scoring during the end of each turn and an intermediate scoring during specific rounds, but still have no final score (for the end of the game).

I would like to resolve both lacks in once single way, as Dr Knizia teachs. So if I am able to introduce some actions useful for the final (or intermediate) score I maybe fix these problems.

Let's see in future playtests.


Thursday, February 14, 2008

Client side technology

Let's talk a bit about technology.
In this post I will talk only about the client part.
I have started my idea last year when I started a new job in Padova in Java web application. It was surely for me a return to a job I did several years ago (I worked with Microsoft tecnology in the meantime for non-web applications).
It was an opportunity to update my knowledge in the web development world.
I surprsly found something new: it was called Ajax. I don't want to talk in detail about Ajax because you can find a lot of tutorial on the web. I would only to note that the Asyncronous concept (the "A" from Ajax) is excatly what surprise me simply because it was what a normal web application lacked in order to become a game application!
Infact the "rough" of a web application (against the non-web applications) is that normally when you perform an action (a click on an image, or on a link) you see a page reload. That means a window flickering! That is excatly what makes a video game on web unplayable in terms of good feeling.
Moreover I learned about JavaScript framework such as Prototype and Scriptacolous and Mootools. These frameworks introduced a set of functions (a library) for specific grafic effects! The result is something unseen on a traditional web application. It is what now is called RIA: Rich Interent Application.
This was also possible thanks to the fact the main browsers (Internet Explorer 7, Firefox and Safari) became quite standard in interpreting JS and HTML.
So I started to learn these frameworks and the power of JavaScript and decided to try to develop a simply game using only JavaScript.
After almost a year I found this tecnology too difficult to use. I need to know a lot of CSS and DHTML other than JavaScript and the frameworks (I foucused on Mootools because seems really better than Scriptacolous).
Moreover debug JavaScript can become a nightmare!
In the meantime I discovery ActionScript 3.0 that is also known as Flash 9 and is included in the new Adobe Creative Suite. ActionScript 3.0 is a great evolution respect his preceding mainly because it is full Object Oriented. For a programmer who worked for more than 8 years using Object Oriented languages such as Java, C++ and C#, learning AS 3.0 is a joke!
AS 3.0 has also other advantages: the Flash player is a plugin that is mainly present in almost all the browser (and it is easy to install in any case). It easier to debug and to develop. And has a complete set of native objects really useful for videogames (but this is not a news of the 3.0 version).

So my target now is ActionScript 3.0. I worked for less than half time to have the same result I add in JavaScript.

Next time I will talk about the server side technology.