Difference between revisions of "Chess Game Example"

From WeizmannWiki
Jump to: navigation, search
 
(26 intermediate revisions by 4 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. The chess game has many rules and that are implemented in this example, see [[http://en.wikipedia.org/wiki/Chess chess]]. The games interface is throught mouse clicks on the peices and the chess board's squares. A click on a square highlights valid user moves according to the rules of chess and the selected piece. The game is implemented with LSCs that can created in different ways, in this example, we present requirements created in two ways: one using the natural language interface to LSCs (NL-Play-In) and the other using the editor. We also review the differences between the approaches.
+
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 [[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.&nbsp;
  
 
== Game Board  ==
 
== Game Board  ==
Line 11: Line 15:
 
<br>
 
<br>
  
== Example 1 -ChessProject- LSCs created with NL-Play-In (chesswithNL.umlseq) ==
+
== Example 1 with NL-Play-In ==
  
The LSCs in this section were created with the [[PlayGo Feature List#Natural_language_play-in|NL-Play-In]]. The natural language text was parsed automatically to create the LSC.
+
The LSCs in this section were created using [[PlayGo Feature List#Natural_language_play-in|NL-Play-In]].
  
 
<br>
 
<br>
Line 20: 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 26: Line 30:
 
| 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".&nbsp;
 
| 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".&nbsp;
 
|
 
|
[[Image:SelectSource.png|thumb|left|x50px|LSC]]
+
[[Image:SelectSource.png|thumb|left|LSC]]
 +
 
 +
|-
 +
| SetPossiblePosition
 +
| when any Square selectSource then the Square setPossibleSquares . &nbsp;
 +
|
 +
[[Image:SetPossiblePositionNL.png|thumb|left|LSC]]
  
 
|-
 
|-
Line 32: Line 42:
 
| when the user clicks any Square, if the board sourcetargetValue is "1" then the Square selectTarget and the board sourcetargetValue changes to "0".&nbsp;
 
| when the user clicks any Square, if the board sourcetargetValue is "1" then the Square selectTarget and the board sourcetargetValue changes to "0".&nbsp;
 
|
 
|
[[Image:SelectTarget.png|thumb|left|x50px|LSC]]
+
[[Image:SelectTarget.png|thumb|left|LSC]]
  
 
|-
 
|-
Line 38: Line 48:
 
| when any Square selectTarget then the Square checkPossibility. &nbsp;
 
| when any Square selectTarget then the Square checkPossibility. &nbsp;
 
|
 
|
[[Image:CheckPossibility.png|thumb|left|x50px|LSC]]
+
[[Image:CheckPossibility.png|thumb|left|LSC]]
  
 
|-
 
|-
Line 44: Line 54:
 
| when any Square checkPossibility, if the Square possibility is "true" then the Square MovePiece. &nbsp;
 
| when any Square checkPossibility, if the Square possibility is "true" then the Square MovePiece. &nbsp;
 
|
 
|
[[Image:MoveSource.png|thumb|left|x50px|LSC]]
+
[[Image:MoveSource.png|thumb|left|LSC]]
  
 
|-
 
|-
Line 50: Line 60:
 
| 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" . &nbsp;
 
| 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" . &nbsp;
 
|
 
|
[[Image:TurnChange.png|thumb|left|x50px|LSC]]
+
[[Image:TurnChange.png|thumb|left|LSC]]
  
 
|-
 
|-
Line 56: Line 66:
 
| when any Square selectSource, if the Square type is "black" and the board state is "white" then the Square showMessage. &nbsp;
 
| when any Square selectSource, if the Square type is "black" and the board state is "white" then the Square showMessage. &nbsp;
 
|
 
|
[[Image:WrongTurn1.png|thumb|left|x50px|LSC]]
+
[[Image:WrongTurn1.png|thumb|left|LSC]]
  
 
|-
 
|-
Line 62: Line 72:
 
| when any Square selectSource, if the Square type is "white" and the board state is "black" then the Square showMessage. &nbsp;
 
| when any Square selectSource, if the Square type is "white" and the board state is "black" then the Square showMessage. &nbsp;
 
|
 
|
[[Image:WrongTurn2.png|thumb|left|x50px|LSC]]
+
[[Image:WrongTurn2.png|thumb|left|LSC]]
  
 
|-
 
|-
Line 68: Line 78:
 
| when any Square showMessage then the board sourcetargetValue changes to "0". &nbsp;
 
| when any Square showMessage then the board sourcetargetValue changes to "0". &nbsp;
 
|
 
|
[[Image:ResetBoard.png|thumb|left|x50px|LSC]]
+
[[Image:ResetBoard.png|thumb|left|LSC]]
  
 
|-
 
|-
| SetPossiblePosition
+
| checkmate
|when any Square selectSource then the Square setPossibleSquares . &nbsp;
+
| when any Square MovePiece then the Square check_CheckMate &nbsp;
 
|
 
|
[[Image:SetPossiblePositionNL.png|thumb|left|x50px|LSC]]
+
[[Image:Checkmate-NL.png|thumb|left|LSC]]
  
 
|-
 
|-
|checkmate
+
| BlkKingPosition
| when any Square MovePiece then the Square   check_CheckMate  &nbsp;
+
| when any Square MovePiece, if the Square piecename is "blkking" then the board BlkkingPosition changes to the Square position&nbsp;
 
|
 
|
[[Image:Checkmate-NL.png|thumb|left|x50px|LSC]]
+
[[Image:BlkKingPosition.png|thumb|left|LSC]]
  
 
|-
 
|-
| BlkKingPosition.png
+
| WteKingPosition
| when any square MovePiece, if the square piecename is "blkking" then the board BlkkingPosition changes to the square position&nbsp;
+
| when any Square MovePiece, if the Square piecename is "wteking" then the board WtekingPosition changes to the Square position &nbsp;
 
|
 
|
[[Image:BlkKingPosition.png|thumb|left|x50px|LSC]]
+
[[Image:WteKingPosition.png|thumb|left|LSC]]
  
|-
 
| WteKingPosition
 
| when any square MovePiece,  if the square piecename is "wteking"  then the board WtekingPosition changes to the square position &nbsp;
 
|
 
[[Image:WteKingPosition.png|thumb|left|x50px|LSC]]
 
 
|-
 
|-
 
| Newgame
 
| Newgame
| when the user click the newgame then the newgame loadnewgame and the board reset   &nbsp;
+
| when the user click the newgame then the newgame loadnewgame and the board reset &nbsp;
 
|
 
|
[[Image:NewGame.png|thumb|left|x50px|LSC]]
+
[[Image:NewGame.png|thumb|left|LSC]]
  
 
|-
 
|-
 
+
| ShowScoreblack
|ShowScoreblack
+
| when the board state change then the BlkScore show the board blackPoint &nbsp;
| when the board state change then the BlkScore show the board blackPoint     &nbsp;
+
 
|
 
|
[[Image:ShowScoreblack.png|thumb|left|x50px|LSC]]
+
[[Image:ShowScoreblack.png|thumb|left|LSC]]
  
 
|-
 
|-
 
| ShowScorewhite
 
| ShowScorewhite
| when the board state change then the WteScore show the board whitePoint   &nbsp;
+
| when the board state change then the WteScore show the board whitePoint &nbsp;
 
|
 
|
[[Image:ShowScorewhite.png|thumb|left|x50px|LSC]]
+
[[Image:ShowScorewhite.png|thumb|left|LSC]]
  
 
|-
 
|-
 
| ShowNextTurn
 
| ShowNextTurn
| when the board state change then the NextTurndisplay show the board state &nbsp;
+
| when the board state change then the NextTurndisplay show the board state &nbsp;
|[[Image:ShowNextTurn.png|thumb|left|x50px|LSC]]
+
| [[Image:ShowNextTurn.png|thumb|left|LSC]]
 
|-
 
|-
 
| ResetPossiblePosition
 
| ResetPossiblePosition
| when any Square selectTarget then the Square reset       &nbsp;
+
| when any Square selectTarget then the Square reset &nbsp;
|[[Image:ResrPossiblePositionNL.png|thumb|left|x50px|LSC]]
+
| [[Image:ResrPossiblePositionNL.png|thumb|left|LSC]]
 
|-
 
|-
 
+
| WrongTurnReset
 +
| when any Square showMessage then the Square reset &nbsp;
 +
| [[Image:WrongTurnReset.png|thumb|left|LSC]]
 
|}
 
|}
  
Line 127: Line 133:
  
 
=== Download the ChessProject Example  ===
 
=== Download the ChessProject Example  ===
Below are downloads of the ChessProject final application, as well as of the LSC project that can be opened and modified in PlayGo.<br>
 
====ChessProject final application (runnable jar)====
 
[[Media:ChessProjectExampleSwingGUI.zip|Runnable ChessProject with Swing GUI]] <br><br>
 
To run the ChessProject, simply extract the downloaded zip and double click the jar file.<br> &nbsp;
 
  
====ChessProject LSC project====
+
Below are links for downloading the ChessProject final application, as well as the LSC project that can be opened and modified in PlayGo.<br>
[[Media:ChessProject.zip|TheChessProject LSC Project (for development purposes)]] <br>
+
 
=====Installation Instructions=====
+
==== 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> &nbsp;
 +
 
 +
==== ChessProject LSC project ====
 +
 
 +
[[Media:ChessProject.zip|The ChessProject LSC Project (for development purposes)]] <br>
 +
 
 +
===== Installation Instructions =====
 +
 
 
#Extract the downloaded zip.
 
#Extract the downloaded zip.
 
#[[Download PlayGo|Download PlayGo]].
 
#[[Download PlayGo|Download PlayGo]].
Line 142: Line 153:
 
##When prompted, select the directory to which you extracted the downloaded ChessProject example.
 
##When prompted, select the directory to which you extracted the downloaded ChessProject example.
 
##Click finish.
 
##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 | 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 -ChessGame- LSC for the game(square.umlseq)  ==
+
== Example 2 ==
  
The following LSCs where created with the use of the editor. Our intention was to create a specification with more than one symbolic lifeline in the LSCs and possibly more than one monitored event at the chart start.
+
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.
  
 
<br>
 
<br>
Line 156: Line 164:
 
|-
 
|-
 
! scope="col" width="15%" | Name
 
! scope="col" width="15%" | Name
! scope="col" width="70%" | Description
+
! scope="col" width="70%" | Requirement
 
! scope="col" width="15%" | LSC
 
! scope="col" width="15%" | LSC
 
|-
 
|-
Line 162: Line 170:
 
| 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.&nbsp;
 
| 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.&nbsp;
 
|
 
|
[[Image:ClickonPiece.png|thumb|left|x50px|LSC]]
+
[[Image:ClickonPiece.png|thumb|left|LSC]]
  
 
|-
 
|-
 
| MovePiece
 
| MovePiece
| When the square Sq1 check_Move square Sq2, canmove is assigned whether the movement of piece from square Sq1 to Sq2 is possible, &nbsp;if the piece canmove and Sq1 piecetype is not equals to Sq2 piecetype then the square Sq1 move_Piece to square Sq2.
+
| When a square Sq1 check_Move square Sq2, canmove is assigned with whether the movement of piece from square Sq1 to Sq2 is possible, &nbsp;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|x50px|LSC]]
+
| [[Image:MovePiece.png|thumb|left|LSC]]
 
|-
 
|-
 
| Square RemovePiece
 
| Square RemovePiece
 
| When&nbsp;the square Sq1 move_Piece to square Sq2, &nbsp;then the square Sq2 emptyPiece the square Sq2.
 
| When&nbsp;the square Sq1 move_Piece to square Sq2, &nbsp;then the square Sq2 emptyPiece the square Sq2.
| [[Image:RemovePiece.png|thumb|left|x50px|LSC]]
+
| [[Image:RemovePiece.png|thumb|left|LSC]]
 
|-
 
|-
 
| NextMove
 
| 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".
 
| 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".
| [[Image:NextMove.png|thumb|left|x50px|LSC]]
+
| [[Image:NextMove.png|thumb|left|LSC]]
 
|-
 
|-
 
| SetSource
 
| 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". &nbsp;
 
| 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". &nbsp;
| [[Image:SetSource.png|thumb|left|x50px|LSC]]
+
| [[Image:SetSource.png|thumb|left|LSC]]
 
|-
 
|-
 
| ShowMessage
 
| 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".
 
| 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".
| [[Image:ShowMessage.png|thumb|left|x50px|LSC]]
+
| [[Image:ShowMessage.png|thumb|left|LSC]]
 
|-
 
|-
 
| ShowMessageReset
 
| 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".
 
| 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".
| [[Image:ShowmessageReset.jpg|thumb|left|x50px|LSC]]
+
| [[Image:ShowmessageReset.jpg|thumb|left|LSC]]
 
|-
 
|-
 
| ResetPossiblePosition
 
| 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.
 
| 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.
| [[Image:ResetPossiblePosition.png|thumb|left|x50px|LSC]]
+
| [[Image:ResetPossiblePosition.png|thumb|left|LSC]]
 
|-
 
|-
 
| CheckMate
 
| 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.
 
| 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.
| [[Image:Checkmate.png|thumb|left|x50px|LSC]]
+
| [[Image:Checkmate.png|thumb|left|LSC]]
 
|-
 
|-
 
| kingposition
 
| 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 .
 
| 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 .
| [[Image:Kingposition.png|thumb|left|x50px|LSC]]
+
| [[Image:Kingposition.png|thumb|left|LSC]]
 
|-
 
|-
 
| showturn
 
| showturn
 
| When the board set the Next_turn to any then the NextTurn show the board Next turn.
 
| When the board set the Next_turn to any then the NextTurn show the board Next turn.
| [[Image:Showturn.png|thumb|left|x50px|LSC]]
+
| [[Image:Showturn.png|thumb|left|LSC]]
 
|-
 
|-
 
| BlackPiecepoint
 
| 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.
 
| When the any square Sq2 emptypiece any square Sq1, if the board Next_turn is white then the blk_score show the black point.
| [[Image:Blackpiecepoint.png|thumb|left|x50px|LSC]]
+
| [[Image:Blackpiecepoint.png|thumb|left|LSC]]
 
|-
 
|-
 
| WhitePiecepoint
 
| 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.
 
| When the any square Sq2 emptypiece any square Sq1, if the board Next_turn is black then the wte_score show the white point.
| [[Image:Whitepiecepoint.png|thumb|left|x50px|LSC]]
+
| [[Image:Whitepiecepoint.png|thumb|left|LSC]]
 
|-
 
|-
 
| GameOver
 
| 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
 
| 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
| [[Image:GameOver.png|thumb|left|x50px|LSC]]
+
| [[Image:GameOver.png|thumb|left|LSC]]
 
|-
 
|-
 
| Loadgame
 
| Loadgame
 
| when the user click NewGame then the NewGame load new game
 
| when the user click NewGame then the NewGame load new game
| [[Image:LoadGame.png|thumb|left|x50px|LSC]]
+
| [[Image:LoadGame.png|thumb|left|LSC]]
 
|}
 
|}
  
 
<br><br> &nbsp; <br>
 
<br><br> &nbsp; <br>
 +
 
=== Download the ChessGame Example  ===
 
=== Download the ChessGame Example  ===
Below are downloads of the ChessGame final application, as well as of the LSC project that can be opened and modified in PlayGo.<br>
 
====ChessGame final application (runnable jar)====
 
[[Media:ChessGameExampleSwingGUI.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> &nbsp;
 
  
====ChessGame LSC project====
+
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)  ====
 +
 
 +
[[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> &nbsp;
 +
 
 +
==== 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.
 
#[[Download PlayGo|Download PlayGo]].
 
#[[Download PlayGo|Download PlayGo]].
Line 239: Line 253:
 
##When prompted, select the directory to which you extracted the downloaded ChessGame example.
 
##When prompted, select the directory to which you extracted the downloaded ChessGame example.
 
##Click finish.
 
##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 | how to play out]].
+
#The ChessGame 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]].
  
 +
<br>
  
 
== Graph and Connections  ==
 
== Graph and Connections  ==
  
'''Example1-ChessProject'''<br>&nbsp;<br>[[Image:ChessSIV-example1.png|SIV Graph]]<br> Dependency graph for Example 1. This graph shows clusters (communities). And MovePiece is selected here and the connected LSCs are colored (blue or pink). Green edges are unified messages between LSCs.
+
'''Example1-ChessProject'''<br>&nbsp;<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>&nbsp;<br>
<br>See [[http://www.weizmann.ac.il/mediawiki/harelgroup/index.php/SIV_Plugin | SIV-Plugin]] for details.
+
<br>&nbsp;<br>
+
'''Example2-ChessGame'''<br>&nbsp;<br>[[Image:ChessSIV-example2.png|SIV Graph]]<br> Dependency graph for Example 2. This graph also shows clusters (communities). And MovePiece is selected here and the connected LSCs are colored (blue or pink). Green edges are unified messages between LSCs.<br> Note: messages were unified here regardless of the parameters, since parameters are symbolic, e.g., MovePiece(String piecename).
+
<br>see[[http://www.weizmann.ac.il/mediawiki/harelgroup/index.php/SIV_Plugin | SIV-Plugin]] for details
+
  
 
+
'''Example2-ChessGame'''<br>&nbsp;<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]].
General observations: Both seem plausible, although they are a bit different.
+
  
 
<br>&nbsp;<br>
 
<br>&nbsp;<br>
  
== SystemModel   ==
+
== SystemModel  ==
<br>&nbsp;<br>
+
Example1-ChessProject<br>&nbsp;[[Image:ChessProjectSystemModel.png|SystemModel]]
+
<br>&nbsp;<br>
+
Example2-ChessGame<br>&nbsp;[[Image:ChessGameSystemmodel.png|System Model]]
+
<br>&nbsp;<br>
+
===== Example 3 - a non working LSC =====
+
 
+
In this example, we demonstrate an LSC created, that seems to work, but will not work due to an unbound lifeline.
+
 
+
<br>
+
 
+
{| width="100%" border="1" align="left" cellpadding="1" cellspacing="1"
+
|-
+
! scope="col" width="15%" | Name
+
! scope="col" width="70%" | Explanation
+
! scope="col" width="15%" | LSC
+
|-
+
| Square ResetHighlight
+
| when the square sq2 is highlighed and the user click that square Sq2 then the square reset the highlight.
+
| [[Image:ResetHighlight.png|thumb|left|LSC]]
+
|}
+
 
+
Since Sq2 is dynamic and there are more highlighted squares it leads to the universal binding.
+
 
+
<br> &nbsp; &nbsp;
+
  
<br> <br> <br>
+
<br>&nbsp;<br> Example1-ChessProject<br>&nbsp;[[Image:ChessProjectSystemModel.png|SystemModel]] <br>&nbsp;<br> Example2-ChessGame<br>&nbsp;[[Image:ChessGameSystemmodel.png|System Model]] <br>&nbsp;<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:

  1. Using the natural language interface to LSCs (NL-Play-In).
  2. Using the LSC Editor. 

Game Board

ChessGUIScreenShot.png



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". 
LSC
SetPossiblePosition when any Square selectSource then the Square setPossibleSquares .  
LSC
SelectTarget when the user clicks any Square, if the board sourcetargetValue is "1" then the Square selectTarget and the board sourcetargetValue changes to "0". 
LSC
CheckPossibility when any Square selectTarget then the Square checkPossibility.  
LSC
MovePiece when any Square checkPossibility, if the Square possibility is "true" then the Square MovePiece.  
LSC
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" .  
LSC
WrongTurn when any Square selectSource, if the Square type is "black" and the board state is "white" then the Square showMessage.  
LSC
WrongTurn2 when any Square selectSource, if the Square type is "white" and the board state is "black" then the Square showMessage.  
LSC
ResetBoard when any Square showMessage then the board sourcetargetValue changes to "0".  
LSC
checkmate when any Square MovePiece then the Square check_CheckMate  
LSC
BlkKingPosition when any Square MovePiece, if the Square piecename is "blkking" then the board BlkkingPosition changes to the Square position 
LSC
WteKingPosition when any Square MovePiece, if the Square piecename is "wteking" then the board WtekingPosition changes to the Square position  
LSC
Newgame when the user click the newgame then the newgame loadnewgame and the board reset  
LSC
ShowScoreblack when the board state change then the BlkScore show the board blackPoint  
LSC
ShowScorewhite when the board state change then the WteScore show the board whitePoint  
LSC
ShowNextTurn when the board state change then the NextTurndisplay show the board state  
LSC
ResetPossiblePosition when any Square selectTarget then the Square reset  
LSC
WrongTurnReset when any Square showMessage then the Square reset  
LSC


 
 

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
  1. Extract the downloaded zip.
  2. Download PlayGo.
  3. Import the downloaded project to your workspace:
    1. From the File menu choose Import-->General-->Existing Projects into Workspace.
    2. Click the 'Next' button.
    3. When prompted, select the directory to which you extracted the downloaded ChessProject example.
    4. Click finish.
  4. 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. 
LSC
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.
LSC
Square RemovePiece When the square Sq1 move_Piece to square Sq2,  then the square Sq2 emptyPiece the square Sq2.
LSC
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".
LSC
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".  
LSC
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".
LSC
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".
LSC
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.
LSC
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.
LSC
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 .
LSC
showturn When the board set the Next_turn to any then the NextTurn show the board Next turn.
LSC
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.
LSC
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.
LSC
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
LSC
Loadgame when the user click NewGame then the NewGame load new game
LSC



 

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
  1. Extract the downloaded zip.
  2. Download PlayGo.
  3. Import the downloaded project to your workspace:
    1. From the File menu choose Import-->General-->Existing Projects into Workspace.
    2. Click the 'Next' button.
    3. When prompted, select the directory to which you extracted the downloaded ChessGame example.
    4. Click finish.
  4. 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
 
SIV Graph
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
 
SIV Graph
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].


 

SystemModel


 
Example1-ChessProject
 SystemModel
 
Example2-ChessGame
 System Model