This is the mine program for the Junior Robot Wars Competition 3 Dec 2020.
Program
---
Junior Robot Wars Mine Program
3 Dec 2020
---
prog_vars =
d/hits 0
d/hit_result 0
d/health 10
d/flashes 0
d/died 0
prog_vars.
prog_start =
"Mine Start"
coff
repeat 10 -> tg c2|d100
-- Setup the bumper pins A1 & A2
btp a1 do_boom
btp a2 do_boom
hled
prog_start.
prog_loop =
patdog
prog_loop.
do_boom =
---
The mine is triggered work out the health or damage.
---
/flashes 0
-- Get a new random number between -6 and 6.
rand -6 6 -> /hit_result
-- Update the health var
add /health /hit_result -> /health
-- Flash for neg /hit_result ie deduct health
any /hit_result < 0 -> /flashes 2
-- Count no of hits
inc /hits
print "T /hits TR /hit_result H /health F /flashes"
show_hit_color /hit_result /flashes
do_boom.
show_hit_color /hit_color 0 /hit_flashes 0 =
-- All c off
coff
-- Get abs version of color
abs /hit_color -> /hit_color
hled
repeat /hit_flashes ->
ant /hit_color ->
= 1 -> sled a3 6 /hit_color 0 255 0
= 2 -> sled a3 6 /hit_color 0 255 255
= 3 -> sled a3 6 /hit_color 255 255 0
= 4 -> sled a3 6 /hit_color 255 0 255
= 5 -> sled a3 6 /hit_color 0 0 255
= 6 -> sled a3 6 /hit_color 0 255 0
-> hled
ant.
d500
hled
repeat.
show_hit_color.
prog_stop =
coff
ant /died ->
= 1 -> "Died Hits"|c1 1
= 2 -> "Died Health"|c3 1
-> c2 1
ant.
rstb
prog_stop.