User talk:Hapiel

From Robowiki
Revision as of 03:14, 13 January 2011 by Rednaxela (talk | contribs) (Welcome and reply!)
Jump to navigation Jump to search

Welcome!

Hello, Hapiel, and welcome to RoboWiki! This place contains a wealth information about Robocode, from basic to more advanced. I hope you enjoy creating robots and being a robocoder!

If you are posting a comment on this wiki, please sign your messages using four tildes (--~~~~); this will automatically insert your username and the date stamp. If you are not familiar with MediaWiki, these links might help you out:

If you need help, check out the frequently asked questions or ask it on this page. Again, welcome!

—— RoboWiki Administrators


Hello guys, I see some of you chat around on talk pages, and as there is no real question forum for Robocode or any other kind of community where the beginning programmer (me) can get answers on his stupid questions I am going to try it out here.

I have very little experience programming, not too much. I get demotivated quickly, because small errors or problems have huge impact on your programs, and I have never found a good solution for that ;). However, somehow when I saw robo soccer on tv I thought I should try robocode once more!

Aaah, I have a question!

while (true) {
			if (getX() <= 100 || getY() <=100 || getBattleFieldWidth() - getX() <= 100 || getBattleFieldHeight() - getY() <= 100) {
				reverseDirection();
			}
			waitFor(new RadarTurnCompleteCondition(this));
			

			setTurnRadarRight(360);
			
			
		}

So, this is a bit of an edit on one of the samplebots, Crazy. Does not matter much. As you can see I wrote an ugly not working system to detect if my robot is close to a wall. However, it does not work.

It only detects the wall if I replace the waitFor code with execute;, but in that case my radar is constantly spinning (right now my onScannedRobot code prevents it from spinning continiously).

I hoped I would be able to create an IF thingy to check if the radarturn was finished, or create an event on radarturncompletion, but was not able to figure it out! How exactly do conditions work? What does the (this) in the radarturncompletecondition code stand for, and what would be a simple/proper solution to my problem? Please let me know, any help is welcome!!

Hapiel --Hapiel =) 22:29, 12 January 2011 (UTC)

Greetings and welcome to the Robowiki! Lots of chat on talk pages indeed, in fact that's the primary use of this place I'd say. A little different than some other wikis.

Anyway, I haven't tested, but looking at that code, I'm pretty sure what you're missing an 'execute' call after 'setTurnRadarRight'. Without the 'execute' call, your loop will immediately skip to the top again, and run 'setTurnRadarRight' over and over without "telling" the robocode engine "I'm done my turn". Make sense?

--Rednaxela 01:14, 13 January 2011 (UTC)