Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Order ID in prepare msg and score automatically #16

Merged
merged 54 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7ff80b2
msgs: add order slot to DS instructions
morxa Jan 18, 2019
1716d0a
rcll: store info about last delivered order in machine fact
morxa Jan 20, 2019
b80965d
rcll: directly assert product-delivered fact on delivery at DS
morxa Jan 20, 2019
6041924
rcll: process SetOrderDelivered msg by setting the delivery to confirmed
morxa Jan 20, 2019
0517d20
rcll: always base scoring on order ID, not on colors
morxa Jan 20, 2019
c78efdd
rcll: fix score computation when computing score based on order ID
morxa Jan 21, 2019
dbbfd2a
rcll: use delivery time for scoring, not current game time
morxa Jan 21, 2019
02b99e2
rcll: add scoring for late delivery on ID confirmation
morxa Jan 21, 2019
3025a46
rcll: also process OrderDelivered message in post-game
morxa Jan 21, 2019
9037648
shell: do not show deliver menu by color, directly go to menu by ID
morxa Jan 21, 2019
38105b2
rcll: also send the order_id in DS machine state message
morxa Jan 21, 2019
8147704
rcll-prepare-machine: also send order ID in prepare msg for DS
morxa Jan 21, 2019
bf61404
rcll: send delivery msg if a new unconfirmed delivery occurred
morxa Jan 21, 2019
19a461e
rcll: add utils function to generate a unique uint ID
morxa Jan 22, 2019
7a7c63e
rcll: add ID slot to product-delivered deftemplate
morxa Jan 22, 2019
155c6fe
msgs: add message for an unconfirmed delivery
morxa Jan 22, 2019
6f306c4
shell: remove unused func to send info about delivery by color
morxa Jan 22, 2019
90d273d
msgs: remove unused SetOrderDeliveredByColor message
morxa Jan 22, 2019
f7e8f54
msgs: replace SetOrderDelivered msg by ConfirmDelivery msg
morxa Jan 22, 2019
cdb9256
shell: store UnconfirmedDelivery messages received from the refbox
morxa Jan 22, 2019
881bdd9
rcll: move gen-int-id function into facts
morxa Jan 23, 2019
95f9811
rcll: fix slot type for slot id of product-delivered deftemplate
morxa Jan 23, 2019
176de0c
rcll: expect a ConfirmDelivery message for delivery confirmation
morxa Jan 23, 2019
13cda2f
shell: only show unconfirmed deliveries in OrderDeliverMenu
morxa Jan 24, 2019
c59bf55
shell: show correct order configuration in OrderDeliverMenu
morxa Jan 24, 2019
743032c
shell: do not show confirmed deliveries in OrderDeliverMenu
morxa Jan 24, 2019
d895e79
shell: add a menu after the delivery menu to ask for a correct delivery
morxa Jan 24, 2019
b074637
shell: fix time display in delivery menu
morxa Jan 24, 2019
4e9fe55
shell: do not show deliveries without an order in DeliveryMenu
morxa Jan 24, 2019
e72be1b
shell: only show deliveries of the selected team in OrderDeliverMenu
morxa Jan 24, 2019
95485a7
rcll: do not give points for incorrect deliveries
morxa Jan 24, 2019
eb94561
shell: fix array access in OrderDeliverMenu
morxa Jan 24, 2019
699d0ee
rcll-prepare-machine: make sure we have the right #args for the DS
morxa Jan 24, 2019
1b3a36f
rcll-prepare-machine: switch the order of arguments for the DS
morxa Jan 24, 2019
23038f8
rcll: only process OrderDelivered msg when in PRODUCTION or POST_GAME
morxa Jan 25, 2019
a68a436
rcll: also compute score when not in PRODUCTION or not RUNNING
morxa Jan 25, 2019
d2f9098
rcll: base decision whether the delivery was too early on delivery time
morxa Jan 25, 2019
90ec209
rcll: only print game summary after all deliveries have been confirmed
morxa Jan 25, 2019
e9dcd55
rcll: improve msg in case of incorrect delivery, fix wrong parentheses
morxa Jan 25, 2019
2a1fb87
shell: show "UNKNOWN" in OrderDeliverMenu if order cannot be found
morxa Jan 25, 2019
2feb3ef
shell: show "UNKNOWN" in DeliveryCorrectMenu if order cannot be found
morxa Jan 25, 2019
2d674a3
msgs: add back SetOrderDelivered message
morxa Jan 25, 2019
516fc1f
rcll: process SetOrderDelivered message
morxa Jan 25, 2019
e2b8699
shell: add show-all option to OrderDeliverMenu
morxa Jan 25, 2019
d8f26e1
shell: add (back) SelectOrderByIDMenu
morxa Jan 25, 2019
bd1fb3f
shell: show SelectOrderByIDMenu if SHOWALL is selected in DeliveryMenu
morxa Jan 25, 2019
d8bace1
rcll: make sure do-for-fact evaluates to TRUE in ConfirmDelivery check
morxa Jan 26, 2019
ee71cc9
msgs: make UnconfirmedDelivery a repeated sub-field of the order
morxa Feb 14, 2019
451d9c2
rcll: send unconfirmed deliveries as part of the OrderInfo
morxa Feb 14, 2019
067cc1e
msgs: only keep one list of unconfirmed deliveries
morxa Feb 14, 2019
2e20967
shell: use nested unconfirmed deliveries from OrderInfo
morxa Feb 14, 2019
2429c3d
rcll: only create a single list of unconfirmed deliveries
morxa Feb 14, 2019
691d1f0
shell: fix position and width of OrderDeliverMenu
morxa Feb 14, 2019
055c72a
rcll: improve readability of do-for-all-facts in net-create-Order
morxa Apr 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/games/rcll/facts.clp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

