Difference between revisions of "Chess Game Example"
(15 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This is a protected page for the Chess Game Example. | This is a protected page for the Chess Game Example. | ||
− | The '''chess game example''' demonstrates the creation of a chess game for two-players. | + | This project was carried out by Jaysree Nair and Michal Gordon, in 2013. |
− | This example demonstrates LSCs creation in two different ways, which also generates different LSCs: | + | |
− | + | The '''chess game example''' demonstrates the creation of a chess game for two-players. Chess game has many rules which we have implemented in this example, see [[http://en.wikipedia.org/wiki/Chess chess]]. On his turn, the user plays by mouse clicking the game pieces and the chess board's squares. A click on a square highlights valid user moves for the selected piece. The game GUI is implemented with [http://en.wikipedia.org/wiki/Swing_(Java) Swing], and the game behavior is implemented with LSCs. This example demonstrates LSCs creation in two different ways, which also generates different LSCs: <br> | |
− | + | # Using the [[PlayGo_Feature_List#Natural_language_play-in | natural language interface to LSCs]] (NL-Play-In). | |
+ | # Using the LSC Editor. | ||
== Game Board == | == Game Board == | ||
Line 12: | Line 13: | ||
<br> | <br> | ||
+ | <br> | ||
− | == Example 1 | + | == Example 1 with NL-Play-In == |
− | The LSCs in this section were created | + | The LSCs in this section were created using [[PlayGo Feature List#Natural_language_play-in|NL-Play-In]]. |
<br> | <br> | ||
Line 22: | Line 24: | ||
|- | |- | ||
! scope="col" width="15%" | Name | ! scope="col" width="15%" | Name | ||
− | ! scope="col" width="70%" | Natural Language Text | + | ! scope="col" width="70%" | Requirement in Natural Language Text |
! scope="col" width="15%" | LSC | ! scope="col" width="15%" | LSC | ||
|- | |- | ||
Line 85: | Line 87: | ||
|- | |- | ||
− | | BlkKingPosition | + | | BlkKingPosition |
− | | when any | + | | when any Square MovePiece, if the Square piecename is "blkking" then the board BlkkingPosition changes to the Square position |
| | | | ||
[[Image:BlkKingPosition.png|thumb|left|LSC]] | [[Image:BlkKingPosition.png|thumb|left|LSC]] | ||
Line 92: | Line 94: | ||
|- | |- | ||
| WteKingPosition | | WteKingPosition | ||
− | | when any | + | | when any Square MovePiece, if the Square piecename is "wteking" then the board WtekingPosition changes to the Square position |
| | | | ||
[[Image:WteKingPosition.png|thumb|left|LSC]] | [[Image:WteKingPosition.png|thumb|left|LSC]] | ||
Line 132: | Line 134: | ||
=== Download the ChessProject Example === | === Download the ChessProject Example === | ||
− | Below are links for downloading the ChessProject final application, as well as | + | Below are links for downloading the ChessProject final application, as well as the LSC project that can be opened and modified in PlayGo.<br> |
− | ==== ChessProject final application (runnable jar) ==== | + | ==== ChessProject final application (runnable jar) ==== |
[[Media:ChessProjectSwingGUI.zip|Runnable ChessProject with Swing GUI]] <br><br> To run the ChessProject, simply extract the downloaded zip and double click the jar file.<br> | [[Media:ChessProjectSwingGUI.zip|Runnable ChessProject with Swing GUI]] <br><br> To run the ChessProject, simply extract the downloaded zip and double click the jar file.<br> | ||
− | ==== ChessProject LSC project ==== | + | ==== ChessProject LSC project ==== |
− | [[Media:ChessProject.zip| | + | [[Media:ChessProject.zip|The ChessProject LSC Project (for development purposes)]] <br> |
− | ===== Installation Instructions ===== | + | ===== Installation Instructions ===== |
#Extract the downloaded zip. | #Extract the downloaded zip. | ||
Line 153: | Line 155: | ||
#The ChessProject example project is now part of your workspace. You can start playing with it. For details refer to [[How to Play-Out|how to play out]]. | #The ChessProject example project is now part of your workspace. You can start playing with it. For details refer to [[How to Play-Out|how to play out]]. | ||
− | == Example 2 | + | == Example 2 == |
− | The following LSCs | + | The following LSCs were created using the LSC editor. Our intention was to create a specification with more than one symbolic lifeline in the LSCs, which was not supported by NL-Play-In. |
− | Our intention was to create a specification with more than one symbolic lifeline in the LSCs, which was not supported by NL-Play-In | + | |
<br> | <br> | ||
Line 163: | Line 164: | ||
|- | |- | ||
! scope="col" width="15%" | Name | ! scope="col" width="15%" | Name | ||
− | ! scope="col" width="70%" | | + | ! scope="col" width="70%" | Requirement |
! scope="col" width="15%" | LSC | ! scope="col" width="15%" | LSC | ||
|- | |- | ||
Line 173: | Line 174: | ||
|- | |- | ||
| MovePiece | | MovePiece | ||
− | | When | + | | When a square Sq1 check_Move square Sq2, canmove is assigned with whether the movement of piece from square Sq1 to Sq2 is possible, if the piece canmove and Sq1 piecetype is not equals to Sq2 piecetype then the square Sq1 move_Piece to square Sq2. |
| [[Image:MovePiece.png|thumb|left|LSC]] | | [[Image:MovePiece.png|thumb|left|LSC]] | ||
|- | |- | ||
Line 233: | Line 234: | ||
=== Download the ChessGame Example === | === Download the ChessGame Example === | ||
− | Below are downloads of the ChessGame final application, as well as | + | Below are downloads of the ChessGame final application, as well as the LSC project that can be opened and modified in PlayGo.<br> |
− | ==== ChessGame final application (runnable jar) ==== | + | ==== ChessGame final application (runnable jar) ==== |
[[Media:ChessGameSwingGUI.zip|Runnable Chess Game with Swing GUI]] <br><br> To run the ChessGame, simply extract the downloaded zip and double click the jar file.<br> | [[Media:ChessGameSwingGUI.zip|Runnable Chess Game with Swing GUI]] <br><br> To run the ChessGame, simply extract the downloaded zip and double click the jar file.<br> | ||
− | ==== ChessGame LSC project ==== | + | ==== ChessGame LSC project ==== |
[[Media:ChessGame.zip|The ChessGame LSC Project (for development purposes)]] <br> | [[Media:ChessGame.zip|The ChessGame LSC Project (for development purposes)]] <br> | ||
− | ===== Installation Instructions ===== | + | ===== Installation Instructions ===== |
#Extract the downloaded zip. | #Extract the downloaded zip. | ||
Line 258: | Line 259: | ||
== Graph and Connections == | == Graph and Connections == | ||
− | '''Example1-ChessProject'''<br> <br>[[Image:SivChessGame.png|SIV Graph]]<br> Dependency graph for | + | '''Example1-ChessProject'''<br> <br>[[Image:SivChessGame.png|SIV Graph]]<br> Dependency graph for example #1. This graph shows clusters (communities). The LSC MovePiece is selected here and the connected LSCs are colored (blue or pink). Green edges indicate unified messages between LSCs. <br>For details, see [[http://www.weizmann.ac.il/mediawiki/harelgroup/index.php/SIV_Plugin | SIV-Plugin]]. <br> <br> |
− | <br> | + | '''Example2-ChessGame'''<br> <br>[[Image:ChessSIV-example2.png|SIV Graph]]<br> Dependency graph for example #2. This graph shows clusters (communities). The LSC MovePiece is selected here and the connected LSCs are colored (blue or pink). Green edges indicate unified messages between LSCs.<br> Note: messages were unified here regardless of the parameters, since parameters are symbolic, e.g., MovePiece(String piecename). <br>For details, see[[http://www.weizmann.ac.il/mediawiki/harelgroup/index.php/SIV_Plugin | SIV-Plugin]]. |
<br> <br> | <br> <br> | ||
Line 267: | Line 268: | ||
<br> <br> Example1-ChessProject<br> [[Image:ChessProjectSystemModel.png|SystemModel]] <br> <br> Example2-ChessGame<br> [[Image:ChessGameSystemmodel.png|System Model]] <br> <br> | <br> <br> Example1-ChessProject<br> [[Image:ChessProjectSystemModel.png|SystemModel]] <br> <br> Example2-ChessGame<br> [[Image:ChessGameSystemmodel.png|System Model]] <br> <br> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 07:50, 8 December 2015
This is a protected page for the Chess Game Example.
This project was carried out by Jaysree Nair and Michal Gordon, in 2013.
The chess game example demonstrates the creation of a chess game for two-players. Chess game has many rules which we have implemented in this example, see [chess]. On his turn, the user plays by mouse clicking the game pieces and the chess board's squares. A click on a square highlights valid user moves for the selected piece. The game GUI is implemented with Swing, and the game behavior is implemented with LSCs. This example demonstrates LSCs creation in two different ways, which also generates different LSCs:
- Using the natural language interface to LSCs (NL-Play-In).
- Using the LSC Editor.
Game Board
Example 1 with NL-Play-In
The LSCs in this section were created using NL-Play-In.
Name | Requirement in Natural Language Text | LSC |
---|---|---|
SelectSource | when the user clicks any Square, if the board sourcetargetValue is "0" and the Square type is not "vacent" then the Square selectSource and the board sourcetargetValue changes to "1". | |
SetPossiblePosition | when any Square selectSource then the Square setPossibleSquares . | |
SelectTarget | when the user clicks any Square, if the board sourcetargetValue is "1" then the Square selectTarget and the board sourcetargetValue changes to "0". | |
CheckPossibility | when any Square selectTarget then the Square checkPossibility. | |
MovePiece | when any Square checkPossibility, if the Square possibility is "true" then the Square MovePiece. | |
ChangeTurn | when any Square MovePiece, if the board state is "black" then the board state changes to "white" otherwise if the board state is "white" then the board state changes to "black" . | |
WrongTurn | when any Square selectSource, if the Square type is "black" and the board state is "white" then the Square showMessage. | |
WrongTurn2 | when any Square selectSource, if the Square type is "white" and the board state is "black" then the Square showMessage. | |
ResetBoard | when any Square showMessage then the board sourcetargetValue changes to "0". | |
checkmate | when any Square MovePiece then the Square check_CheckMate | |
BlkKingPosition | when any Square MovePiece, if the Square piecename is "blkking" then the board BlkkingPosition changes to the Square position | |
WteKingPosition | when any Square MovePiece, if the Square piecename is "wteking" then the board WtekingPosition changes to the Square position | |
Newgame | when the user click the newgame then the newgame loadnewgame and the board reset | |
ShowScoreblack | when the board state change then the BlkScore show the board blackPoint | |
ShowScorewhite | when the board state change then the WteScore show the board whitePoint | |
ShowNextTurn | when the board state change then the NextTurndisplay show the board state | |
ResetPossiblePosition | when any Square selectTarget then the Square reset | |
WrongTurnReset | when any Square showMessage then the Square reset |
Download the ChessProject Example
Below are links for downloading the ChessProject final application, as well as the LSC project that can be opened and modified in PlayGo.
ChessProject final application (runnable jar)
Runnable ChessProject with Swing GUI
To run the ChessProject, simply extract the downloaded zip and double click the jar file.
ChessProject LSC project
The ChessProject LSC Project (for development purposes)
Installation Instructions
- Extract the downloaded zip.
- Download PlayGo.
- Import the downloaded project to your workspace:
- From the File menu choose Import-->General-->Existing Projects into Workspace.
- Click the 'Next' button.
- When prompted, select the directory to which you extracted the downloaded ChessProject example.
- Click finish.
- The ChessProject example project is now part of your workspace. You can start playing with it. For details refer to how to play out.
Example 2
The following LSCs were created using the LSC editor. Our intention was to create a specification with more than one symbolic lifeline in the LSCs, which was not supported by NL-Play-In.
Name | Requirement | LSC |
---|---|---|
PieceClick | When the user click any square Sq1, and then click any square Sq2, if the board next turn is equals to the Sq1 piece type and if the Sq1 is a source then the square Sq1 check_Move square Sq2. | |
MovePiece | When a square Sq1 check_Move square Sq2, canmove is assigned with whether the movement of piece from square Sq1 to Sq2 is possible, if the piece canmove and Sq1 piecetype is not equals to Sq2 piecetype then the square Sq1 move_Piece to square Sq2. | |
Square RemovePiece | When the square Sq1 move_Piece to square Sq2, then the square Sq2 emptyPiece the square Sq2. | |
NextMove | When the square Sq1 move_Piece to square Sq2, if the board next turn is "white" the board next turn changes to "black" otherwise if the board next turn is "black" the board next turn changes to "white". | |
SetSource | When the user click any square Sq1, if the Issource is "empty" then the square Sq1's possible positions are set and the IsSource changes to "set". | |
ShowMessage | When the user click any square Sq1, if the square IsSource is "empty" and the board next turn not equals the Sq1 piecetype then the square showmessage and the Issource is set to "empty". | |
ShowMessageReset | When the user click any square Sq1, if the square IsSource is "empty" and the board next turn not equals the Sq1 piecetype then the square showmessage and the Issource is set to "empty". | |
ResetPossiblePosition | When the user click any square Sq1, the square Sq1 setPossiblePosition and the user click any other square Sq2 then the Sq2 resetPossiblePosition of the Sq1. | |
CheckMate | When the any square Sq2 emptypiece any square Sq1, then isCheck is assigned whether there is any checkmate, if the checkmate is true then the square show the checkmate otherwise square removecheckmate. | |
kingposition | When the any square Sq2 emptypiece any square Sq1, if the Sq2 piecname is wteking then the Sq1 removecheckMate and the board wtekingposition is set to the Sq2 position else if the Sq2 piecname is blkking then the Sq1 removecheckMate and the board blkkingposition is set to the Sq2 position . | |
showturn | When the board set the Next_turn to any then the NextTurn show the board Next turn. | |
BlackPiecepoint | When the any square Sq2 emptypiece any square Sq1, if the board Next_turn is white then the blk_score show the black point. | |
WhitePiecepoint | When the any square Sq2 emptypiece any square Sq1, if the board Next_turn is black then the wte_score show the white point. | |
GameOver | When the any square Sq1 movePiece to any square Sq2, if the board black point is 0 then the white won the game otherwise if the board white point is 0 then the black won the game | |
Loadgame | when the user click NewGame then the NewGame load new game |
Download the ChessGame Example
Below are downloads of the ChessGame final application, as well as the LSC project that can be opened and modified in PlayGo.
ChessGame final application (runnable jar)
Runnable Chess Game with Swing GUI
To run the ChessGame, simply extract the downloaded zip and double click the jar file.
ChessGame LSC project
The ChessGame LSC Project (for development purposes)
Installation Instructions
- Extract the downloaded zip.
- Download PlayGo.
- Import the downloaded project to your workspace:
- From the File menu choose Import-->General-->Existing Projects into Workspace.
- Click the 'Next' button.
- When prompted, select the directory to which you extracted the downloaded ChessGame example.
- Click finish.
- The ChessGame example project is now part of your workspace. You can start playing with it. For details refer to how to play out.
Graph and Connections
Example1-ChessProject
Dependency graph for example #1. This graph shows clusters (communities). The LSC MovePiece is selected here and the connected LSCs are colored (blue or pink). Green edges indicate unified messages between LSCs.
For details, see [| SIV-Plugin].
Example2-ChessGame
Dependency graph for example #2. This graph shows clusters (communities). The LSC MovePiece is selected here and the connected LSCs are colored (blue or pink). Green edges indicate unified messages between LSCs.
Note: messages were unified here regardless of the parameters, since parameters are symbolic, e.g., MovePiece(String piecename).
For details, see[| SIV-Plugin].