User talk:Hapiel

From Robowiki
Revision as of 17:40, 13 January 2011 by Hapiel (talk | contribs) (Question not answered :()
Jump to navigation Jump to search

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)

Thanks for your reply! Is there an easy way to browse talk pages, or do you find the current topics only by going to the recent changes page?

Back to my question: The code runs, I suppose that waitFor is a proper replacement for an execute code. If I add execute to this, nothing visibly changes. Again, the problem is is that the piece of wall detection code is not run constant. It is only run when my scanner has finished turning (which is about never, except for when I just killed a robot.) If I replace the waitfor by execute();, my scanner keeps spinning constantly all the time, while if I use the wait for it is being overwritten by setScannerRight codes in my onScannedRobot event.

What would be the way so that my robot does scan this virtual wall at all time, but does not spin continiously? --Hapiel =) 16:40, 13 January 2011 (UTC)

You cannot post new threads to this discussion page because it has been protected from new threads, or you do not currently have permission to edit.

There are no threads on this page yet.