View Single Post
  #102   Spotlight this post!  
Unread 10-12-2007, 12:14
artdutra04's Avatar
artdutra04 artdutra04 is offline
VEX Robotics Engineer
AKA: Arthur Dutra IV; NERD #18
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2002
Location: Greenville, TX
Posts: 3,078
artdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond repute
Re: Programming jokes

Quote:
Originally Posted by JesseK View Post
Maybe he lacked the proper people skills. Many a great idea go mutiliated or unknown because someone doesn't speak up enough or that someone lacks the insight into how to be pushy enough to make the idea become a success.

(Java-C-MPLab pseudo-goullash code)
Code:
int rand = Math.rand() * 127;
int pos_neg = Math.rand;
if(pos_neg > 0.5) 
pos_neg = 1;
else 
pos_neg = -1;

//Drive Motors
pwm_04=pwm_05=(rand + 127);
pwm_06=pwm_07=(rand * pos_neg + 127);

//Arm
pwm_08=255; //Arms up!
pwm_09=(rand/2*pos_neg + 127);  //Wavy hands
This isn't a joke; this will be our autonomous algorithm next year if our students don't come up with anything to do in autonomous. Students be warned!
The only downside to this algorithm is that there is no rand() function of any kind on our controller.

The best way I've found to generate "random" numbers on Vex/FRC controllers is to start a timer at the beginning of your program, and whenever you need a random number get the modulus of the timer value when divided by a number of your choice.
__________________
Art Dutra IV
Robotics Engineer, VEX Robotics, Inc., a subsidiary of Innovation First International (IFI)
Robowranglers Team 148 | GUS Robotics Team 228 (Alumni) | Rho Beta Epsilon (Alumni) | @arthurdutra

世上无难事,只怕有心人.