From ac51969cc52a9fdfdc50a8d893c03cf90b76a926 Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Tue, 16 Apr 2019 17:14:22 +0200 Subject: [PATCH 1/5] rcll: allow two maintenances per bot --- src/games/rcll/globals.clp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/games/rcll/globals.clp b/src/games/rcll/globals.clp index 090cd60e0..ffb1254e0 100644 --- a/src/games/rcll/globals.clp +++ b/src/games/rcll/globals.clp @@ -84,7 +84,7 @@ ?*TECHCHALL-WAM-TIME* = 300 ?*TECHCHALL-NAVIGATION-TIME* = 60 ; number of allowed robot maintenance cycles - ?*MAINTENANCE-ALLOWED-CYCLES* = 1 + ?*MAINTENANCE-ALLOWED-CYCLES* = 2 ?*MAINTENANCE-ALLOWED-TIME* = 120 ?*MAINTENANCE-WARN-TIME* = 105 ?*MAINTENANCE-GRACE-TIME* = 15 From 7dc8e106deeb876bef529f9c1614b04573a872b0 Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Tue, 16 Apr 2019 18:06:05 +0200 Subject: [PATCH 2/5] rcll: deduct 5 points for second maintenance Introduce a global constant multi-slot ?*MAINTENANCE-COST*, where the nth slot defines the cost for the nth maintenance of a robot. Deduct those points when receiving a robot maintenance message. --- src/games/rcll/globals.clp | 1 + src/games/rcll/robots.clp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/games/rcll/globals.clp b/src/games/rcll/globals.clp index ffb1254e0..a2521b5cf 100644 --- a/src/games/rcll/globals.clp +++ b/src/games/rcll/globals.clp @@ -85,6 +85,7 @@ ?*TECHCHALL-NAVIGATION-TIME* = 60 ; number of allowed robot maintenance cycles ?*MAINTENANCE-ALLOWED-CYCLES* = 2 + ?*MAINTENANCE-COST* = (create$ 0 5) ?*MAINTENANCE-ALLOWED-TIME* = 120 ?*MAINTENANCE-WARN-TIME* = 105 ?*MAINTENANCE-GRACE-TIME* = 15 diff --git a/src/games/rcll/robots.clp b/src/games/rcll/robots.clp index 9c9765719..ea8b2aa59 100644 --- a/src/games/rcll/robots.clp +++ b/src/games/rcll/robots.clp @@ -85,7 +85,7 @@ (defrule robot-recv-SetRobotMaintenance ?pf <- (protobuf-msg (type "llsf_msgs.SetRobotMaintenance") (ptr ?p) (rcvd-via STREAM)) - (gamestate (cont-time ?ctime)) + (gamestate (cont-time ?ctime) (game-time ?game-time)) => (retract ?pf) ; message will be destroyed after rule completes (do-for-fact ((?robot robot)) @@ -99,6 +99,14 @@ (printout t "Robot " ?robot:number " scheduled for maintenance cycle " ?cycle crlf) (modify ?robot (state MAINTENANCE) (maintenance-start-time ?ctime) (maintenance-cycles ?cycle) (maintenance-warning-sent FALSE)) + (bind ?cycle-cost (nth$ ?cycle ?*MAINTENANCE-COST*)) + (if (neq ?cycle-cost nil) + then + (assert (points (game-time ?game-time) + (points (* -1 ?cycle-cost)) + (team ?robot:team-color) (phase PRODUCTION) + (reason (str-cat "Maintenance of robot " ?robot:number)))) + ) ) else (bind ?maint-time (- ?ctime ?robot:maintenance-start-time)) From ae15a28dd8137d71eadd0670660cf6406227ccaa Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Tue, 16 Apr 2019 18:07:43 +0200 Subject: [PATCH 3/5] rcll: adapt wording of score message for negative points We may now also have negative points, "Awarding -5 points" sounds awkward, say "Giving -5 points" instead. --- src/games/rcll/orders.clp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/games/rcll/orders.clp b/src/games/rcll/orders.clp index ea36c272f..c7fec7d01 100644 --- a/src/games/rcll/orders.clp +++ b/src/games/rcll/orders.clp @@ -233,6 +233,6 @@ (defrule order-print-points (points (game-time ?gt) (points ?points) (team ?team) (phase ?phase) (reason ?reason)) => - (printout t "Awarding " ?points " points to team " ?team ": " ?reason + (printout t "Giving " ?points " points to team " ?team ": " ?reason " (" ?phase " @ " ?gt ")" crlf) ) From 86638d2b24b32bd348c72fc6694853f0dc59f192 Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Tue, 16 Apr 2019 18:39:17 +0200 Subject: [PATCH 4/5] shell: show number of maintenances taken instead of exclamation mark A robot possibly may have had multiple maintenances. Instead of showing an exclamation mark if it has taken a maintenance, show the number of maintenances taken. If it is larger than zero, show the number in red. --- src/shell/robot.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shell/robot.cpp b/src/shell/robot.cpp index 8ad5fd8b5..5be0434cc 100644 --- a/src/shell/robot.cpp +++ b/src/shell/robot.cpp @@ -149,13 +149,13 @@ LLSFRefBoxShellRobot::refresh() printw(1, width() - 5, "%s", RobotState_Name(state_).substr(0,3).c_str()); standend(); + attron(A_BOLD); if (maintenance_cycles_ > 0) { - attron(A_BOLD); attron(' '|COLOR_PAIR(COLOR_RED_ON_BACK)); - //mvwaddwstr(w, 1, width() - 1, L"\u26a0"); - printw(1, width() - 1, "!"); - standend(); } + //mvwaddwstr(w, 1, width() - 1, L"\u26a0"); + printw(1, width() - 1, "%1i", maintenance_cycles_); + standend(); } else { bkgd(' '|COLOR_PAIR(COLOR_DEFAULT)); From eb382ad4a953a2631f1ab771f3ac5529823995fa Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Wed, 17 Apr 2019 16:16:40 +0200 Subject: [PATCH 5/5] rcll: assign point deduction for maintenance to the correct game phase We can also have a robot maintenance during exploration. In that case, the points should be deducted from the exploration points, not from the production points. Co-Authored-By: Tarik Viehmann --- src/games/rcll/robots.clp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/games/rcll/robots.clp b/src/games/rcll/robots.clp index ea8b2aa59..f55c5f21f 100644 --- a/src/games/rcll/robots.clp +++ b/src/games/rcll/robots.clp @@ -85,7 +85,7 @@ (defrule robot-recv-SetRobotMaintenance ?pf <- (protobuf-msg (type "llsf_msgs.SetRobotMaintenance") (ptr ?p) (rcvd-via STREAM)) - (gamestate (cont-time ?ctime) (game-time ?game-time)) + (gamestate (phase ?phase) (cont-time ?ctime) (game-time ?game-time)) => (retract ?pf) ; message will be destroyed after rule completes (do-for-fact ((?robot robot)) @@ -104,7 +104,7 @@ then (assert (points (game-time ?game-time) (points (* -1 ?cycle-cost)) - (team ?robot:team-color) (phase PRODUCTION) + (team ?robot:team-color) (phase ?phase) (reason (str-cat "Maintenance of robot " ?robot:number)))) ) )