Difference between revisions of "Talk:BulletSimBot"

From Robowiki
Jump to navigation Jump to search
m (added signature)
(I don't know what to write here, I wrote too much information in the page =))
Line 105: Line 105:
 
--[[User:Awesomeness|Awesomeness]] 23:26, 5 May 2009 (UTC)
 
--[[User:Awesomeness|Awesomeness]] 23:26, 5 May 2009 (UTC)
  
In addition to what the others have said, I feel I should also note that the second code example you pasted, is NOT typical overall. It's typical of nanobots, but not full size ones, because nanobots so often sacrifice structure for codesize. That's probably what you've seen most partially because generally only nanobots have their full code pasted on the wiki. I'd suggest that you look at some bots without codesize restriction if you want to see clearer looking code. [[TheArtOfWar]] is a fairly traditional example for that type of thing, though I haven't looked at that one myself. --[[User:Rednaxela|Rednaxela]] 00:35, 6 May 2009 (UTC)
+
In addition to what the others have said, I feel I should also note that the second code example you pasted, is NOT typical overall. It's typical of nanobots, but not full size ones, because nanobots so often sacrifice structure for codesize. That's probably what you've seen most partially because generally only nanobots have their full code pasted on the wiki. I'd suggest that you look at some bots without codesize restriction if you want to see clearer looking code. [[TheArtOfWar]] is a fairly traditional example for that type of thing, though I haven't looked at that one myself.  
 +
--[[User:Rednaxela|Rednaxela]] 00:35, 6 May 2009 (UTC)
 +
 
 +
One thing you should know about creating a bot. RELEASE IT or you will never release anything. You won't believe me that I have over a hundred of unfinished bots in over 50 eclipse workspaces! I'm here about half a year and I can't even beat the top MicroBot! I want you look back at many many of unsuccessful authors. Don't look at the successful authors or you will lost your confident, especially with [[user:Zyx|zyx]], who started robocoding in less than a year and beat Shadow PL champs! I want you  to read the history of robocode. (it's on the old wiki) You will know that many advance technique is started like you are doing now, and evolve along the eight years (robocode start in 2001) Don't close your eye. Reading the advance stuffs before creating your own. Reading what have invented and thinking beyond it. In my earlier try I've once implement a thing that should be the same as old [[GuessFactor Targeting (traditional)|GuessFactor Targeting]], but worser that it doesn't care MEA or direction of enemy.
 +
 
 +
About your coding style, you can use your as long as you still understand what is going on. I think the main reason we don;t use getter and setter (and sometime constructor) is we lazy to type 5 more characters (w.velocity vs w.getVelocity()) I know that some bot like [[RougeDC]] and [[User:Zyx|zyx]]'s bot have very clean structure with all the getter and settter. That piece of code is cleaner code of the wiki, if you read current King ([[DrussGT]]) source you will agree with me. That code is not commented because the it need no comment. The variable name is self-document (read the {{OldWiki|WhyCommentsAreBad}} on the old wiki if you want) When you are cooking you robot, you will name the variable that self-documentation since there are too much data in robocode to just name it a,b,c,d (the exception is i in for loop and codesize-limited bot that the variables will sometimes reused) In order to understand the tutorial, you first need to understand what the result of tutorial is. Reading text before the code will make you understand what it actually done. I read the tutorial around 50 times before I fully get what it done in each part. And I think you know this, programmers are lazy. Instead of writing a long if(...) {...} command, they instead just use inline if (var = (exp) ? truevalue : falsevalue) IMO, writing a long, fully OO code will take you much more time to improve. I'm first try to make everything fully OO like you, but when I start developing a serious robot, I'm start to agree with [[User:Skilgannon|Skilgannon]] that [[DrussGT]] coding style is the most effective.
 +
 
 +
Another thing, don't drop your robot too fast. Release a robot with either linear or circular targeting to any rumble first, even if it get the 3 next to last position, it will make you confident more in yourself. Then move up with some PM (following Skilgannon way is th easiest way I think) or just more to GuessFactor Targeting and Segmentation. By understanding both, create another bot with it or if you are too lazy like me you can just skip it. Then reading the more complicate stuff like [[Dynamic Clustering]], [[Wiki Targeting]] and vice versa. Pressing random page on the old wiki for an hour and read everything it come up will make you learn faster. Reading the discussion too, that contain more information than the article itself. This is how I come up. &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 01:11, 7 May 2009 (UTC)

Revision as of 02:11, 7 May 2009

Hey guys! My bot beats DrussGT! It's weird, he just self destructs do to an error or something about a second after starting, and for the rest of the match, just appears as a crater you see after a robot blows up, not a robot. PwnBot wins instantly. PwnBot pwns him even more by making him never work again, (I had to re-download DrussGT) and best of all, I tried the trick with other bots, and it didn't work. I tried it with PwnBot again, and... PWNED! I had to re-download DrussGT again. Same thing happens with Waylander. =D

--Awesomeness 20:15, 3 May 2009 (UTC)

I bet you will see something like this in his robot console:

SYSTEM: You have skipped a turn. (x30)
SYSTEM: This robot is stopped because it doesn't perform any action in a reasonable amount of time. No score will be generated.

And that robot removed in repository, mean that you cannot create a battle with that robot again. :-) » Nat | Talk » 12:18, 4 May 2009 (UTC)

It is? Aww man... I shouldn't have killed my second copy... --Awesomeness 00:17, 5 May 2009 (UTC)

If you're putting DrussGF into melee as opposed to one-on-one this would be expected. Many one-on-one bots have code to make them outright refuse to run in melee. --Rednaxela 12:47, 4 May 2009 (UTC)

I think you mean DrussGT, do you? But why this is expected? I think it will act like every enemy is the same. » Nat | Talk » 12:57, 4 May 2009 (UTC)
Depends on the code, some bots may have a decent behavior, some may crash, some may sit still. I believe DrussGT crashes if the battle field isn't 800x600, maybe it has some other hard-coded values so is better to try it with the normal rumble values. Edit: signature added a day after the comment. --zyx 20:44, 6 May 2009 (UTC)


Sorry if this is a bit long, but I really need to tell you this, or I'll never get any farther in Robocode.


Ugh... I found my virtual bullets simulator is totally useless for what I was planning to do with them, because I later found out that my plan was almost identical to primitive wave surfing. I can't really use them for targeting either because guess factor targeting just seems to beat everything else, and there's no uncharted ground for research. It seems to me that the one thing I made that was so important to this bot, which was going to be my first big huge statistical MegaBot, is just not good enough. It seems everything I wanted to do is just worse versions of stuff already invented. Even if there's some use for my virtual bullets and stuff I'm sure it's way too complicated for my 7th grade brain to understand. It seems like whatever I come up with is a primitive version of something now evolved into a way better version of it. So far, I've invented, and discovered it's already been done, with wave surfing, guessfactor targeting, minimum risk movement, pattern matching, and many others. Of course, then I find there's a better strategy of he same concept that's five times as good and I feel all glum. Repeat. Repeat again... Etcetera.

Anyways... I can't really do anything with PwnBot anymore, and I don't know how to get any farther ahead because I'm clueless on how to do any advanced movement or targeting. I understand exactly how they work, but never how they're implemented it. That's my problem in Java: I'm great at doing almost everything, but I can almost never do anything requiring optimization, statistics, searching, etc. It's why it's taken me over six months to have just almost finished a file compression program I've been working on, and it seems like this is why I can't do any of the complicated stuff in Robocode.

I just wish I was a genius like you guys. Sure, I'm in an advanced school. Sure, I started programming when I was eight, but I'm not a genius like you, meaning Voidious, ABC, PEZ, etcetera. How do you do it? You always know just how to do things and can come up with trig stuff in the blink of an eye, and make a robot in you're sleep that'd beat all of my robots combined. I wish I was at all like you in this. I don't know, maybe I just need practice, maybe it's just I'm too young, I don't know, but around you guys I really feel good-for-nothing here.

And I know all three of you plus more are going to say, "It didn't happen overnight!" but the thing is, I really can't catch up with you guys. I've been around for much longer than a quarter of a year, and the best bots are getting better five times as fast as I'm learning. I'm not even learning that much anymore because I simply don't understand how to do all this complicated stuff. All the tutorials explain entire classes all at once, and for me to understand a really complicated Java program, I really need it unpacked, step-by-step and not optimized for codesize so much that guessfactor targeting fits in a nano bot.

My style of coding is like this:

		VirtualBullet(double startX, double startY, double velocity, double trajectory) {
			x = startX;
			y = startY;
			speed = velocity;
			angle = trajectory;
		}
		
		public void tick(long ticks) {  //Moves the bullet the amount it would
			while(ticks > 0) {
				x += Math.sin(angle)*speed;
				y += Math.cos(angle)*speed;
				ticks --;
			}
		}
		
		//Just simple gets and sets
		public double getX() {
			return x;
		}
		
		public double getY() {
			return y;
		}
		
		//Returns distance
		public double getDistance(double botX, double botY) {
			return Math.sqrt(Math.pow(botX-x, 2)+Math.pow(botY-y, 2));
		}
		
		//If the bullet is on top of my bot, or has hit the wall, returns true
		public boolean checkCollide(double botX, double botY) {
			if (x < 0 || y < 0 || x > getBattleFieldWidth() || y > getBattleFieldHeight()) {
				return true;
			}
			if(botX-18<x && botX+18>x && botY-18<y && botY+18>y) {
				return true;
			}
			return false;
		}

Although I took a fairly simple part of the code, you can still see I comment almost everything and I space things out. I don't stuff a million things all into the same method, I just make it all clear. While all the stuff I see online is:

		double absBearing = getHeadingRadians() + e.getBearingRadians();
		double firePower = e.getDistance() < 200 ? 3 : 1.72;
		BulletWave w = new BulletWave();
		w.firedLocation = new Point2D.Double(getX(), getY());
		enemyLoc = new Point2D.Double(getX() + Math.sin(absBearing) * e.getDistance(), getY()
				+ Math.cos(absBearing) * e.getDistance());
		w.bearingDir = (e.getVelocity() * Math.sin(e.getHeadingRadians() - absBearing) < 0 ? -BIN_WIDTH
				: BIN_WIDTH);
		w.bearing = absBearing;
		w.velocity = bulletVelocity(firePower);
		int distanceIndex = (int) e.getDistance() / (MAX_DISTANCE / DISTANCE_INDEXES);
		int velocityIndex = (int) Math.abs(e.getVelocity() / 2);
		w.aimFactors = aimFactors[distanceIndex][velocityIndex];
		int mostVisited = MIDDLE_BIN;
		for (int i = 0; i < BINS; i++) {

I consider that impossible to understand. Packed together so much and no comments whatsoever. I guess I'll never learn much until I learn how to decipher stuff like this...

--Awesomeness 22:13, 5 May 2009 (UTC)


Hi Awesomeness, I haven't talked to you much yet. Just so you know, I am also new to both robocode and java, and I reached a stage similar to yours a while ago, where I felt as if I was pretty much stuck and had reached a plateau in my ability to understand things on the wiki. I realized that it was almost impossible for me to look at the code of the advanced robots and have any ideas about what the code did. For me, I found the solution in slowing down. Instead of working on other peoples ideas, I started developing a few of my own(Yes, 99.9% of the ideas I thought of had been done already). My advice to you is to check out every idea you have, even it shows little promise. Lots of times I've had random thoughts that seemed like they would get me nowhere when I first started them, but some of them ended up being new ideas that halfway work and definitely helped to advance my knowledge of robocode(and java, extremely important for me!).--CrazyBassoonist 22:56, 5 May 2009 (UTC)

P.S.- about the math, I am also not old enough to have taken trig, but I have definitely got a lot better at robot-related math since I started. You'll learn--CrazyBassoonist 22:58, 5 May 2009 (UTC)

Hey man, don't knock yourself out about stuff like that. I'm a computer science major specialized in computer graphics and artificial intelligence, have been programming for more than 13 years and been competing in programming contests for 7 years, and still took me about a year to have a decent competitive Bot. As CrazyBassoonist mentioned, slowing down is not a bad thing, I implemented the simple methods to start, while working on a decent Stop And Go you understand a lot about the Physics in Robocode, and that understanding is crucial for advanced techniques. GuessFactor Targeting and Wave Surfing aren't called advanced for nothing, but if you keep working you will get it done, don't try to go over your head though, don't try to segment it until you have it working for instance. Wave Surfing took me lots of hard working hours while going trough the tutorial and still had many bugs at the end, about the 9th version I wrote I would call bug-free (which means it probably still has some bugs :). About the trig, well it's true that you will need to master it,but look at CrazyBassoonist and Nat, they are both youngsters who have improved their trig skills while Robocoding. Just keep trying and ask questions qhen you need help. --zyx 23:33, 5 May 2009 (UTC)

Oh and I forgot, if you feel you can't work on a bot to improve it more, don't think you got to your end, the bot did, fire up your favorite IDE and start a fresh new bot ;). That usually leads to better structured code and less buggy implementations, what you learned in previous bots will carry on. --zyx 23:37, 5 May 2009 (UTC)

I guess you're right. I should keep trying. After all, giving up won't help me get better! I should expand on my old ideas. You're right.

--Awesomeness 23:26, 5 May 2009 (UTC)

In addition to what the others have said, I feel I should also note that the second code example you pasted, is NOT typical overall. It's typical of nanobots, but not full size ones, because nanobots so often sacrifice structure for codesize. That's probably what you've seen most partially because generally only nanobots have their full code pasted on the wiki. I'd suggest that you look at some bots without codesize restriction if you want to see clearer looking code. TheArtOfWar is a fairly traditional example for that type of thing, though I haven't looked at that one myself. --Rednaxela 00:35, 6 May 2009 (UTC)

One thing you should know about creating a bot. RELEASE IT or you will never release anything. You won't believe me that I have over a hundred of unfinished bots in over 50 eclipse workspaces! I'm here about half a year and I can't even beat the top MicroBot! I want you look back at many many of unsuccessful authors. Don't look at the successful authors or you will lost your confident, especially with zyx, who started robocoding in less than a year and beat Shadow PL champs! I want you to read the history of robocode. (it's on the old wiki) You will know that many advance technique is started like you are doing now, and evolve along the eight years (robocode start in 2001) Don't close your eye. Reading the advance stuffs before creating your own. Reading what have invented and thinking beyond it. In my earlier try I've once implement a thing that should be the same as old GuessFactor Targeting, but worser that it doesn't care MEA or direction of enemy.

About your coding style, you can use your as long as you still understand what is going on. I think the main reason we don;t use getter and setter (and sometime constructor) is we lazy to type 5 more characters (w.velocity vs w.getVelocity()) I know that some bot like RougeDC and zyx's bot have very clean structure with all the getter and settter. That piece of code is cleaner code of the wiki, if you read current King (DrussGT) source you will agree with me. That code is not commented because the it need no comment. The variable name is self-document (read the WhyCommentsAreBad on the old wiki if you want) When you are cooking you robot, you will name the variable that self-documentation since there are too much data in robocode to just name it a,b,c,d (the exception is i in for loop and codesize-limited bot that the variables will sometimes reused) In order to understand the tutorial, you first need to understand what the result of tutorial is. Reading text before the code will make you understand what it actually done. I read the tutorial around 50 times before I fully get what it done in each part. And I think you know this, programmers are lazy. Instead of writing a long if(...) {...} command, they instead just use inline if (var = (exp) ? truevalue : falsevalue) IMO, writing a long, fully OO code will take you much more time to improve. I'm first try to make everything fully OO like you, but when I start developing a serious robot, I'm start to agree with Skilgannon that DrussGT coding style is the most effective.

Another thing, don't drop your robot too fast. Release a robot with either linear or circular targeting to any rumble first, even if it get the 3 next to last position, it will make you confident more in yourself. Then move up with some PM (following Skilgannon way is th easiest way I think) or just more to GuessFactor Targeting and Segmentation. By understanding both, create another bot with it or if you are too lazy like me you can just skip it. Then reading the more complicate stuff like Dynamic Clustering, Wiki Targeting and vice versa. Pressing random page on the old wiki for an hour and read everything it come up will make you learn faster. Reading the discussion too, that contain more information than the article itself. This is how I come up. » Nat | Talk » 01:11, 7 May 2009 (UTC)