Difference between revisions of "Chess Game Example"
Line 119: | Line 119: | ||
! scope="col" width="15%" | LSC | ! scope="col" width="15%" | 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 then the square Sq1 check_Move square Sq2. | | 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 then the square Sq1 check_Move square Sq2. | ||
| | | | ||
Line 125: | Line 125: | ||
|- | |- | ||
− | | | + | | MovePiece |
| When the square Sq1 check_Move square Sq2, canmove is assigned 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. | | When the square Sq1 check_Move square Sq2, canmove is assigned 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|x50px|LSC]] | | [[Image:MovePiece.png|thumb|left|x50px|LSC]] | ||
Line 133: | Line 133: | ||
| [[Image:RemovePiece.png|thumb|left|x50px|LSC]] | | [[Image:RemovePiece.png|thumb|left|x50px|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". | | 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|x50px|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". | | 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". | ||
| [[Image:SetSource.png|thumb|left|x50px|LSC]] | | [[Image:SetSource.png|thumb|left|x50px|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". | | 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|x50px|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". | | 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|x50px|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. | | 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|x50px|LSC]] |
Revision as of 13:24, 6 March 2013
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 [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.
Contents
Game Board
Example 1 - LSCs created with NL-Play-In
The LSCs in this section were created with the NL-Play-In. The natural language text was parsed automatically to create the LSC.
Name | 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". | |
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. | |
TurnChange | 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" . | |
ChessNL 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". | |
PawnPossiblePosition | when any Square selectSource, if the Square piecename is "pawn" then the Square setPossiblePawnSquares. | |
RookPossiblePosition | when any Square selectSource, if the Square piecename is "rook" then the Square setPossibleRookSquares . | |
KnightPossiblePosition | when any Square selectSource, if the Square piecename is "knight" then the Square setPossibleKnightSquares. | |
BishopPossiblePosition | when any Square selectSource, if the Square piecename is "bishop" then the Square setPossibleBishopSquares. | |
QueenPossiblePosition | when any Square selectSource, if the Square piecename is "queen" then the Square setPossibleQueenSquares . | |
KingPossiblePosition | when any Square selectSource, if the Square piecename is "king" then the Square setPossibleKingSquares . |
Example 2 - LSC for the game
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.
Name | Description | 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 then the square Sq1 check_Move square Sq2. | |
MovePiece | When the square Sq1 check_Move square Sq2, canmove is assigned 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. |
Graph and Connections
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.
Name | Explanation | LSC |
---|---|---|
Square ResetHighlight | when the square sq2 is highlighed and the user click that square Sq2 then the square reset the highlight. |
Since Sq2 is dynamic and there are more highlighted squares it leads to the universal binding.