Subject:
|
Re: My RCX is HAUNTED
|
Newsgroups:
|
lugnet.org.ca.rtltoronto
|
Date:
|
Fri, 12 Sep 2003 05:02:21 GMT
|
Viewed:
|
485 times
|
| |
| |
> I'm the worst programmer I know, and even I know how not to use 64 IF's. :)
>
> Calum
Calum.......
I don't need to point out who won that event, and who did not even have a robot.
If I can juggle 64 nested if's then that just puts me on a level that you mortals
could only dream.
now.... cause you asked so nice..... the CODE. with 64 nested if's
if project X came is second with this Primitive spaghetti code, imagine if I actually
applied myself.
:)
----------------------snip-------------------
program mouse{
macro homex {
backward A
on A
wait 10
off A
x = 5
}
macro homey {
forward B
on B
wait 30
off B
y = 0
}
macro pick{ float C wait 2 off C wait 30 z = 1 }
macro place{ if z = 1 {float C wait 2 off C wait 32 z = 0 } }
macro tick {
if x1 > x {forward A on A x += 1 d = 9} else {backward A on A x -= 1 d = 8}
if x = x1 {power A 7 off A wait 20 reverse A on A wait d off A power A 8 w1 += 1 }
}
macro tock {
if y1 > y {backward B on B y += 1 r = 5 } else {forward B on B y -= 1 r = 3 }
if y = y1 {power B 8 off B wait 20 reverse B on B wait r off B power B 8 w1 += 1 }
}
macro sort {
select zz {
when 1 {aa = 1 bb = 0 cc = 0 dd = 0}
when 2 {aa = 0 bb = 0 cc = 1 dd = 0}
when 3 {aa = 0 bb = 1 cc = 0 dd = 0}
when 4 {aa = 1 bb = 1 cc = 0 dd = 0}
when 5 {aa = 1 bb = 0 cc = 1 dd = 0}
when 6 {aa = 0 bb = 1 cc = 1 dd = 0}
when 7 {aa = 1 bb = 1 cc = 1 dd = 0}
when 8 {aa = 0 bb = 0 cc = 0 dd = 0}
when 9 {aa = 0 bb = 0 cc = 0 dd = 1}
when 10 {aa = 1 bb = 0 cc = 0 dd = 1}
when 11 {aa = 0 bb = 0 cc = 1 dd = 1}
when 12 {aa = 0 bb = 1 cc = 0 dd = 1}
when 13 {aa = 1 bb = 1 cc = 0 dd = 1}
when 14 {aa = 1 bb = 0 cc = 1 dd = 1}
when 15 {aa = 0 bb = 1 cc = 1 dd = 1}
when 16 {aa = 1 bb = 1 cc = 1 dd = 1}
}
x += 1
zz = 0
select x {
when 1 {a1 = aa a2 = bb a3 = cc a4= dd}
when 2 {b1 = aa b2 = bb b3 = cc b4= dd}
when 3 {c1 = aa c2 = bb c3 = cc c4= dd}
when 4 {d1 = aa d2 = bb d3 = cc d4= dd
homex
homey
start targetx
start targety
start thew1
start code
stop clocks
stop look
}
}
}
sensor l on 1 l is light as percent
sensor s on 2 s is light as percent
sensor q on 3 q is light as percent
timer t
event black when l < 40
event white when s > 40
event thew when w1 = 2
event times when t > 1
event wow when q >70
output A on 1
output B on 2
output C on 3
var aa = 0
var bb = 0
var cc = 0
var dd = 0
var x = 0
var x1 = 0
var y = 0
var y1 = 0
var w1 = 0
var zz = 0
var a1 = 0
var a2 = 0
var a3 = 0
var a4 = 0
var b1 = 0
var b2 = 0
var b3 = 0
var b4 = 0
var c1 = 0
var c2 = 0
var c3 = 0
var c4 = 0
var d1 = 0
var d2 = 0
var d3 = 0
var d4 = 0
Main {
clear message
power B 8
power A 8
start clocks
start look
forever{display x}
}
watcher targetx monitor black {local d tick }
watcher targety monitor white {local r tock }
watcher thew1 monitor thew {w1 = 0 }
watcher clocks monitor times { if zz > 0 {sort} }
watcher look monitor wow { clear t zz += 1 }
task logicx {
if x = x1 {w1 += 1 stop logicx }
if x1 > x {forward A} else {backward A}
on A
}
task logicy {
if y = y1 {w1 += 1 stop logicy }
if y1 > y {backward B} else {forward B}
on B
}
task code{
local z = 0
//---------------------start math code
if a2 = 1 {
x1 = 4 y1 = 3
start logicx start logicy
wait until thew
pick
}
if a2 = 1{if a1 = 0 { a1 = 1 a2 = 0 x1= 4 y1 = 4 start logicx start logicy wait
until thew}}
if a2 = 1{if b2 = 0 { b2 = 1 a2 = 0 x1= 3 y1 = 3 start logicx start logicy wait
until thew}}
if a2 = 1{if b3 = 0 { b3 = 1 a2 = 0 x1= 3 y1 = 2 start logicx start logicy wait
until thew}}
if a2 = 1{if a4 = 0 { a4 = 1 a2 = 0 x1= 4 y1 = 1 start logicx start logicy wait
until thew}}
if a2 = 1{if c2 = 0 { c2 = 1 a2 = 0 x1= 2 y1 = 3 start logicx start logicy wait
until thew}}
if a2 = 1{if c3 = 0 { c3 = 1 a2 = 0 x1= 2 y1 = 2 start logicx start logicy wait
until thew}}
if a2 = 1{if d1 = 0 { d1 = 1 a2 = 0 x1= 1 y1 = 4 start logicx start logicy wait
until thew}}
if a2 = 1{if d4 = 0 { d4 = 1 a2 = 0 x1= 1 y1 = 1 start logicx start logicy wait
until thew}}
place
//
if a3 = 1 {
x1 = 4 y1 = 2
start logicx start logicy
wait until thew
pick
}
if a3 = 1{if a4 = 0 { a4 = 1 a3 = 0 x1= 4 y1 = 1 start logicx start logicy wait
until thew}}
if a3 = 1{if b3 = 0 { b3 = 1 a3 = 0 x1= 3 y1 = 2 start logicx start logicy wait
until thew}}
if a3 = 1{if b2 = 0 { b2 = 1 a3 = 0 x1= 3 y1 = 3 start logicx start logicy wait
until thew}}
if a3 = 1{if a1 = 0 { a1 = 1 a3 = 0 x1= 4 y1 = 4 start logicx start logicy wait
until thew}}
if a3 = 1{if c3 = 0 { c3 = 1 a3 = 0 x1= 2 y1 = 2 start logicx start logicy wait
until thew}}
if a3 = 1{if c2 = 0 { c2 = 1 a3 = 0 x1= 2 y1 = 3 start logicx start logicy wait
until thew}}
if a3 = 1{if d4 = 0 { d4 = 1 a3 = 0 x1= 1 y1 = 1 start logicx start logicy wait
until thew}}
if a3 = 1{if d1 = 0 { d1 = 1 a3 = 0 x1= 1 y1 = 4 start logicx start logicy wait
until thew}}
place
//
if b1 = 1 {
x1 = 3 y1 = 4
start logicx start logicy
wait until thew
pick
}
if b1 = 1{if b2 = 0 { b2 = 1 b1 = 0 x1= 3 y1 = 3 start logicx start logicy wait
until thew}}
if b1 = 1{if a1 = 0 { a1 = 1 b1 = 0 x1= 4 y1 = 4 start logicx start logicy wait
until thew}}
if b1 = 1{if c2 = 0 { c2 = 1 b1 = 0 x1= 2 y1 = 3 start logicx start logicy wait
until thew}}
if b1 = 1{if d1 = 0 { d1 = 1 b1 = 0 x1= 1 y1 = 4 start logicx start logicy wait
until thew}}
if b1 = 1{if b3 = 0 { b3 = 1 b1 = 0 x1= 3 y1 = 2 start logicx start logicy wait
until thew}}
if b1 = 1{if c3 = 0 { c3 = 1 b1 = 0 x1= 2 y1 = 2 start logicx start logicy wait
until thew}}
if b1 = 1{if a4 = 0 { a4 = 1 b1 = 0 x1= 4 y1 = 1 start logicx start logicy wait
until thew}}
if b1 = 1{if d4 = 0 { d4 = 1 b1= 0 x1= 1 y1 = 1 start logicx start logicy wait until
thew}}
place
//
if b4 = 1 {
x1 = 3 y1 = 1
start logicx start logicy
wait until thew
pick
}
if b4 = 1{if b3 = 0 { b3 = 1 b4 = 0 x1= 3 y1 = 2 start logicx start logicy wait
until thew}}
if b4 = 1{if a4 = 0 { a4 = 1 b4 = 0 x1= 4 y1 = 1 start logicx start logicy wait
until thew}}
if b4 = 1{if c3 = 0 { c3 = 1 b4 = 0 x1= 2 y1 = 2 start logicx start logicy wait
until thew}}
if b4 = 1{if d4 = 0 { d4 = 1 b4 = 0 x1= 1 y1 = 1 start logicx start logicy wait
until thew}}
if b4 = 1{if b2 = 0 { b2 = 1 b4 = 0 x1= 3 y1 = 3 start logicx start logicy wait
until thew}}
if b4 = 1{if c2 = 0 { c2 = 1 b4 = 0 x1= 2 y1 = 3 start logicx start logicy wait
until thew}}
if b4 = 1{if a1 = 0 { a1 = 1 b4 = 0 x1= 4 y1 = 4 start logicx start logicy wait
until thew}}
if b4 = 1{if d1 = 0 { d1 = 1 b4 = 0 x1= 1 y1 = 4 start logicx start logicy wait
until thew}}
place
//
if c1 = 1 {
x1 = 2 y1 = 4
start logicx start logicy
wait until thew
pick
}
if c1 = 1{if c2 = 0 { c2 = 1 c1 = 0 x1= 2 y1 = 3 start logicx start logicy wait
until thew}}
if c1 = 1{if b2 = 0 { b2 = 1 c1 = 0 x1= 3 y1 = 3 start logicx start logicy wait
until thew}}
if c1 = 1{if d1 = 0 { d1 = 1 c1 = 0 x1= 1 y1 = 4 start logicx start logicy wait
until thew}}
if c1 = 1{if a1 = 0 { a1 = 1 c1 = 0 x1= 4 y1 = 4 start logicx start logicy wait
until thew}}
if c1 = 1{if b3 = 0 { b3 = 1 c1 = 0 x1= 3 y1 = 2 start logicx start logicy wait
until thew}}
if c1 = 1{if c3 = 0 { c3 = 1 c1 = 0 x1= 2 y1 = 2 start logicx start logicy wait
until thew}}
if c1 = 1{if d4 = 0 { d4 = 1 c1 = 0 x1= 1 y1 = 1 start logicx start logicy wait
until thew}}
if c1 = 1{if a4 = 0 { a4 = 1 c1 = 0 x1= 4 y1 = 1 start logicx start logicy wait
until thew}}
place
//
if c4 = 1 {
x1 = 2 y1 = 1
start logicx start logicy
wait until thew
pick
}
if c4 = 1{if c3 = 0 { c3 = 1 c4 = 0 x1= 2 y1 = 2 start logicx start logicy wait
until thew}}
if c4 = 1{if b3 = 0 { b3 = 1 c4 = 0 x1= 3 y1 = 2 start logicx start logicy wait
until thew}}
if c4 = 1{if d4 = 0 { d4 = 1 c4 = 0 x1= 1 y1 = 1 start logicx start logicy wait
until thew}}
if c4 = 1{if a1 = 0 { a1 = 1 c4 = 0 x1= 4 y1 = 4 start logicx start logicy wait
until thew}}
if c4 = 1{if c2 = 0 { c2 = 1 c4 = 0 x1= 2 y1 = 3 start logicx start logicy wait
until thew}}
if c4 = 1{if b2 = 0 { b2 = 1 c4 = 0 x1= 3 y1 = 3 start logicx start logicy wait
until thew}}
if c4 = 1{if d1 = 0 { d1 = 1 c4 = 0 x1= 1 y1 = 4 start logicx start logicy wait
until thew}}
if c4 = 1{if a4 = 0 { a4 = 1 c4 = 0 x1= 4 y1 = 1 start logicx start logicy wait
until thew}}
place
//
if d2 = 1 {
x1 = 1 y1 = 3
start logicx start logicy
wait until thew
pick
}
if d2 = 1{if d1 = 0 { d1 = 1 d2 = 0 x1= 1 y1 = 4 start logicx start logicy wait
until thew}}
if d2 = 1{if c2 = 0 { c2 = 1 d2 = 0 x1= 2 y1 = 3 start logicx start logicy wait
until thew}}
if d2 = 1{if c3 = 0 { c3 = 1 d2 = 0 x1= 2 y1 = 2 start logicx start logicy wait
until thew}}
if d2 = 1{if d4 = 0 { d4 = 1 d2 = 0 x1= 1 y1 = 1 start logicx start logicy wait
until thew}}
if d2 = 1{if b2 = 0 { b2 = 1 d2 = 0 x1= 3 y1 = 3 start logicx start logicy wait
until thew}}
if d2 = 1{if b3 = 0 { b3 = 1 d2 = 0 x1= 3 y1 = 2 start logicx start logicy wait
until thew}}
if d2 = 1{if a1 = 0 { a1 = 1 d2 = 0 x1= 4 y1 = 4 start logicx start logicy wait
until thew}}
if d2 = 1{if a4 = 0 { a4 = 1 d2 = 0 x1= 4 y1 = 1 start logicx start logicy wait
until thew}}
place
//
if d3 = 1 {
x1 = 1 y1 = 2
start logicx start logicy
wait until thew
pick
}
if d3 = 1{if c3 = 0 { c3 = 1 d3 = 0 x1= 2 y1 = 2 start logicx start logicy wait
until thew}}
if d3 = 1{if d4 = 0 { d4 = 1 d3 = 0 x1= 1 y1 = 1 start logicx start logicy wait
until thew}}
if d3 = 1{if c2 = 0 { c2 = 1 d3 = 0 x1= 2 y1 = 3 start logicx start logicy wait
until thew}}
if d3 = 1{if d1 = 0 { d1 = 1 d3 = 0 x1= 1 y1 = 4 start logicx start logicy wait
until thew}}
if d3 = 1{if b3 = 0 { b3 = 1 d3 = 0 x1= 3 y1 = 2 start logicx start logicy wait
until thew}}
if d3 = 1{if b2 = 0 { b2 = 1 d3 = 0 x1= 3 y1 = 3 start logicx start logicy wait
until thew}}
if d3 = 1{if a4 = 0 { a4 = 1 d3 = 0 x1= 4 y1 = 1 start logicx start logicy wait
until thew}}
if d3 = 1{if a1 = 0 { a1 = 1 d3 = 0 x1= 4 y1 = 4 start logicx start logicy wait
until thew}}
place
x1 = 5
y1 = 2
start logicx start logicy
wait until thew
stop targetx
stop targety
forward A
on A
wait 20
off A
forward B
on B
wait 6
off B
send 3
wait 15
stop tasks
//-----------------end code
}
}
--
Chris
|
|
Message has 3 Replies: | | Re: My RCX is HAUNTED
|
| (...) Well, let's see. Rob won the event...and I know he can program--or at least his dad can. Who didn't have a robot? Well, I brought one with Mario. Hrm. We can both program (He wrote the majority of the code, I wrote a small part on a secondary (...) (21 years ago, 12-Sep-03, to lugnet.org.ca.rtltoronto)
| | | Re: My RCX is HAUNTED
|
| (...) Chris, I'd just like to know whether you use BricxCC to edit your MindScript code? If you don't you might consider giving it a try. John Hansen (URL) (21 years ago, 12-Sep-03, to lugnet.org.ca.rtltoronto)
|
Message is in Reply To:
| | Re: My RCX is HAUNTED
|
| (...) I'm pretty sure the reason why operating systems have garbage collection routines is because of people who insist on programming 64 nested ifs. I'm the worst programmer I know, and even I know how not to use 64 IF's. :) Calum (21 years ago, 12-Sep-03, to lugnet.org.ca.rtltoronto)
|
38 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|