Go to Post Man I hate it when people muddy up our rampant speculation with facts and logic, jeez :D - rsisk [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-09-2005, 01:29
henryBsick's Avatar
henryBsick henryBsick is offline
Why wait for the last 20?
AKA: Henry B. Sick
FRC #0125 (NUTRONS)
Team Role: Mentor
 
Join Date: Nov 2003
Rookie Year: 2001
Location: Bahston, MA
Posts: 645
henryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond repute
Send a message via AIM to henryBsick
Karel++ Noob help

Ok, heres the story... I got this nifty new Karel++ book today in my intro to Computer Programming class. In my haste to learn I read waaaay ahead and thought of a neat thing to do. I based the length of move commands in how you write the word "move" It is binary based using capitals for on/off.
example:

movE---move one space
moVe---move two spaces
moVE---move three spaces
ect...

The skinny is M=8, O=4, V=2, E=1.

Here is the actual code... the task it performs is just filler to make it a complete code.

Code:
class robot_pwn: ur_robot{
	void movE( ); //1
	void moVe( ); //2
	void moVE( ); //3
	void mOve( ); //4
	void mOvE( ); //5
	void mOVe( ); //6
	void mOVE( ); //7
	void Move( ); //8
	void MovE( ); //9
	void MoVe( ); //10
	void MoVE( ); //11
	void MOve( ); //12
	void MOvE( ); //13
	void MOVe( ); //14
	void MOVE( ); //15
	void turnRight( ); //self explanatory genius
	
};

void robot_pwn :: movE( )
{
	move( );
}

void robot_pwn :: moVe( )
{
	move( );
	move( );
}

void robot_pwn :: moVE( )
{
	move( );
	move( );
	move( );
}

void robot_pwn :: mOve( )
{
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: mOvE( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: mOVe( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: mOVE( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: Move( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: MovE( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: MoVe( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: MoVE( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: MOve( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: MOvE( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: MOVe( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: MOVE( )
{
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
	move( );
}

void robot_pwn :: turnRight( )
{
	turnLeft( );
	turnLeft( );
	turnLeft( );
}

task
{	robot_pwn Blitz(1,1, East, 9); //w00t w00t for 9 beepers
	Blitz.turnOff( ); //sad existence for such a complicated binary-move code
}
Anyone out there with any Karel++ experince... please let me know if what I attempted is possible.


n00b coder,

-Henry
__________________
Mechanical Engineer
Digital Lumens
NU ME: 2011
  #2   Spotlight this post!  
Unread 08-09-2005, 06:10
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Karel++ Noob help

I don't know Karel++, but it's definitely possible with almost any other language, so it probably is.

One thing, from looking at your code: you might want to (at the very least) have it loop over the "move();"s There's probably something called along the lines of a C/C++ "for" loop where you (basically) specify where the loop starts and where it ends.

You could also go for actually determining the actual value of the string, which shouldn't be that hard, even in a language with mostly low-level string stuff. Then, use that value to determine how many times you move. (If you have a for loop then, you can just stick the variable in instead of a hard value.)
__________________

  #3   Spotlight this post!  
Unread 08-09-2005, 10:09
jdiwnab's Avatar
jdiwnab jdiwnab is offline
Really the Inventor Guy
AKA: Bryan Hartley
FRC #0617
Team Role: College Student
 
Join Date: Nov 2004
Rookie Year: 2002
Location: Highland Springs, VA
Posts: 260
jdiwnab is a jewel in the roughjdiwnab is a jewel in the roughjdiwnab is a jewel in the rough
Re: Karel++ Noob help

Why not
Code:
class robot_pwn: ur_robot
{
	void movE( int n );
};

void robot_pwn :: movE( int n )
{
	int i
	for(i=0; i <= n; i++)
	{
		  move( );
	}
}
I hope this is the correct syntax, but you get the idea. You pass the number of "moves" you want to a function and it loops through the move funtion for that number of times. You wouldn't need a bunch of functions and be limited to 15 moves. You could put (depending on the compiler's limits) put 10,000 moves. You can then add whatever else, like turnRight(int degree); and turnLeft(int degree); for how far you want to turn.
__________________
Proof that Macs will win the platform war: How did Scotty know how to use MacDraft in Star Trek IV?
// random()
I have 100 gmail invites. PM me if you want one.
If they want us to think outside of the box, why do they make us fit in a 38x28x60 inch box?
Beware of Geeks bearing GIFs
Help me test my server software
  #4   Spotlight this post!  
Unread 08-09-2005, 15:23
sciguy125 sciguy125 is offline
Electrical Engineer
AKA: Phil Baltar
FRC #1351
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Sunnyvale, CA
Posts: 519
sciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond repute
Send a message via AIM to sciguy125 Send a message via MSN to sciguy125 Send a message via Yahoo to sciguy125
Re: Karel++ Noob help

Ok, I just took a crash course in Karel++. That was the fastest I've ever learned a new language. For those of you who are wondering, it turns out that Karel++ is the language you would get if LOGO and C++ had a child that was raised by BASIC (not sure how that works, but that's what it looks like to me).

Karel++ doesn't have a "for" loop, but it does have "loop" loop.

Code:
loop(5)
{
  move(); //calls move() 5 times
}
I'm not sure if it supports non-void functions (or "instructions" as they seem to be called). All the examples I found don't take or return parameters in the functions. Because of the way the language is designed, I suspect that the following code might work, but I don't have Karel++, so I can't test it.

Code:
void movenum(n)
{
  loop(n)
  {
    move();
  }
}
Just as some general advice: Whenever possible, it's a good idea to make multipurpose code. Your example of using 15 separate functions works, but it's not very clean. If you wanted to expand it for some reason, you might have a hard time doing so because it only does one thing. It also makes it hard to read any code that uses those functions.
__________________

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GE/S/P a-- e y-- r-- s:++ d+ h! X+++
t++ C+ P+ L++ E W++ w M-- V? PS+ PE+
5- R-- tv+ b+ DI+++ D- G
------END GEEK CODE BLOCK------
  #5   Spotlight this post!  
Unread 08-09-2005, 16:03
henryBsick's Avatar
henryBsick henryBsick is offline
Why wait for the last 20?
AKA: Henry B. Sick
FRC #0125 (NUTRONS)
Team Role: Mentor
 
Join Date: Nov 2003
Rookie Year: 2001
Location: Bahston, MA
Posts: 645
henryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond reputehenryBsick has a reputation beyond repute
Send a message via AIM to henryBsick
Re: Karel++ Noob help

OK guys. thanks for the help.
I am going to test the code tomorrow with a list of random tasks just to make sure all of the loops that I put in will read.

The purpose of this is to get an all functioning robot. I am going to go through the book I have and code in all of the shortcuts and pre-programmed moves. Then I am going to work on autonomous beeper harvesters for any situation.


On second thought... now that I know the loop function... I don't need all of what I just did. It would be pretty funny though, when one of my classmates reads my programs and says "HEY! How come your robot moves 9 time when all you have here is 'MovE' once ?!?!"
__________________
Mechanical Engineer
Digital Lumens
NU ME: 2011
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:01.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi