How do I Post to the Game Q&A Forum?

Welcome to the FTC Game Q&A Forum! If this is your first time here, please refer to the Instructions for Forum Use section before posting.

Thank you!

Results 1 to 9 of 9

Thread: Obfuscated RobotC contest

  1. #1
    Senior Member
    Join Date
    Dec 2010
    Location
    Glassboro, NJ
    Posts
    426

    Obfuscated RobotC contest

    Due to many team's seasons being over (including mine), I thought it would be a good time to run a friendly contest among the programmers on the FTC forums. This contest will be similar to the International Obfuscated C Code Contest, in that contestants are invited to submit the most horrible or intriguing RobotC code they have to offer, in order to challenge each other, and the compiler. The rules of the competition are:

    0. Code must be interesting in some way, either syntactically, aesthetically, or how-did-you-get-away-with-that-ly.
    1. Code must be posted in a reply to this message in order to count as a submission.
    2. Code must compile and run successfully in RobotC, unless it brings out a horrible, funny, or intriguing compiler error. Specific compiler settings, if they are not default, must be noted in the submission.
    3. Code must not contain any profanities, or cause the compiler to emit profanities.
    4. Code must be submitted by March 15, 2012 for it to count in judging.
    5. If the interesting part of the code is not obvious after looking at it and compiling it, the "point" of the code must be written in the post which contains the code.
    6. Every account may make exactly one submission.

    Judging will be carried out by myself (a six-year C veteran) and a programmer from the RobotC development team. Prizes may include a message in your signature about winning, and those which RobotC announced. Good luck, and happy coding! Please post your submissions and questions.

    EDIT 3/1/12: Added rule about compiler settings.
    EDIT 3/4/12: Added stuff about RobotC (you guys are awesome).
    Last edited by Skinkworks; 03-04-2012 at 07:10 PM. Reason: Added stuff about RobotC
    Max Bareiss

    FTC #248 Fatal Error (2009-2013)
    FRC #3142 Aperture (2009-2012)
    FRC #1302 Team Lionheart (2012-2013)
    ZRHS #89 Team Kühlschrank (2011-2013)
    ZRAC #40 Catcher in the Skye (2012)
    ISR 12: Umptysquatch 6
    Rowan University Baja SAE

    And mentoring for life.
    --
    11 seasons of FIRST in 6 years, as a student. Many more as a mentor.

  2. #2
    Junior Member
    Join Date
    Mar 2012
    Location
    Pittsburgh, PA
    Posts
    3

    Wink

    Thanks skinkworks for the great idea for a competition for ROBOTC users. The ROBOTC Development team would love to assist and participate!

    In order to contribute and motivate teams to participate in the Obfuscated ROBOTC contest, we would be happy to join in as guest judges for the competition. In addition to this, we'd also like to offer the following prizes for the competition:

    First Place: A free "Team License" for ROBOTC and Robot Virtual Worlds for the 2012-2013 FTC season ($199 Value) and a front page blog post at our ROBOTC.net website
    Second Place: A free "Team License" to Robot Virtual Worlds for the 2012-2013 FTC season ($99 Value)
    Third Place: A free "Single License" to Robot Virtual Worlds for the 2012-2013 FTC season ($49 Value)

    In additional, extra prizes may be given out to entries that are particularly noteworthy as judges awards.

    We're looking forward to all of the crazy submissions that may be possible. May be the best (and most ridiculous) program win!
    Last edited by tfriezROBOTC; 03-01-2012 at 04:31 PM.
    --
    Timothy Friez
    ROBOTC - Sr. Software Engineer
    http://www.robotc.net/
    tfriez@robotc.net

  3. #3
    Senior Member
    Join Date
    Dec 2010
    Location
    Glassboro, NJ
    Posts
    426
    As no one has submitted entries to this contest, the deadline will be extended to March 24. Please submit something! You could win RobotC for your next FTC season!
    Max Bareiss

    FTC #248 Fatal Error (2009-2013)
    FRC #3142 Aperture (2009-2012)
    FRC #1302 Team Lionheart (2012-2013)
    ZRHS #89 Team Kühlschrank (2011-2013)
    ZRAC #40 Catcher in the Skye (2012)
    ISR 12: Umptysquatch 6
    Rowan University Baja SAE

    And mentoring for life.
    --
    11 seasons of FIRST in 6 years, as a student. Many more as a mentor.

  4. #4
    Junior Member
    Join Date
    Jan 2012
    Location
    Bowie, MD
    Posts
    17
    Here is an Entry from Team 4081.

    Hope it is liked

    #pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, none)
    #pragma config(Sensor, S2, rangeFront, sensorSONAR)
    #pragma config(Sensor, S3, rangeLeft, sensorSONAR)
    #pragma config(Sensor, S4, rangeRight, sensorSONAR)
    #pragma config(Motor, motorA, , tmotorNormal, openLoop)
    #pragma config(Motor, motorB, , tmotorNormal, openLoop)
    #pragma config(Motor, motorC, , tmotorNormal, openLoop)
    #pragma config(Motor, mtr_S1_C1_1, motor2, tmotorNormal, openLoop, reversed)
    #pragma config(Motor, mtr_S1_C1_2, motor4, tmotorNormal, openLoop, reversed)
    #pragma config(Motor, mtr_S1_C2_1, motor3, tmotorNormal, openLoop, reversed)
    #pragma config(Motor, mtr_S1_C2_2, motor1, tmotorNormal, openLoop, reversed)
    #pragma config(Motor, mtr_S1_C3_1, elevator, tmotorNormal, openLoop)
    #pragma config(Motor, mtr_S1_C3_2, claw, tmotorNormal, openLoop)
    //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

    /*
    FTC Team 4081
    THE DROIDS
    2011 Competition, "Bowled Over" teleOp program
    Matthew Hahne
    */

    #include "JoystickDriver.c"

    void initializeRobot()
    {

    return;
    }


    task main()
    {
    initializeRobot();

    waitForStart(); // wait for start of tele-op phase

    int x1Val = 0; // these four are all just for easy manipulation of
    int y1Val = 0; // joystick values from gamepad one.
    int x2Val = 0; // the data from pad 2 is used less intensively,
    int y2Val = 0; // so these are un-needed there.

    int boundBox = 20; // size of the bounding box for the wheels

    int scale = 5; // the amount by which the wheels are slowed by default.
    // With a button the bring it up to full speed

    int motor1Val = 0; // same as the joystick values, just to make life easier
    int motor2Val = 0;
    int motor3Val = 0;
    int motor4Val = 0;

    int eleVal = 0; // and once again, these two are just to make dealing
    int clawVal = 0; // with the numbers simpler

    /*
    int eleSpeed = 50;
    int clawSpeed = 20;
    */

    while (true)
    {
    getJoystickSettings(joystick);

    /*------------------------Joystick Values-------------------------*\
    ||
    || Getting a bounding box/cutting down sensitivity from joysticks
    ||
    \*----------------------------------------------------------------*/

    if(abs(joystick.joy1_x1) > boundBox)
    {
    x1Val = joystick.joy1_x1 / scale;
    }
    else
    {
    x1Val = 0;
    }

    if(abs(joystick.joy1_y1) > boundBox)
    {
    y1Val = joystick.joy1_y1 / scale;
    }
    else
    {
    y1Val = 0;
    }

    if(abs(joystick.joy1_x2) > boundBox)
    {
    x2Val = joystick.joy1_x2 / scale;
    }
    else
    {
    x2Val = 0;
    }

    if(abs(joystick.joy1_y2) > boundBox)
    {
    y2Val = joystick.joy1_y2 / scale;
    }
    else
    {
    y2Val = 0;
    }


    /*--------------------Holonomic Motor Assignments-------------------*\
    || OVERVIEW:
    ||
    || Alright, this is the tricky bit of the holonomic system. The
    || "y1Val" and "x1Val" together make up the "strafing" movement, while
    || the "x2Val" is rotation. The tough bit comes because when driving,
    || each motor is paired with another in each axis(x and y). These
    || pairings are different for foreward and backward movement versus
    || sideways movement. As you can see, the pairings in the x-axis are
    || 1-2 and 3-4, but in the y-axis they are 1-3 and 2-4. This is key,
    || and is due to the fact that when driving LEFT, the FRONT two
    || wheels go the one direction and the BACK two must go the other,
    || while when driving FORWEARD, the LEFT two wheels must go one
    || direction, and the RIGHT must go the other.
    ||
    ||----------------------------------------------------------------------
    || MOTOR CONNECTIONS:
    ||
    || This part is very much a pain to reverse engineer blindly, so be
    || sure this is the exact setup.
    ||
    || front left = motor1
    || front right = motor2
    || back left = motor3
    || back right = motor4
    ||
    || Note: it is entirely fine to make any side of your robot the
    || "front." Being holonomic makes front, back, left, and right largely
    || arbitrary anyway. The key part of the motor connections is the
    || relative positions of the motors on the robot(i.e. 1 and 2 are
    || adjacent, 3 is diagonally across from 2, and 4 is adjacent to 3).
    ||
    || For example, the two setups below are equally vaild:
    ||
    || 1 /---------\ 2
    || | |
    || | |
    || | |
    || | |
    || 3 \---------/ 4
    ||
    ||
    || 2 /---------\ 4
    || | |
    || | |
    || | |
    || | |
    || 1 \---------/ 3
    ||
    || The relative positions are the same in each case.
    ||
    ||
    ||
    || In case of problems, check to ensure that either ALL, or NONE of
    || the motors are reversed in the "Motors and Sensors Setup" window
    || (assuming that all wheels are geared the same).
    ||
    \*-------------------------------------------------------------------*/

    motor1Val = -y1Val - x1Val - x2Val;
    motor2Val = y1Val - x1Val - x2Val;
    motor3Val = -y1Val + x1Val - x2Val;
    motor4Val = y1Val + x1Val - x2Val;

    // I know, that was a lot of build up for just four little lines. But
    // those four lines are the heart and soul of the holonomic drive.


    //speed boost (up to full speed)
    if(joy1Btn(5))
    {
    motor1Val = motor1Val * scale;
    motor2Val = motor2Val * scale;
    motor3Val = motor3Val * scale;
    motor4Val = motor4Val * scale;
    }




    //this next bit is only still here as a backup, in case
    //multi-gamepad control fails for some reason

    //------Single Gamepad Elevator/Claw Movement-------//
    // the left bottom trigger raises the elevator //
    // right bottom trigger lowers elevator //
    // Claw is nearly identical, simply with //
    // different buttons. //
    //--------------------------------------------------//
    /*
    if(joy1Btn(5))
    {
    eleVal = eleSpeed;
    }
    else if(joy1Btn(7))
    {
    eleVal = -eleSpeed;
    }
    if(!joy1Btn(5) && !joy1Btn(7))
    {
    eleVal = 0;
    }


    if(joy1Btn(6))
    {
    clawVal = clawSpeed;
    }
    else if(joy1Btn(8))
    {
    clawVal = -clawSpeed;
    }
    if(!joy1Btn(6) && !joy1Btn(8))
    {
    clawVal = 0;
    }
    */

    /*---------------Multiple Gamepad Elevator/Claw Movement-------------*\
    ||
    || With multiple controllers, we have the second controlling the claw
    || and elevator with the sticks, for precise analogue control. By
    || default,the elevator and claw move at a fraction of their full
    || power, with trigger buttons bringing them up to a faster speed.
    || The idea being that when fine control is needed, we dont want the
    || operator holding another button, he should be able to focus only on
    || his thumbs. If speed should ever be needed, then he can spare the
    || control lost to holding a trigger. This same idea is applied to the
    || bounding boxes. They are larger for course control, and smaller for
    || fine control.
    ||
    \*-------------------------------------------------------------------*/

    int eleScaleSlo = 4;
    int eleBoxFst = 5;
    int eleBoxSlo = 2;

    if(joy2Btn(5))
    {
    if(abs(joystick.joy2_y1) > eleBoxFst)
    {
    eleVal = joystick.joy2_y1;
    }
    else
    {
    eleVal = 0;
    }
    }
    else
    {
    if(abs(joystick.joy2_y1) > eleBoxSlo)
    {
    eleVal = joystick.joy2_y1 / eleScaleSlo;
    }
    else
    {
    eleVal = 0;
    }
    }


    int clawScaleSlo = 8;
    int clawScaleFst = 4;
    int clawBoxSlo = 2;
    int clawBoxFst = 5;

    if(joy2Btn(7))
    {
    if(abs(joystick.joy2_x2) > clawBoxFst)
    {
    clawVal = joystick.joy2_x2 / clawScaleFst;
    }
    else
    {
    clawVal = 0;
    }
    }
    else
    {
    if(abs(joystick.joy2_x2) > clawBoxSlo)
    {
    clawVal = joystick.joy2_x2 / clawScaleSlo;
    }
    else
    {
    clawVal = 0;
    }
    }

    //and finally, we take the calculated values and give them to the
    //motors.
    motor[motor1] = motor1Val;
    motor[motor2] = motor2Val;
    motor[motor3] = motor3Val;
    motor[motor4] = motor4Val;
    motor[elevator] = eleVal;
    motor[claw] = clawVal;

    }//end while
    }//end main
    Inshal Chenet
    Team 4081 The Droids
    We ARE the droids you're looking for

  5. #5
    Senior Member
    Join Date
    Dec 2010
    Location
    Glassboro, NJ
    Posts
    426
    This is interesting, but not nearly obfuscated; on the contrary, it's pretty clearly explained. As a rule of thumb, obfuscated code contest submissions cannot have comments, since comments make things less confusing. Also, can you put your code in a BBcode code block?
    Last edited by Skinkworks; 03-21-2012 at 01:26 PM.
    Max Bareiss

    FTC #248 Fatal Error (2009-2013)
    FRC #3142 Aperture (2009-2012)
    FRC #1302 Team Lionheart (2012-2013)
    ZRHS #89 Team Kühlschrank (2011-2013)
    ZRAC #40 Catcher in the Skye (2012)
    ISR 12: Umptysquatch 6
    Rowan University Baja SAE

    And mentoring for life.
    --
    11 seasons of FIRST in 6 years, as a student. Many more as a mentor.

  6. #6
    Senior Member
    Join Date
    Dec 2010
    Location
    Glassboro, NJ
    Posts
    426

    An example

    An example of code that is fairly obfuscated, here is the drive motor code from my robot this season (from what I remember):
    Code:
    motor[motorRight] = backwards?(abs(joystick.joy1_y2)>10:0:((abs(joystick.joy1_y2)>0:powf((float)joystick.joy1_y2/128.0,2):-powf((float)joystick.joy1_y2/128.0,2)):(abs(joystick.joy1_y1)>10:0:(abs(joystick.joy1_y1)>0:-powf((float)joystick.joy1_y1/128.0,2):powf((float)joystick.joy1_y1/128.0,2)))));
    motor[motorLeft] =  backwards?(abs(joystick.joy1_y1)>10:0:((abs(joystick.joy1_y1)>0:powf((float)joystick.joy1_y1/128.0,2):-powf((float)joystick.joy1_y1/128.0,2)):(abs(joystick.joy1_y2)>10:0:(abs(joystick.joy1_y2)>0:-powf((float)joystick.joy1_y2/128.0,2):powf((float)joystick.joy1_y2/128.0,2)))));
    Max Bareiss

    FTC #248 Fatal Error (2009-2013)
    FRC #3142 Aperture (2009-2012)
    FRC #1302 Team Lionheart (2012-2013)
    ZRHS #89 Team Kühlschrank (2011-2013)
    ZRAC #40 Catcher in the Skye (2012)
    ISR 12: Umptysquatch 6
    Rowan University Baja SAE

    And mentoring for life.
    --
    11 seasons of FIRST in 6 years, as a student. Many more as a mentor.

  7. #7
    Junior Member
    Join Date
    Jan 2012
    Location
    Bowie, MD
    Posts
    17
    Well may I resubmit the code like this?


    Code:
    #pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, none)#pragma config(Sensor, S2, rangeFront, sensorSONAR)
    #pragma config(Sensor, S3, rangeLeft, sensorSONAR)
    #pragma config(Sensor, S4, rangeRight, sensorSONAR)
    #pragma config(Motor, motorA, , tmotorNormal, openLoop)
    #pragma config(Motor, motorB, , tmotorNormal, openLoop)
    #pragma config(Motor, motorC, , tmotorNormal, openLoop)
    #pragma config(Motor, mtr_S1_C1_1, motor2, tmotorNormal, openLoop, reversed)
    #pragma config(Motor, mtr_S1_C1_2, motor4, tmotorNormal, openLoop, reversed)
    #pragma config(Motor, mtr_S1_C2_1, motor3, tmotorNormal, openLoop, reversed)
    #pragma config(Motor, mtr_S1_C2_2, motor1, tmotorNormal, openLoop, reversed)
    #pragma config(Motor, mtr_S1_C3_1, elevator, tmotorNormal, openLoop)
    #pragma config(Motor, mtr_S1_C3_2, claw, tmotorNormal, openLoop)
    //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
    
    
    #include "JoystickDriver.c"task main(){waitForStart(); int x1Val = 0; int y1Val = 0;int x2Val = 0; int y2Val = 0; int boundBox = 20;int scale = 5;int motor1Val = 0;int motor2Val = 0; int motor3Val = 0; int motor4Val = 0;while (true){getJoystickSettings(joystick);if(abs(joystick.joy1_x1) > boundBox){x1Val = joystick.joy1_x1 / scale;}else{x1Val = 0;}if(abs(joystick.joy1_y1) > boundBox){y1Val = joystick.joy1_y1 / scale;}else{y1Val=0;}if(abs(joystick.joy1_x2) > boundBox){x2Val = joystick.joy1_x2 / scale;}else{x2Val = 0;}if(abs(joystick.joy1_y2) > boundBox){y2Val = joystick.joy1_y2 / scale;}else{y2Val = 0;}motor1Val = -y1Val - x1Val - x2Val;motor2Val = y1Val - x1Val - x2Val;motor3Val = -y1Val + x1Val - x2Val;motor4Val = y1Val + x1Val - x2Val;if(joy1Btn(5)){motor1Val = motor1Val * scale;motor2Val = motor2Val * scale;motor3Val = motor3Val * scale;motor4Val = motor4Val * scale;}motor[motor1] = motor1Val;motor[motor2] = motor2Val;motor[motor3] = motor3Val;motor[motor4] = motor4Val;}}
    And if it is not obvious what the code does, it is to control a robot with Holonomic Drive
    Last edited by protocolDROID; 03-25-2012 at 09:56 AM.
    Inshal Chenet
    Team 4081 The Droids
    We ARE the droids you're looking for

  8. #8
    Senior Member
    Join Date
    Dec 2010
    Location
    Glassboro, NJ
    Posts
    426
    initializeRobot() is not defined.
    Max Bareiss

    FTC #248 Fatal Error (2009-2013)
    FRC #3142 Aperture (2009-2012)
    FRC #1302 Team Lionheart (2012-2013)
    ZRHS #89 Team Kühlschrank (2011-2013)
    ZRAC #40 Catcher in the Skye (2012)
    ISR 12: Umptysquatch 6
    Rowan University Baja SAE

    And mentoring for life.
    --
    11 seasons of FIRST in 6 years, as a student. Many more as a mentor.

  9. #9
    Junior Member
    Join Date
    Jan 2012
    Location
    Bowie, MD
    Posts
    17
    -_-
    Now it should be better
    Inshal Chenet
    Team 4081 The Droids
    We ARE the droids you're looking for

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •