The implementation of an interactive gaming machine of “ Mafia Wars ”

This article describes the implementation of a gaming machine of “Mafia Wars” using Arduino UNO board and some other electrical components for the construction. The gaming machine is designed by the following items, such as game story setting, interactive elements for the game play, game art, state machine for the game process, coding, electrical components, and hardware construction, etc. There are INTRO, ROULETTE, SLAP, WAR and End Round states in this game. Some important interactive mechanisms with Arduino board for the gaming machine are designed and illustrated in this study. The hardware of the gaming machine consists of an Arduino UNO, a LCD screen, a photo resistor, several resistors, LEDs, buttons, plastic coins, game art decoration and the wood shielding box. Finally, the resultant functions of the gaming machine are tested by playing and the testing results demonstrate the good working performance.


Introduction
"Mafia Wars" is a multiplayer social network game developed by Zynga company."Mafia Wars" worked on Facebook and it was a popular game in which players start a mob family with their friends and run crime actions.The developers often added new weapons and features for the game to successfully aggregate more players.Aki Järvinen [1] has ever invastigated the game design of "Mafia Wars" game for its good social interactive properties and Samuel Greengard [2] stduied the influence of the popularity of virtual goods and currencies to the behavior of the players.Three years later, the sequel "Mafia Wars 2" was released in October 2011 but shut down in December 2012 by sequence.However, "Mafia Wars" has become a historic game.It is significant to develop a similar game machine with different interactive ways to play.In this study, an interactive game machine is designed and implemented.The name of the game machine is also called "Mafia Wars", because a similar game story to the former is adopted.The interactive ways of playing "Mafia Wars" gaming machine are developed for two players to fight with each other at the same time.

Concept of gaming machine (Gameplay) [3]
1.The game story is based on the "Mafia Wars" for players to act as a gangster leader.2. Goal: Keep alive and kill all the opposite members.3. Rules: A game round proceeds by "Roulette", "Slap" and "War" state cycle.At the beginning, "Roulette" state randomly produce a bingo condition for players to react, then "Slap" deals with the response from players to determin a winner, who can get a gun or cannon.Finally, the winner in "War" state has ability to shoot up, the defender should dodge well to avoid his gang member killed.4. Victory: When a player has finally no gang member alive, the game ends and he lose the game.The other one with gang members alive will be the winner.5.The roulette panel is formed by 6 LEDs arranged in a circle, it indicates the bingo conditions.6.The gaming machine consists of Arduino UNO, sensors, elecrical components, LCD display, roulette, push buttons and a buzzer to interact with players.7. The LCD display would show the corresponding information for each state.The gaming machine is constructed by a handmade wood box.8.The apperance of 3D design model for the gaming machine is shown as follows (Fig. 1): Fig. 1.The 3D design model of "Mafia Wars" game machine.

Game story
There was a mafia gang living in Madou town for many years.One day there came another mafia gang from a neighboring city.They often fight hardly when they encountered in the street.After some negotiations failure, the mafia gang bosses declared war to defeat the other gang.Only the winner can rule the town.Now you become the leader of a mafia gang and get 5 elite members.Your job is to eliminate other mafia gang by killing all of their elite gang members.But don't forget to escape from Town Sheriff (Police Car), and protect your member from Mad Bull.

Game Art
The characters and tools of Town Sheriff, Police Car, Mad Bull, Gun and Cannon are designed and sketched in Table 1.

Town Sheriff
Police Car Mad Bull Gun Cannon

Flow chart of gaming mechanism
A simple flow chart design for "Mafia Wars" gaming mechanism is illustrated as shown in Fig. 2. The game begins with Intro (intoduction), Roulette, Slap, War to End Round.

Finite-state machine of gaming mechanism
The above flow chart is then transformed to finite-state machine (FSM) [4] diagram for further coding as shown in Fig. 3. Intro, Rolette, Slap, War and End Round are recognized as states in the FSM diagram, in which the transition conditions are also clarified.1. "Intro" state: -Show title screen -Coin LED indicator turns on -Transition condition: When a coin is inserted, the state changes to "Roulette" state.
-Display and music: The display content and music for "Intro" state is shown in Fig. 4.
Fig. 4. Display and music contents for "Intro" state.

