## 3 Personalized Exergame Language
### Design and Development of PEL
#### Trajectories component  
The component trajectories is used to store the trajectories associated with the movements that a patient will make when performing an exergame. In this case, and unlike the component _virtual_nodes_, the points or nodes in the 3D space do not need a unique identifier, since the identity of the element is represented by each path (_id_trajectory_), and not by individual points in 3D space. As an example, an element defined by the component trajectories would be the route or path associated to a shoulder abduction exercise. Thus, the component trajectories stores a list of individual paths, each one of them being identified by the value of the attribute _id_trajectory_ and defined by the attribute _3d_path_. This attribute will contain an ordered list or sequence of points in 3D space that form the path. Single nodes can be used as part of a path. The EBNF grammar for trajectories block is the following:  
\begin{tabular}{l l l} TRAJECTORIES & \(::=\) & \({}^{**}\)**trajectories \({}^{**}\)\({}^ \begin{tabular}{l l l} type\_joint & \(::=\) & hip-center \(|\) spine \(|\) shoulder-center \(|\) head \(|\) \\  & shoulder-left \(|\) elbow-left \(|\) wrist-left \(|\) hand-left \(|\) \\  & shoulder-right \(|\) elbow-right \(|\) wrist-right \(|\) \\  & hand-right \(|\) hip-left \(|\) knee-left \(|\) ankle-left \(|\) \\  & foot-left \(|\) hip-right \(|\) knee-right \(|\) ankle-right \(|\) \\  & foot-right \\ type\_interaction & \(::=\) & on-touch \(|\) hold \\ type\_action & \(::=\) & retry \(|\) skip \\ \end{tabular} \begin{tabular}{l l l} ID\_GAME\_DYNAMIC & \(::=\) & \({}^{***}\) **id\_game\_dynamic \({}^{***}\) ':' string** \\ MAXTIME & \(::=\) & \({}^{***}\) **max\_time\_between\_path\_nodes \({}^{***}\) ':' \\  & & **integer** \\ INVOLVED\_JOINTS & \(::=\) & \({}^{***}\) **involved\_joint \({}^{***}\) ':' type\_joint** \\ INTERACTION & \(::=\) & \({}^{***}\) **interaction \({}^{***}\) ':' \\  & & BLOCK\_INTERACTION \\ BLOCK\_INTERACTION & \(::=\) & '\(|\)' DEFINITION\_INTERACTION \(|\)'\\ DEFINITION\_INTERACTION & \(::=\) & TYPE'':' INTERACTION\_TIME \\ TYPE & \(::=\) & \({}^{***}\) **type\_interaction** \\ INTERACTION\_TIME & \(::=\) & \({}^{***}\) **interaction\_time \({}^{***}\) ':' integer** \\ ON\_REPT\_COMPLETED & \(::=\) & \({}^{***}\) **on\_repetition\_completed \({}^{***}\) ':' \\  & BLOCK\_ORC & \(::=\) & '\(|\)' REPETITION\_INCR ',' \\  & & SCORE\_INCR '\(\rangle\)'\\ REPETITION\_INCR & \(::=\) & \({}^{***}\) **repetition\_increment \({}^{***}\) ':' \\  & & **integer** \\ SCORE\_INCR & \(::=\) & \({}^{***}\) **score\_increment \({}^{***}\) ':' integer** \\ ON\_REPT\_FAILED & \(::=\) & \({}^{***}\) **on\_repetition\_failed \({}^{***}\) ':' \\  & & BLOCK\_ORF \\ BLOCK\_ORF & \(::=\) & '\(|\)' ACTION '\(|\)' \\ ACTION & \(::=\) & \({}^{***}\) **action \({}^{***}\) ':' type\_action** \\ \end{tabular}   
The attribute _id\_game\_dynamic_ identifies each one of the game dynamics available in the exergame. _id\_trajectory_ and _max\_time\_between\_path\_nodes_, contained in the each game dynamic, are related to its trajectory. The attribute _id\({}_{trajectory}\)_ contains the unique identifier of a virtual path previously defined in PEL (_trajectories_ component). PEL allows to set what should happen if this restriction is not met. To do this, the element _on\_repetition\_failed_ allows to set an callback action (attribute _action_), such as informing the patient that he/she must start the repetition again (value _retry_). The attribute _involved\_joint_ and the element _interaction_ are associated with the interaction mechanism. Thus, _involved\_joint_ allows for registering the joint that the system must monitor, while _interaction_ is used for specifying the type of interaction (_on-touch_ for a simple interaction, or hold for one that requires the patient to hold the position during a time defined in the attribute _interaction\_time_). Finally, PEL allows to define what happens when a repetition is completed or not in a game dynamic, thus providing feedback to the patient.