(slot ds-gate (type INTEGER))
(slot ds-last-gate (type INTEGER))
(slot ds-order (type INTEGER))

(slot ss-operation (type SYMBOL) (allowed-values STORE RETRIEVE))
(multislot ss-slot (type INTEGER) (cardinality 3 3)) ; meaning defined in llsf_msgs.SSSlot
Expand Down Expand Up @@ -215,11 +216,19 @@
(multislot period (type INTEGER) (cardinality 2 2))
)

(deffunction gen-int-id ()
"Generate a unique uint that can be used as an ID."
(bind ?id-string (str-cat (gensym*)))
(return (string-to-field (sub-string 4 (length$ ?id-string) ?id-string)))
)

(deftemplate product-delivered
(slot id (type INTEGER) (default-dynamic (gen-int-id)))
(slot game-time (type FLOAT))
(slot order (type INTEGER) (default 0))
(slot team (type SYMBOL) (allowed-values nil CYAN MAGENTA))
(slot delivery-gate (type INTEGER))
(slot confirmed (type SYMBOL) (allowed-values FALSE TRUE) (default FALSE))
(slot base-color (type SYMBOL) (allowed-values BASE_RED BASE_SILVER BASE_BLACK))
(multislot ring-colors (type SYMBOL) (cardinality 0 3)
(allowed-values RING_BLUE RING_GREEN RING_ORANGE RING_YELLOW))
Expand Down
23 changes: 20 additions & 3 deletions src/games/rcll/game.clp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@
(game-print-points-team MAGENTA)
)

(deffunction game-summary ()
(game-print-points)
(assert (attention-message (text "Game Over") (time 60)))
(printout t "=== Game Over ===" crlf)
)

(defrule game-over
?gs <- (gamestate (refbox-mode STANDALONE) (phase PRODUCTION) (state RUNNING)
(over-time FALSE) (points ?p-cyan ?p-magenta&:(<> ?p-cyan ?p-magenta))
Expand Down Expand Up @@ -357,7 +363,18 @@
(delayed-do-for-all-facts ((?machine machine)) TRUE
(modify ?machine (desired-lights RED-BLINK))
)
(game-print-points)
(assert (attention-message (text "Game Over") (time 60)))
(printout t "=== Game Over ===" crlf)
(if (any-factp ((?pd product-delivered)) TRUE) then
(assert (attention-message (text "Game ended, please confirm deliveries!")))
(assert (postgame-for-unconfirmed-deliveries))
else
(game-summary)
)
)

(defrule game-postgame-no-unconfirmed-deliveries
?w <- (postgame-for-unconfirmed-deliveries)
(not (product-delivered))
=>
(retract ?w)
(game-summary)
)
21 changes: 21 additions & 0 deletions src/games/rcll/net.clp
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@
(case DS then
(bind ?pm (pb-create "llsf_msgs.PrepareInstructionDS"))
(pb-set-field ?pm "gate" (fact-slot-value ?mf ds-gate))
(pb-set-field ?pm "order_id" (fact-slot-value ?mf ds-order))
(pb-set-field ?m "instruction_ds" ?pm)
)
(case SS then
Expand Down Expand Up @@ -580,6 +581,19 @@
(pb-destroy ?s)
)

(deffunction net-create-UnconfirmedDelivery (?id ?team ?time)
(bind ?msg (pb-create "llsf_msgs.UnconfirmedDelivery"))
(pb-set-field ?msg "id" ?id)
(pb-set-field ?msg "team" ?team)
(bind ?delivery-time (pb-field-value ?msg "delivery_time"))
(if (eq (type ?delivery-time) EXTERNAL-ADDRESS) then
(bind ?gt (time-from-sec ?time))
(pb-set-field ?delivery-time "sec" (nth$ 1 ?gt))
(pb-set-field ?delivery-time "nsec" (integer (* (nth$ 2 ?gt) 1000)))
(pb-set-field ?msg "delivery_time" ?delivery-time) ; destroys ?delivery-time!
)
(return ?msg)
)

(deffunction net-create-Order (?order-fact)
(bind ?o (pb-create "llsf_msgs.Order"))
Expand All @@ -603,6 +617,13 @@
(pb-set-field ?o "delivery_period_end"
(nth$ 2 (fact-slot-value ?order-fact delivery-period)))

(do-for-all-facts
((?delivery product-delivered))
(and (eq ?delivery:confirmed FALSE) (eq ?delivery:order (fact-slot-value ?order-fact id)))

(bind ?d (net-create-UnconfirmedDelivery ?delivery:id ?delivery:team ?delivery:game-time))
(pb-add-list ?o "unconfirmed_deliveries" ?d)
)
(return ?o)
)

Expand Down
Loading