Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
clean-and-itasks
iTasks-SDK
Commits
413250ec
Commit
413250ec
authored
Sep 15, 2016
by
Jurriën Stutterheim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add C2 demo to Applications examples
parent
ec26688a
Changes
353
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
75 changed files
with
5283 additions
and
0 deletions
+5283
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Core.dcl
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Core.dcl
+9
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Core.icl
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Core.icl
+404
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Editor.dcl
...les/Applications/c2-demo/C2/Apps/ShipAdventure/Editor.dcl
+8
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Editor.icl
...les/Applications/c2-demo/C2/Apps/ShipAdventure/Editor.icl
+502
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Images.dcl
...les/Applications/c2-demo/C2/Apps/ShipAdventure/Images.dcl
+29
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Images.icl
...les/Applications/c2-demo/C2/Apps/ShipAdventure/Images.icl
+378
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/PathFinding.dcl
...pplications/c2-demo/C2/Apps/ShipAdventure/PathFinding.dcl
+15
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/PathFinding.icl
...pplications/c2-demo/C2/Apps/ShipAdventure/PathFinding.icl
+30
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Scripting.dcl
.../Applications/c2-demo/C2/Apps/ShipAdventure/Scripting.dcl
+37
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Scripting.icl
.../Applications/c2-demo/C2/Apps/ShipAdventure/Scripting.icl
+106
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Types.dcl
...ples/Applications/c2-demo/C2/Apps/ShipAdventure/Types.dcl
+212
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Types.icl
...ples/Applications/c2-demo/C2/Apps/ShipAdventure/Types.icl
+489
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Util.dcl
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Util.dcl
+7
-0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Util.icl
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Util.icl
+9
-0
Examples/Applications/c2-demo/C2/Framework/Common.dcl
Examples/Applications/c2-demo/C2/Framework/Common.dcl
+37
-0
Examples/Applications/c2-demo/C2/Framework/Common.icl
Examples/Applications/c2-demo/C2/Framework/Common.icl
+152
-0
Examples/Applications/c2-demo/C2/Framework/ContactPosition.dcl
...les/Applications/c2-demo/C2/Framework/ContactPosition.dcl
+74
-0
Examples/Applications/c2-demo/C2/Framework/ContactPosition.icl
...les/Applications/c2-demo/C2/Framework/ContactPosition.icl
+189
-0
Examples/Applications/c2-demo/C2/Framework/Core.dcl
Examples/Applications/c2-demo/C2/Framework/Core.dcl
+36
-0
Examples/Applications/c2-demo/C2/Framework/Core.icl
Examples/Applications/c2-demo/C2/Framework/Core.icl
+177
-0
Examples/Applications/c2-demo/C2/Framework/Entity.dcl
Examples/Applications/c2-demo/C2/Framework/Entity.dcl
+59
-0
Examples/Applications/c2-demo/C2/Framework/Entity.icl
Examples/Applications/c2-demo/C2/Framework/Entity.icl
+43
-0
Examples/Applications/c2-demo/C2/Framework/GeoRoutines.dcl
Examples/Applications/c2-demo/C2/Framework/GeoRoutines.dcl
+35
-0
Examples/Applications/c2-demo/C2/Framework/GeoRoutines.icl
Examples/Applications/c2-demo/C2/Framework/GeoRoutines.icl
+197
-0
Examples/Applications/c2-demo/C2/Framework/Logging.dcl
Examples/Applications/c2-demo/C2/Framework/Logging.dcl
+24
-0
Examples/Applications/c2-demo/C2/Framework/Logging.icl
Examples/Applications/c2-demo/C2/Framework/Logging.icl
+21
-0
Examples/Applications/c2-demo/C2/Framework/MapEnvironment.dcl
...ples/Applications/c2-demo/C2/Framework/MapEnvironment.dcl
+227
-0
Examples/Applications/c2-demo/C2/Framework/MapEnvironment.icl
...ples/Applications/c2-demo/C2/Framework/MapEnvironment.icl
+737
-0
Examples/Applications/c2-demo/C2/Framework/Util.dcl
Examples/Applications/c2-demo/C2/Framework/Util.dcl
+77
-0
Examples/Applications/c2-demo/C2/Framework/Util.icl
Examples/Applications/c2-demo/C2/Framework/Util.icl
+203
-0
Examples/Applications/c2-demo/C2/Framework/Workspace.dcl
Examples/Applications/c2-demo/C2/Framework/Workspace.dcl
+10
-0
Examples/Applications/c2-demo/C2/Framework/Workspace.icl
Examples/Applications/c2-demo/C2/Framework/Workspace.icl
+38
-0
Examples/Applications/c2-demo/C2/Navy/Roles/Commander.dcl
Examples/Applications/c2-demo/C2/Navy/Roles/Commander.dcl
+9
-0
Examples/Applications/c2-demo/C2/Navy/Roles/Commander.icl
Examples/Applications/c2-demo/C2/Navy/Roles/Commander.icl
+190
-0
Examples/Applications/c2-demo/C2/Navy/Roles/DOff.dcl
Examples/Applications/c2-demo/C2/Navy/Roles/DOff.dcl
+10
-0
Examples/Applications/c2-demo/C2/Navy/Roles/DOff.icl
Examples/Applications/c2-demo/C2/Navy/Roles/DOff.icl
+79
-0
Examples/Applications/c2-demo/C2/Navy/Roles/HVU.dcl
Examples/Applications/c2-demo/C2/Navy/Roles/HVU.dcl
+9
-0
Examples/Applications/c2-demo/C2/Navy/Roles/HVU.icl
Examples/Applications/c2-demo/C2/Navy/Roles/HVU.icl
+20
-0
Examples/Applications/c2-demo/C2/Navy/Roles/Sailor.dcl
Examples/Applications/c2-demo/C2/Navy/Roles/Sailor.dcl
+9
-0
Examples/Applications/c2-demo/C2/Navy/Roles/Sailor.icl
Examples/Applications/c2-demo/C2/Navy/Roles/Sailor.icl
+17
-0
Examples/Applications/c2-demo/C2/Navy/Roles/Simulator.dcl
Examples/Applications/c2-demo/C2/Navy/Roles/Simulator.dcl
+9
-0
Examples/Applications/c2-demo/C2/Navy/Roles/Simulator.icl
Examples/Applications/c2-demo/C2/Navy/Roles/Simulator.icl
+18
-0
Examples/Applications/c2-demo/C2/Navy/Roles/Suspect.dcl
Examples/Applications/c2-demo/C2/Navy/Roles/Suspect.dcl
+9
-0
Examples/Applications/c2-demo/C2/Navy/Roles/Suspect.icl
Examples/Applications/c2-demo/C2/Navy/Roles/Suspect.icl
+20
-0
Examples/Applications/c2-demo/Makefile
Examples/Applications/c2-demo/Makefile
+10
-0
Examples/Applications/c2-demo/WebPublic/Incidone.css
Examples/Applications/c2-demo/WebPublic/Incidone.css
+303
-0
Examples/Applications/c2-demo/WebPublic/icons/406mhz-message.png
...s/Applications/c2-demo/WebPublic/icons/406mhz-message.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/action-active.png
...es/Applications/c2-demo/WebPublic/icons/action-active.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/action-canceled.png
.../Applications/c2-demo/WebPublic/icons/action-canceled.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/action-completed.png
...Applications/c2-demo/WebPublic/icons/action-completed.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/action-compound.png
.../Applications/c2-demo/WebPublic/icons/action-compound.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/action-failed.png
...es/Applications/c2-demo/WebPublic/icons/action-failed.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/action-planned.png
...s/Applications/c2-demo/WebPublic/icons/action-planned.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/actions.png
Examples/Applications/c2-demo/WebPublic/icons/actions.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/ais.png
Examples/Applications/c2-demo/WebPublic/icons/ais.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/basic-information.png
...pplications/c2-demo/WebPublic/icons/basic-information.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/communication.png
...es/Applications/c2-demo/WebPublic/icons/communication.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/contact-airplane.png
...Applications/c2-demo/WebPublic/icons/contact-airplane.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/contact-diver.png
...es/Applications/c2-demo/WebPublic/icons/contact-diver.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/contact-helicopter.png
...plications/c2-demo/WebPublic/icons/contact-helicopter.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/contact-other.png
...es/Applications/c2-demo/WebPublic/icons/contact-other.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/contact-person.png
...s/Applications/c2-demo/WebPublic/icons/contact-person.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/contact-surfer.png
...s/Applications/c2-demo/WebPublic/icons/contact-surfer.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/contact-vessel.png
...s/Applications/c2-demo/WebPublic/icons/contact-vessel.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/contacts.png
Examples/Applications/c2-demo/WebPublic/icons/contacts.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/details.png
Examples/Applications/c2-demo/WebPublic/icons/details.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/dsc-message.png
...ples/Applications/c2-demo/WebPublic/icons/dsc-message.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/email-message.png
...es/Applications/c2-demo/WebPublic/icons/email-message.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/inbound.png
Examples/Applications/c2-demo/WebPublic/icons/inbound.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/incident.png
Examples/Applications/c2-demo/WebPublic/icons/incident.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/inmarsat-call.png
...es/Applications/c2-demo/WebPublic/icons/inmarsat-call.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/log.png
Examples/Applications/c2-demo/WebPublic/icons/log.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/map.png
Examples/Applications/c2-demo/WebPublic/icons/map.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/new.png
Examples/Applications/c2-demo/WebPublic/icons/new.png
+0
-0
Examples/Applications/c2-demo/WebPublic/icons/outbound.png
Examples/Applications/c2-demo/WebPublic/icons/outbound.png
+0
-0
No files found.
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Core.dcl
0 → 100644
View file @
413250ec
definition
module
C2
.
Apps
.
ShipAdventure
.
Core
import
iTasks
myTasks
::
[
Workflow
]
currentUserWalkAround
::
Task
()
giveInstructions
::
Task
()
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Core.icl
0 → 100644
View file @
413250ec
This diff is collapsed.
Click to expand it.
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Editor.dcl
0 → 100644
View file @
413250ec
definition
module
C2
.
Apps
.
ShipAdventure
.
Editor
import
iTasks
import
C2
.
Framework
.
MapEnvironment
import
C2
.
Apps
.
ShipAdventure
.
Types
shipEditorTabs
::
Task
()
sharedMapAction
::
RWShared
()
(
MapAction
SectionStatus
)
(
MapAction
SectionStatus
)
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Editor.icl
0 → 100644
View file @
413250ec
This diff is collapsed.
Click to expand it.
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Images.dcl
0 → 100644
View file @
413250ec
definition
module
C2
.
Apps
.
ShipAdventure
.
Images
import
C2
.
Framework
.
MapEnvironment
import
C2
.
Apps
.
ShipAdventure
.
Types
::
RenderMode
=
PickRoomMode
|
KitchenMode
|
WalkAroundMode
|
EditMode
|
DOffMode
derive
class
iTask
RenderMode
::
EditHilite
=
MapHilite
!
Maps2DIndex
|
SectionHilite
!
Maps2DIndex
!
Coord2D
mapTitleImage
::
!
Maps2DIndex
!(
Maybe
EditHilite
)
!
Size2D
!
String
->
Image
m
maps2DImage
::
!(
Set
Coord3D
)
!(
MapAction
SectionStatus
)
!
RenderMode
!
Maps2D
!
SectionExitLockMap
!
SectionHopLockMap
!
MySectionInventoryMap
!
MySectionStatusMap
!
SectionUsersMap
!(
UserActorMap
ObjectType
ActorStatus
)
!(
IntMap
Device
)
!
Network
!*
TagSource
->
Image
(
Maps2D
,
MapAction
SectionStatus
)
map2DImage
::
!(
Set
Coord3D
)
!(
MapAction
SectionStatus
)
!
RenderMode
!
SectionExitLockMap
!
SectionHopLockMap
!
MySectionInventoryMap
!
MySectionStatusMap
!
SectionUsersMap
!(
UserActorMap
ObjectType
ActorStatus
)
!(
IntMap
Device
)
!
Network
!(!
Maps2DIndex
,
!
Map2D
)
->
Image
(
Maps2D
,
MapAction
SectionStatus
)
roomImage
::
!
Coord3D
!
SectionExitLockMap
!
SectionHopLockMap
!
MyInventory
!
SectionStatus
!
MyActors
!(
IntMap
Device
)
!
Network
!
Bool
!
Section
!
Map2D
!(
MapAction
SectionStatus
)
!*
TagSource
->
Image
(
Maps2D
,
MapAction
SectionStatus
)
editLayoutImage
::
!(
MapAction
SectionStatus
)
!(
IntMap
Device
)
!
Network
!
MySectionInventoryMap
!
Maps2DIndex
!
Map2D
->
Image
(
Maps2D
,
MapAction
SectionStatus
)
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Images.icl
0 → 100644
View file @
413250ec
This diff is collapsed.
Click to expand it.
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/PathFinding.dcl
0 → 100644
View file @
413250ec
definition
module
C2
.
Apps
.
ShipAdventure
.
PathFinding
import
C2
.
Apps
.
ShipAdventure
.
Types
// given object to search for, current location and current map
smartShipPathToClosestObject
::
!
ObjectType
!
MySectionInventoryMap
!
Coord3D
!
Coord3D
!
MySectionStatusMap
!
SectionExitLockMap
!
SectionHopLockMap
!
Graph
->
(!
Maybe
MyObject
,
!
Int
,
!
Distance
,
!
Int
,
!(!
Coord3D
,
!
Distance
,
!
Maybe
[
Coord3D
]))
// given object to search for, current location, target room to move to with object, and current map
shipShortestPath
::
!
Coord3D
!
Coord3D
!
MySectionStatusMap
!
SectionExitLockMap
!
SectionHopLockMap
!
Graph
->
Maybe
(![
Coord3D
],
!
Distance
)
// shortest path given the alarms set on the ship
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/PathFinding.icl
0 → 100644
View file @
413250ec
implementation
module
C2
.
Apps
.
ShipAdventure
.
PathFinding
import
C2
.
Framework
.
MapEnvironment
import
C2
.
Apps
.
ShipAdventure
.
Types
// returns: distance, number of objects found, location of object, distance to object, shortest path to obejct
//shipPathToClosestObject :: Object Coord3D MyMap -> (Int,(Coord3D,Distance, Maybe ([Exit], Distance)))
//shipPathToClosestObject kind actorLoc curMap = pathToClosestObject shipShortestPath kind actorLoc curMap
smartShipPathToClosestObject
::
!
ObjectType
!
MySectionInventoryMap
!
Coord3D
!
Coord3D
!
MySectionStatusMap
!
SectionExitLockMap
!
SectionHopLockMap
!
Graph
->
(!
Maybe
MyObject
,
!
Int
,
!
Distance
,
!
Int
,
!(!
Coord3D
,
!
Distance
,
!
Maybe
[
Coord3D
]))
smartShipPathToClosestObject
kind
inventoryMap
actorLoc
targetLoc
statusMap
exitLocks
hopLocks
curMap
=
smartPathToClosestObject
shipShortestPath
kind
actorLoc
targetLoc
statusMap
inventoryMap
exitLocks
hopLocks
curMap
// shortest path given the alarms set on the ship
shipShortestPath
::
!
Coord3D
!
Coord3D
!
MySectionStatusMap
!
SectionExitLockMap
!
SectionHopLockMap
!
Graph
->
Maybe
(![
Coord3D
],
!
Distance
)
shipShortestPath
startCoord3D
endCoord3D
statusMap
exitLocks
hopLocks
graph
=
shortestPath
cost
startCoord3D
endCoord3D
statusMap
exitLocks
hopLocks
graph
where
cost
::
!
SectionStatus
->
Int
cost
status
=
1
+
statusCost
status
statusCost
::
!
SectionStatus
->
Int
statusCost
HasSomeWater
=
500
statusCost
IsFlooded
=
1000
statusCost
HasSmoke
=
400
statusCost
HasSmallFire
=
500
statusCost
HasMediumFire
=
750
statusCost
HasBigFire
=
1000
statusCost
_
=
0
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Scripting.dcl
0 → 100644
View file @
413250ec
definition
module
C2
.
Apps
.
ShipAdventure
.
Scripting
import
iTasks
import
C2
.
Apps
.
ShipAdventure
.
Types
// script language
::
Target
=
Section
Coord3D
|
Nearest
ObjectType
|
TargetSection
::
Script
=
MoveTo
Target
|
Take
ObjectType
|
Drop
ObjectType
|
Use
ObjectType
|
ReSetTargetDetector
|
If
Condition
[
Script
]
[
Script
]
::
Condition
=
ObjectInCurrentSection
ObjectType
|
CarriesObject
ObjectType
|
ActorStatus
ActorStatus
|
And
Condition
Condition
|
Or
Condition
Condition
derive
class
iTask
Target
,
Script
,
Condition
handleFireScript
::
Shared
[
Script
]
handleFloodScript
::
Shared
[
Script
]
handleSmokeScript
::
Shared
[
Script
]
changeFireScript
::
Task
()
changeFloodScript
::
Task
()
changeSmokeScript
::
Task
()
interperScript
::
!(!
Coord3D
,
!
SectionStatus
)
!
User
![
Script
]
->
Task
Bool
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Scripting.icl
0 → 100644
View file @
413250ec
implementation
module
C2
.
Apps
.
ShipAdventure
.
Scripting
import
iTasks
import
C2
.
Apps
.
ShipAdventure
.
Types
import
C2
.
Apps
.
ShipAdventure
.
PathFinding
import
C2
.
Apps
.
ShipAdventure
.
Util
import
qualified
Data
.
IntMap
.
Strict
as
DIS
import
qualified
Data
.
Map
as
DM
// scripted simulation
derive
class
iTask
Target
,
Script
,
Condition
handleFireScript
::
Shared
[
Script
]
handleFireScript
=
sharedStore
"handleFireScript"
[]
handleFloodScript
::
Shared
[
Script
]
handleFloodScript
=
sharedStore
"handleFloodScript"
[]
handleSmokeScript
::
Shared
[
Script
]
handleSmokeScript
=
sharedStore
"handleSmokeScript"
[]
changeFireScript
::
Task
()
changeFireScript
=
changeScript
"Handling Fire"
handleFireScript
changeFloodScript
::
Task
()
changeFloodScript
=
changeScript
"Handling Flood"
handleFloodScript
changeSmokeScript
::
Task
()
changeSmokeScript
=
changeScript
"Handling Smoke"
handleSmokeScript
changeScript
::
!
String
!(
Shared
[
Script
])
->
Task
()
changeScript
prompt
script
=
viewSharedInformation
(
"Current Script: "
<+++
prompt
)
[
ViewAs
(\
script
->
[
toString
i
+++
" : "
+++
line
\\
line
<-
map
toSingleLineText
script
&
i
<-
[
1
..]])]
script
>>*
[
OnAction
(
Action
"Fine"
[])
(
always
(
return
()))
,
OnAction
(
Action
"Change"
[])
(
always
(
updateSharedInformation
(
"Change Script: "
<+++
prompt
)
[]
script
>>|
changeScript
prompt
script
))
]
interperScript
::
!(!
Coord3D
,
!
SectionStatus
)
!
User
![
Script
]
->
Task
Bool
interperScript
(
targetSection
,
status
)
user
script
=
get
(
sectionUsersShare
|*|
myUserActorMap
)
>>-
\(
sectionUsersMap
,
userActorMap
)
->
case
findUser
user
sectionUsersMap
userActorMap
of
Just
user
->
perform
script
user
_
->
return
False
where
perform
::
![
Script
]
!(!
Coord3D
,
!
MyActor
)
->
Task
Bool
perform
[]
_
=
return
True
perform
[
MoveTo
target
:
next
]
(
actorLoc
,
actor
)
=
get
(
myStatusMap
|*|
myInventoryMap
|*|
lockedExitsShare
|*|
lockedHopsShare
|*|
sharedGraph
)
>>-
\((((
statusMap
,
invMap
),
exitLocks
),
hopLocks
),
graph
)
->
let
newLoc
=
whereIs
targetSection
target
actorLoc
statusMap
invMap
exitLocks
hopLocks
graph
in
autoMove
actorLoc
newLoc
shipShortestPath
actor
.
userName
myStatusMap
myUserActorMap
>>|
perform
next
(
newLoc
,
actor
)
perform
[
Take
objType`
:
next
]
(
actorLoc
,
actor
)
=
get
myInventoryMap
>>-
\
invMap
->
case
'
DM
'.
get
actorLoc
invMap
of
Just
inv
=
case
[
obj
\\
obj
=:{
Object
|
objType
}
<-
'
DIS
'.
elems
inv
|
objType`
==
objType
]
of
[
obj
:
_]
=
pickupObject
actorLoc
obj
actor
.
userName
myUserActorMap
inventoryInSectionShare
>>|
perform
next
(
actorLoc
,
actor
)
_
=
perform
next
(
actorLoc
,
actor
)
_
=
perform
next
(
actorLoc
,
actor
)
perform
[
Drop
objType`
:
next
]
(
actorLoc
,
actor
)
=
case
[
obj
\\
obj
=:{
Object
|
objType
}
<-
actor
.
carrying
|
objType`
==
objType
]
of
[
obj
:
_]
=
dropObject
actorLoc
obj
actor
.
userName
myUserActorMap
inventoryInSectionShare
>>|
perform
next
(
actorLoc
,
actor
)
_
=
perform
next
(
actorLoc
,
actor
)
perform
[
Use
objType`
:
next
]
(
actorLoc
,
actor
)
=
case
[
obj
\\
obj
=:{
Object
|
objType
}
<-
actor
.
carrying
|
objType`
==
objType
]
of
[
obj
:
_]
=
useObject
actorLoc
obj
actor
.
userName
myUserActorMap
inventoryInSectionShare
>>|
perform
next
(
actorLoc
,
actor
)
_
=
perform
next
(
actorLoc
,
actor
)
perform
[
ReSetTargetDetector
:
next
]
(
actorLoc
,
actor
)
=
setAlarm
actor
.
userName
(
targetSection
,
NormalStatus
)
myStatusMap
>>|
perform
next
(
actorLoc
,
actor
)
perform
[
If
condition
script1
script2
:
next
]
(
actorLoc
,
actor
)
=
get
myInventoryMap
>>=
\
invMap
->
case
'
DM
'.
get
actorLoc
invMap
of
Just
inv
|
isTrue
('
DIS
'.
elems
inv
)
condition
(
actorLoc
,
actor
)
=
perform
(
script1
++
next
)
(
actorLoc
,
actor
)
_
=
perform
(
script2
++
next
)
(
actorLoc
,
actor
)
isTrue
::
![
MyObject
]
!
Condition
!(!
Coord3D
,
!
MyActor
)
->
Bool
isTrue
inv
(
ObjectInCurrentSection
object
)
(
actorLoc
,
actor
)
=
objTypeInList
object
inv
isTrue
inv
(
CarriesObject
object
)
(
actorLoc
,
actor
)
=
isCarrying
object
actor
isTrue
inv
(
ActorStatus
status
)
(
actorLoc
,
actor
)
=
status
===
actor
.
actorStatus
isTrue
inv
(
And
cond1
cond2
)
(
actorLoc
,
actor
)
=
and
[
isTrue
inv
cond1
(
actorLoc
,
actor
),
isTrue
inv
cond2
(
actorLoc
,
actor
)]
isTrue
inv
(
Or
cond1
cond2
)
(
actorLoc
,
actor
)
=
or
[
isTrue
inv
cond1
(
actorLoc
,
actor
),
isTrue
inv
cond2
(
actorLoc
,
actor
)]
whereIs
::
Coord3D
!
Target
Coord3D
MySectionStatusMap
MySectionInventoryMap
SectionExitLockMap
SectionHopLockMap
Graph
->
Coord3D
whereIs
_
(
Section
nr
)
_
_
_
_
_
_
=
nr
whereIs
targetSection
(
Nearest
object
)
actorLoc
statusMap
inventoryMap
exitLocks
hopLocks
graph
#!
(_,_,_,_,(
objectLoc
,_,_))
=
smartShipPathToClosestObject
object
inventoryMap
actorLoc
targetSection
statusMap
exitLocks
hopLocks
graph
=
objectLoc
whereIs
targetSection
TargetSection
_
_
_
_
_
_
=
targetSection
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Types.dcl
0 → 100644
View file @
413250ec
definition
module
C2
.
Apps
.
ShipAdventure
.
Types
import
C2
.
Framework
.
MapEnvironment
import
GenLexOrd
from
C2
.
Apps
.
ShipAdventure
.
Images
import
::
RenderMode
::
MyActor
:==
Actor
ObjectType
ActorStatus
::
MyObject
:==
Object
ObjectType
::
MySectionStatusMap
:==
SectionStatusMap
SectionStatus
::
MySectionInventoryMap
:==
SectionInventoryMap
ObjectType
::
MyInventory
:==
IntMap
(
Object
ObjectType
)
::
MyActors
:==
[
Actor
ObjectType
ActorStatus
]
::
MyDrawMapForActor
:==
DrawMapForActor
SectionStatus
ObjectType
ActorStatus
::
SectionStatus
=
NormalStatus
|
HasSomeWater
|
IsFlooded
|
HasSmoke
|
HasSmallFire
|
HasMediumFire
|
HasBigFire
::
ObjectType
=
FireExtinguisher
|
FireBlanket
|
Plug
::
ActorStatus
=
{
occupied
::
!
Availability
,
health
::
!
ActorHealth
,
energy
::
!
ActorEnergy
}
::
Availability
=
Available
|
NotAvailable
|
Busy
::
ActorHealth
=
FullHealth
|
AScratch
|
CompletelyWorn
::
ActorEnergy
=
FullEnergy
|
SomewhatTired
|
Fatigued
::
Priority
=
Low
|
Normal
|
High
|
Highest
// logical devices
::
DeviceType
=
{
kind
::
!
DeviceKind
,
requires
::
!
Map
CableType
Capacity
,
produces
::
!
Map
CableType
Capacity
}
::
DeviceKind
=
Radar
|
Apar
|
Sonar
|
Hydrophone
|
Radio
|
PowerGenerator
|
CoolingPump
|
Gun
|
GasTurbine
|
DieselEngine
|
SmokeDetector
|
HeatSensor
|
WaterSensor
::
CableType
=
PowerCable
|
CoolingPipe
|
DataCable
::
Capacity
:==
Int
// physical devices
::
Network
=
{
devices
::
!
Map
Coord3D
[
DeviceId
]
// [Coord3D |-> DeviceIds]
,
cables
::
!
IntMap
Cable
// [CableId |-> Cable]
,
cableMapping
::
!
IntMap
[(!
Operational
,
!
Coord3D
)]
// [CableId |-> Coord3Ds]
}
::
Device
=
{
description
::
!
String
,
deviceType
::
!
DeviceType
,
deviceId
::
!
DeviceId
,
inCables
::
![
CableId
]
,
outCables
::
![
CableId
]
}
::
DeviceId
:==
Int
::
CableId
:==
Int
::
Cable
=
// Edge
{
description
::
!
String
,
cableId
::
!
CableId
,
capacity
::
!
Capacity
,
cableType
::
!
CableType
}
::
Operational
:==
Bool
::
PPDevice
=
{
description
::
!
String
,
deviceType
::
!
PPDeviceType
,
deviceId
::
!
DeviceId
,
inCables
::
![
CableId
]
,
outCables
::
![
CableId
]
}
::
PPDeviceType
=
{
kind
::
!
DeviceKind
,
requires
::
![(!
CableType
,
!
Capacity
)]
,
produces
::
![(!
CableType
,
!
Capacity
)]
}
::
CommandAim
=
{
aimDescription
::
!
String
,
requiredCapabilities
::
![
Capability
]
}
::
Capability
=
Propulsion
|
RadioCommunication
|
SatelliteCommunication
|
AirSensors
|
SurfaceSensors
|
SubsurfaceSensors
|
SurfaceToAirOffence
|
SurfaceToSurfaceOffence
|
SurfaceToSubsurfaceOffence
|
AirDefence
|
SurfaceDefence
|
SubsurfaceDefence
::
CapabilityExpr
=
DeviceExpr
DeviceKind
|
CapAndExpr
CapabilityExpr
CapabilityExpr
|
CapOrExpr
CapabilityExpr
CapabilityExpr
::
CapabilityToDeviceKindMap
:==
Map
Capability
CapabilityExpr
derive
class
iTask
PPDevice
,
PPDeviceType
,
CommandAim
,
Capability
,
CapabilityExpr
derive
gLexOrd
CableType
,
Capability
derive
class
iTask
ObjectType
,
ActorStatus
,
Availability
,
ActorHealth
,
ActorEnergy
,
DeviceType
,
SectionStatus
derive
class
iTask
Cable
,
Priority
,
Network
,
Device
,
CableType
,
DeviceKind
instance
==
ObjectType
instance
==
Priority
instance
==
CableType
instance
==
Device
instance
==
DeviceType
instance
==
DeviceKind
instance
==
Capability
instance
<
CableType
instance
<
Capability
instance
toString
ObjectType
//instance toString Exit
instance
toString
SectionStatus
instance
toString
Device
// shared stores:
myUserActorMap
::
UserActorShare
ObjectType
ActorStatus
myStatusMap
::
RWShared
()
MySectionStatusMap
MySectionStatusMap
myInventoryMap
::
RWShared
()
MySectionInventoryMap
MySectionInventoryMap
myNetwork
::
RWShared
()
Network
Network
myCables
::
RWShared
()
(
IntMap
Cable
)
(
IntMap
Cable
)
myDevices
::
RWShared
()
(
IntMap
Device
)
(
IntMap
Device
)
commandAims
::
RWShared
()
[
CommandAim
]
[
CommandAim
]
capabilityMap
::
RWShared
()
CapabilityToDeviceKindMap
CapabilityToDeviceKindMap
disabledSections
::
RWShared
()
(
Set
Coord3D
)
(
Set
Coord3D
)
deviceKindsForCapability
::
RWShared
Capability
CapabilityExpr
CapabilityExpr
statusInSectionShare
::
RWShared
Coord3D
SectionStatus
SectionStatus
inventoryInSectionShare
::
FocusedSectionInventoryShare
ObjectType
deviceIdInNetworkSectionShare
::
RWShared
Coord3D
[
DeviceId
]
[
DeviceId
]
devicesInSectionShare
::
RWShared
Coord3D
[
Device
]
[
Device
]
deviceWithIdShare
::
RWShared
DeviceId
Device
Device
cableWithIdShare
::
RWShared
CableId
Cable
Cable
cablesInSectionShare
::
RWShared
Coord3D
[
Cable
]
[
Cable
]
cablesForSection
::
!
Coord3D
!
Network
->
[
Cable
]
allActiveAlarms
::
ReadOnlyShared
[(!
Coord3D
,
!
SectionStatus
)]
allAvailableActors
::
ReadOnlyShared
[(!
Coord3D
,
!
MyActor
)]
// setting and resetting of the detection systems:
setAlarm
::
!
User
!(!
Coord3D
,
!
SectionStatus
)
!(
Shared
MySectionStatusMap
)
->
Task
()
// making images from a map
setSectionDetectors
::
Task
()
cutCable
::
!
Coord3D
!
CableId
!
Network
->
Network
patchCable
::
!
Coord3D
!
CableId
!
Network
->
Network
viewDisabledDevices
::
Task
()
hasFire
::
!
SectionStatus
->
Bool
hasSmoke
::
!
SectionStatus
->
Bool
hasWater
::
!
SectionStatus
->
Bool
deviceIsEnabled
::
!
Device
!(
IntMap
Device
)
!
Network
->
Bool
isDetector
::
!
DeviceKind
->
Bool
updateMapStatus
::
!
RenderMode
->
Task
(
MapAction
SectionStatus
)
allDisabledDevices
::
!(
IntMap
Device
)
!
Network
->
[
Device
]
allImperiledCommandAims
::
!(
IntMap
Device
)
!
CapabilityToDeviceKindMap
![
CommandAim
]
!
Network
->
[
CommandAim
]
deviceIsDisabledInSection
::
!
Coord3D
!
Device
!(
IntMap
Device
)
!
Network
->
Bool
isOperational
::
!
CableId
!(
IntMap
[(!
Operational
,
!
Coord3D
)])
->
Bool
devicesForCable
::
!
Cable
!(
IntMap
Device
)
!
Network
->
[
Device
]
devicesForCableInSection
::
!
Coord3D
!
Cable
!(
IntMap
Device
)
!
Network
->
[
Device
]
toPPDevice
::
!
Device
->
PPDevice
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Types.icl
0 → 100644
View file @
413250ec
This diff is collapsed.
Click to expand it.
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Util.dcl
0 → 100644
View file @
413250ec
definition
module
C2
.
Apps
.
ShipAdventure
.
Util
import
C2
.
Apps
.
ShipAdventure
.
Types
isCarrying
::
!
ObjectType
!
MyActor
->
Bool
objTypeInList
::
!
ObjectType
![
MyObject
]
->
Bool
Examples/Applications/c2-demo/C2/Apps/ShipAdventure/Util.icl
0 → 100644
View file @
413250ec
implementation
module
C2
.
Apps
.
ShipAdventure
.
Util
import
C2
.
Apps
.
ShipAdventure
.
Types
isCarrying
::
!
ObjectType
!
MyActor
->
Bool
isCarrying
objType`
{
Actor
|
carrying
}
=
objTypeInList
objType`
carrying
objTypeInList
::
!
ObjectType
![
MyObject
]
->
Bool
objTypeInList
objType`
objs
=
length
[
0
\\
{
Object
|
objType
}
<-
objs
|
objType
==
objType`
]
>
0
Examples/Applications/c2-demo/C2/Framework/Common.dcl
0 → 100644
View file @
413250ec
definition
module
C2
.
Framework
.
Common
import
iTasks
from
Data
.
IntMap
.
Strict
import
::
IntMap
from
C2
.
Framework
.
Entity
import
::
Entity
from
C2
.
Framework
.
ContactPosition
import
::
ContactMapPerspective
::
EntityMap
:==
IntMap
Entity
::
MapState
=
{
perspective
::
ContactMapPerspective
,
entities
::
IntMap
Entity
,
selection
::
Int
}
derive
class
iTask
MapState
mapState
::
RWShared
()
MapState
MapState
entityMap
::
RWShared
()
EntityMap
EntityMap
registerEntity
::
(
Int
->
Entity
)
->
Task
Entity
updateEntity
::
Int
(
Entity
->
Entity
)
->
Task
()
contactWithId
::
RWShared
Int
(
Maybe
Entity
)
Entity
selectedContactShare
::
RWShared
()
(
Maybe
Entity
)
Entity
resetMapState
::
Task
()
periodicallyUpdateEntity
::
!
Int
->
Task
()
mapView
::
(
RWShared
()
r
w
)
(
r
->
Bool
)
User
[
Entity
]
->
Task
()
|
iTask
r
userMapState
::
User
->
Shared
MapState