Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 12:92ba52394c85
- Parent:
- 11:93c035708249
- Child:
- 13:2c8f8e77b549
diff -r 93c035708249 -r 92ba52394c85 main.cpp --- a/main.cpp Sun Apr 01 00:50:47 2018 +0000 +++ b/main.cpp Sun Apr 01 01:46:03 2018 +0000 @@ -587,127 +587,316 @@ } /*******************************************************************///Cyan - if( i == 0 && color == 4 ) + if( i == 0 && color == 4 )//condition for return Cyan at index 0 { - //condition for return Cyan at index 0 + move(2*leg + 0.3046*scale, FORWARD) + turnRight(); + move(2*leg + 0.3046*scale, FORWARD) + dropToken(); + rot180(); + move(2*leg + 0.3046*scale, FORWARD) + turnLeft(); + move(2*leg + 0.3046*scale, FORWARD) + rot180(); + } + if( i == 1 && color == 4 )//condition for return Cyan at index 1 + { + move(leg + 0.3046*scale, FOWARD); + turnRight(); + move(2*leg + 0.3046*scale, FOWARD); + dropToken(); + rot180(); + move(2*leg + 0.3046*scale, FOWARD); + turnleft(); + move(leg + 0.3046*scale, FOWARD); + rot180(); } - if( i == 1 && color == 4 ) + if( i == 2 && color == 4 )//condition for return Cyan at index 2 { - //condition for return Cyan at index 1 + move(2*leg + 0.3046*scale, FOWARD); + turnLeft(); + move(0.3046*scale); + dropToken(); + rot180(); + move(0.3046*scale); + turnRight(); + move(2*leg + 0.3046*scale, FOWARD); + rot180(); } - if( i == 2 && color == 4 ) + if( i == 4 && color == 4 )//condition for return Cyan at index 4 { - //condition for return Cyan at index 2 + rot180(); + move(0.3046*scale, FORWARD); + turnRight(); + move(0.3046*scale, FORWARD); + dropToken(); + rot180(); + move(0.3046*scale, FORWARD); + turnLeft(); + move(0.3046*scale, FORWARD); + turnleft(); + move(0.3046*scale, FORWARD); + turnRight(); } - if( i == 4 && color == 4 ) + if( i == 5 && color == 4 )//condition for return Cyan at index 5 { - //condition for return Cyan at index 4 + rot180(); + move(leg + 0.3046*scale, FORWARD); + turnRight(); + move(0.3046*scale, FORWARD); + dropToken(); + rot180(); + move(0.3046*scale, FORWARD); + turnLeft(); + move(leg + 0.3046*scale, FORWARD); } - if( i == 5 && color == 4 ) + if( i == 6 && color == 4 )//condition for return Cyan at index 6 { - //condition for return Cyan at index 5 - - } - if( i == 6 && color == 4 ) - { - //condition for return Cyan at index 6 + turnRight(); + move(2*leg + 0.3046*scale, FORWARD); + turnRight(); + move(0.3046*scale, FORWARD); + dropToken(); + rot180(); + move(0.3046*scale, FORWARD); + turnLeft(); + move(leg + 0.3046*scale, FORWARD); + turnRight(); } /*******************************************************************///Magenta - if( i == 0 && color == 5 ) + if( i == 0 && color == 5 )//condition for return Magenta at index 0 { - //condition for return Magenta at index 0 + move(leg, FORWARD); + turnRight(); + move(2*leg + 0.3046*scale); + dropToken(); + rot180(); + move(2*leg + 0.3046*scale); + turnLeft(); + move(leg, FORWARD); + rot180(); } - if( i == 1 && color == 5 ) + if( i == 1 && color == 5 )//condition for return Magenta at index 1 { - //condition for return Magenta at index 1 + turnRight(); + move(2*leg + 0.3046*scale); + dropToken(); + rot180(); + move(2*leg + 0.3046*scale); + turnRight(); + + } + if( i == 2 && color == 5 )//condition for return Magenta at index 2 + { + move(leg + 0.3046*scale, FORWARD); + turnRight(); + move(leg, FORWARD); + dropToken(); + rot180(); + move(leg, FORWARD); + turnLeft(); + move(2*leg + 0.3046*scalem FORWARD); + rot180(); } - if( i == 2 && color == 5 ) + if( i == 4 && color == 5 )//condition for return Magenta at index 4 { - //condition for return Magenta at index 2 + move(leg, FORWARD); + turnLeft(); + move(0.3046*scale); + dropToken(); + rot180(); + move(0.3046*scale); + turnRight(); + Move(leg, FORWARD); + rot180(); } - if( i == 4 && color == 5 ) + if( i == 5 && color == 5 )//condition for return Magenta at index 5 { - //condition for return Magenta at index 4 + turnLeft(); + move(0.3046*scale); + dropToken(); + rot180(); + move(0.3046*scale); + turnLeft(); } - if( i == 5 && color == 5 ) + if( i == 6 && color == 5 )//condition for return Magenta at index 6 { - //condition for return Magenta at index 5 - - } - if( i == 6 && color == 5 ) - { - //condition for return Magenta at index 6 + rot180(); + move(leg, FORWARD); + turnRight(); + move(0.3046*scale); + dropToken(); + rot180(); + move(0.3046*scale); + turnLeft(); + move(lef, FORWARD); + turnRight(); } /*******************************************************************///Yellow - if( i == 0 && color == 6 ) + if( i == 0 && color == 6 )//condition for return Yellow at index 0 { - //condition for return Yellow at index 0 + turnRight(); + move(2*leg + 0.3046*scale); + turnRight(); + move(0.3046*scale); + dropToken(); + rot180(); + move(0.3046*scale); + turnLeft(); + move(2*leg + 0.3046*scale); + turnRight(); } - if( i == 1 && color == 6 ) + if( i == 1 && color == 6 )//condition for return Yellow at index 1 { - //condition for return Yellow at index 1 + rot180(); + move(leg + 0.3046*scale, FORWARD); + turnLeft(); + move(2*leg, FORWARD); + dropToken(); + rot180(); + move(2*leg, FOWARD); + turnRight(); + move(leg + 0.3046*scale, FORWARD); + } - if( i == 2 && color == 6 ) + if( i == 2 && color == 6 )//condition for return Yellow at index 2 { - //condition for return Yellow at index 2 + move(2*leg + 0.3046*scale, FORWARD); + turnRight(); + move(2*leg, FORWARD); + dropToken(); + rot180(); + move(2*leg, FORWARD); + turnLeft(); + move(2*leg + 0.3046*scale, FORWARD); + rot180(); } - if( i == 4 && color == 6 ) + if( i == 4 && color == 6 )//condition for return Yellow at index 4 { - //condition for return Yellow at index 4 + move(2*leg + 0.3046*scale, FORWARD); + turnLeft(); + move(0.3046*scale, FORWARD); + dropToken(); + rot180(0); + move(0.3046*scale, FORWARD); + turnRight(); + move(2*leg + 0.3046*scale, FORWARD); + rot180(); + } - if( i == 5 && color == 6 ) + if( i == 5 && color == 6 )//condition for return Yellow at index 5 { - //condition for return Yellow at index 5 + move(leg + 0.3046*scale, FORWARD); + turnLeft(); + move(0.3046*scale, FORWARD); + dropToken(); + rot180(); + move(0.3046*scale, FORWARD); + turnRight(); + move(Leg + 0.3046*scale, FORWARD); + rot180(); + } - if( i == 6 && color == 6 ) + if( i == 6 && color == 6 )//condition for return Yellow at index 6 { - //condition for return Yellow at index 6 + rot180(); + move(0.3046*scale, FORWARD); + turnRight(); + move(0.3046*scale, FORWARD); + dropToken(); + rot180(); + move(0.3046*scale, FORWARD); + turnLeft(); + move(0.3046*scale, FORWARD); } /*******************************************************************///Gray - if( i == 0 && color == 7 ) + if( i == 0 && color == 7 )//condition for return Gray at index 0 { - //condition for return Gray at index 0 + move(leg, FORWARD); + turnRight(); + move(leg, FORWARD); + dropToken(); + rot180(); + move(leg, FORWARD); + turnLeft(); + move(leg, FORWARD); + } - if( i == 1 && color == 7 ) + if( i == 1 && color == 7 )//condition for return Gray at index 1 + { + turnRight(); + move(leg, FORWARD); + dropToken(); + rot180(); + move(leg, FORWARD); + turnRight(); + } + if( i == 2 && color == 7 ) //condition for return Gray at index 2 { - //condition for return Gray at index 1 + rot180(); + move(leg, FORWARD); + turnLeft(); + move(leg, FORWARD); + dropToken(); + rot180(); + move(leg, FORWARD); + turnRight(); + move(leg, FORWARD); + turnRight(); } - if( i == 2 && color == 7 ) + if( i == 4 && color == 7 ) //condition for return Gray at index 4 { - //condition for return Gray at index 2 + move(leg, FORWARD); + turnRight(); + move(leg, FORWARD); + dropToken(); + rot180(); + move(leg, FORARD); + turnLeft(); + move(lef, FORWARD); + rot180(); } - if( i == 4 && color == 7 ) + if( i == 5 && color == 7 )//condition for return Gray at index 5 { - //condition for return Gray at index 4 + turnRight(); + move(leg, FORWARD); + dropToken(); + rot180(); + move(leg, FORWARD); + turnRight(); } - if( i == 5 && color == 7 ) + if( i == 6 && color == 7 )//condition for return Gray at index 6 { - //condition for return Gray at index 5 - - } - if( i == 6 && color == 7 ) - { - //condition for return Gray at index 6 + turnRight(); + move(leg, FORWARD); + turnLeft(); + move(leg, FORWARD); + dropToken(); + rot180(); + move(leg, FORWARD); + rightRight(); + move(leg, FORWARD); + turnRight(); } else