"Roulette" state:
-A game round starts -Flashing player current information -Roulette LEDs start to blink.
-Transition condition: When Roulette Machine has randomly created a "bingo", the game changes to "Slap" state.-Display and music: The display content and music for "Roulette" state are shown in Figure 5. BUZZ ROULETTE music maintains during the state.

"Slap" state:
-The players must react correctly and quickly to win the gun.Fig. 6 illustrates the "Slap" state bingo conditions for players to react.-The "Slap" state bingo conditions and the required actions are defined in Fig. 7.
-Game controller response definition for "Slap" state is shown in Fig. 8.
-The game will deal with the response from the players and then pick out the correct and the fastest one as the winner.If it is a draw, the game will proceed with a balancing algorithm to pick out a player as the winner.-The player who win the gun or cannon will be marked as the "ATTACKER" -Transition conditions: When there is a winner (got a gun or cannon), "Slap" state will change to "WAR" state, otherwise the game will change to "End Round" state.-Display and music: The display contents and music for "Slap"state are shown in Fig. 9.
BUZZ RESULT music is played when the competition results in a winner.

"End Round" state:
-Checking the situation to decide whether the game should create the next round or not.
-Round will always restart as long as both of the players have mafia member alive.
-Transition conditions: When both of the players have any mafia member alive, the state will change to "Roulette" state, otherwise, it change to "Intro" state.-Display and music: The LCD screen would show "Game Over" for a while as illustrated in Fig. 11 when the game goes to end.In the meanwhile, BUZZ GAME OVER music is played.

Mechanic with Arduino UNO
The Input handler subroutine, for example, is developed with analog1 for player 1 and analog2 for player 2, respectively.The simulation circuit layout and code is illustrated in Fig. 12.

Construction of gaming machine
The gaming machine is constructed by the hardware components within a handmade wood box.The bottom view photograph as shown in Fig. 13

Play testing
The resultant gaming machine is tested by actual playing.The test result demonstrates the desired functions work very well.The properties of playability are always considered as affected by the different elements of video game architecture [9,10].In this study, the intrinsic playability and mechanical playability of "Mafia Wars" gaming machine seem to be evaluated a high mark, however, interactive playability with common value, and artistic playability with low grade.

Discussion about interactive playability
The interactive playability design in the "Mafia Wars" gaming machine contains three stages from Roulette, Slap to War in a round.The players reflect a problem that the LCD screen is too small to recognize the bingo condition.It is thought that a lager LCD panel would provide a wide vision for recognizing.

Discussion about artistic playability
It is well known that the game art setting does influence the playability, which is called artistic playability.The players reflect the poor artistic features about the handmade box.It is thought that a delicate cover paste could beautify the appearance of the gaming machine.3D printing would be another way to obtain a good-looking appearance for the gaming machine.

Conclusions
The interactive gaming machine of "Mafia Wars" is designed and implemented.It provides a novel interactive method to players.A state diagram with FSM is helpful to coding development.The playing test result shows the functions woks well and the gameplay is benefit to all ages.But, it also shows the drawbacks in interactive playability and artistic playability.It is thought that a larger LCD screen, delicate cover and 3D printing could improve effectively.

Fig. 7 .
Fig. 7. Bingo conditions of "Slap" state and the corresponding required responses.

Fig. 9 .-
Fig. 9. Display contents of three phases and BUZZ RESULT music setting for "Slap" state.4."War" state:-The Attacker will choose which side he will attack depending on what weapon he carries.

Fig. 10 .
Fig. 10.Display contents of three phases and BUZZ RESULT music setting for "War" state.

Fig. 12 .
Fig. 12. Design circuit simulation layout and code for input handler.
reveals the Arduino UNO, 20x4 LCD I2C module, laser KY008 module x laser detector, electrical continuity, toy coin and the toy coin track, et al.The resultant gaming machine is shown in Fig. 14.

Fig. 13 .
Fig. 13.Bottom view reveals the hardware components and the construction.

Table 1 .
Game art of "Mafia Wars" gaming machine.