Difference between revisions of "User talk:Awesomeness"

From Robowiki
Jump to navigation Jump to search
(linear prediction code and Anti-Gravity Movement)
(American flag)
 
(42 intermediate revisions by 6 users not shown)
Line 2: Line 2:
 
| title = Archived talks
 
| title = Archived talks
 
| page1 = Archived Talk 20090502
 
| page1 = Archived Talk 20090502
 +
| page2 = Archived Talk 20090504
 
}}
 
}}
  
Okay, I need to make a list of bullets.  I have made a bullet class and everything, but I need a special list that will let me access all of the bullets in a while/for loop and be able to add and remove them at any time and never mess up.  If I did this in a normal array I could do a for loop and access using an increasing number, but I wouldn't know when to stop. In a while loop, if I used while(bulletsArray[x] != null) and then increment x, after I remove my first bullet that say, hit a wall, it will stop there.  I need help!
+
Help! I can't edit any pages because of some stupid database error! --[[User:Awesomeness|Awesomeness]] 21:57, 6 May 2009 (UTC)
  
:Thanks,
+
:Hey, it works now...  --[[User:Awesomeness|Awesomeness]] 22:00, 6 May 2009 (UTC)
::[[User:Awesomeness|Awesomeness]] 14:02, 2 May 2009 (UTC)
 
  
I think this will do:
+
Okay, I'm almost done with the prototype of my bot. It's really big, so I'll put it [[PwnBot/Current_Code|here]]. I'm sure it has lots of problems with the antigrav movement, (just look at the console, which shows the x force and y force that the points generate) and I'm sure it doesn't work at all... However, do take a look at the debug graphics, I think they're cool. =)
<pre>
+
--[[User:Awesomeness|Awesomeness]] 20:52, 4 May 2009 (UTC)
ArrayList<Bullet> bullets = new ArrayList<Bullet>();
 
for (int i = 0; i < bullets.size(); i++) {
 
    Bullet bullet = bullets.get(i);
 
    if (bullet.needRemove()) {
 
        // I think this will work
 
        // bullets.remove(i--);
 
        // but usually I do
 
        bullets.remove(bullet);
 
        i--;
 
    }
 
}
 
</pre>
 
Here I assume that you use ArrayList to store you bullets and your bullet's classname is Bullet. If you use a plain array to keep the bullets, consider change to ArrayList. It is more flexible. &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 14:09, 2 May 2009 (UTC)
 
  
:Oh my goshYou're rightArrayList is way more flexible! I looked at the documentation; you don't even have to increment or decrement anything!  The function remove() shifts the other elements to the left already!  Thanks!  [[User:Awesomeness|Awesomeness]] 14:14, 2 May 2009 (UTC)
+
:OH NOSomething I did with the antigrav code messed up the bullet sim codeGood thing I backed up the non-broken version before I added antigrav.  Should I show that one instead? I can't figure out how to add antigrav, I guess I'm simply just not good enough.  Oh well... =(   --[[User:Awesomeness|Awesomeness]] 20:58, 4 May 2009 (UTC)
  
:: Be sure don't use for-each style (<code>for(Bullet bullet : bullets)</code> or you will get ConcurentModificationException when you remove element (this is per java spec, but I still use the for-each style and didn't get this exception actually). And when you scroll through the array like one I mentioned, be sure you do i--, or you will just skip one element. &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 14:19, 2 May 2009 (UTC)
+
:: Don't say that - you wouldn't believe how buggy the first version of [[Dookious]] was. =) And I had been programming for years, and had four semesters of Computer Science study under my belt. Seriously, keep at it, dude... --[[User:Voidious|Voidious]] 21:04, 4 May 2009 (UTC)
  
:: Oh, you're right.  [[User:Awesomeness|Awesomeness]] 14:27, 2 May 2009 (UTC)
+
::: I'm going to put the before-I-messed-it-up code on instead--[[User:Awesomeness|Awesomeness]] 22:11, 4 May 2009 (UTC)
  
: One suggestion. Don't use <code>bullets.remove(bullet);</code>, use <code>bullets.remove(i);</code> instead because removing by index is far faster than removing by content. Well, with the size the list is in robocode it probably doesn't matter a ton, but removal of list by content, when you already have the index on hand, seems terribly wasteful to me. --[[User:Rednaxela|Rednaxela]] 14:45, 2 May 2009 (UTC)
+
What do you think of my targeting idea on my userpage? --[[User:Awesomeness|Awesomeness]] 00:44, 7 May 2009 (UTC)
  
: I changed that myself already. =D lol  [[User:Awesomeness|Awesomeness]] 14:56, 2 May 2009 (UTC)
+
: I think I've seen something like this before but I don't remember which so don't care. Now, I understand how I recorded thing to tree, but how it find the match? &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 01:19, 7 May 2009 (UTC)
  
I've grown very fond of iterators for Lists, this would be my implementation:
+
:: It would look through every branch in the tree, and it will look for matches.  It simply takes the current speed, acceleration, turn rate, etc. and finds the closest match, or matches. If there are multiple branches that match, it would take the branch that occurs most. I suppose if they're even in occurence it might pick them randomly. Then again, it might balance out, choosing based on the closeness of the match and the number of occurences combined. There's lot's of ways to do it. --[[User:Awesomeness|Awesomeness]] 01:50, 7 May 2009 (UTC)
<pre>
 
ArrayList<Bullet> bullets = new ArrayList<Bullet>();
 
Iterator<Bullet> i = bullets.iterator();
 
while (i.hasNext()) {
 
    Bullet bullet = i.next();
 
    if (bullet.needRemove()) {
 
        i.remove();
 
    }
 
}
 
</pre> --[[User:Skilgannon|Skilgannon]] 15:00, 2 May 2009 (UTC)
 
: Ahhh... I never knew that iterator has remove method so I always using ArrayLisy.get(i) to prevent ConcurentModificationException. Thanks you very much. &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 15:06, 2 May 2009 (UTC)
 
  
----
+
::: OK, I think I remember which now. [[LambdaBot]]'s state searching. =P &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 01:55, 7 May 2009 (UTC)
  
How do you find the x and y of a robot you've scanned? I see no <code>ScannedRobotEvent.getX()</code> or <code>getY()</code> method.  [[User:Awesomeness|Awesomeness]] 15:19, 2 May 2009 (UTC)
+
:::: It seems none of my ideas are ever new.  Man!  Everyone's thought of everything! Either way, I suppose mine might still be new because i'ts a targeting implementation, not movement--[[User:Awesomeness|Awesomeness]] 01:58, 7 May 2009 (UTC)
  
Trig Trig Trig...
+
:::::  If I'd thought of it just a bit earlier, it'd finally be my first original idea... --[[User:Awesomeness|Awesomeness]] 02:02, 7 May 2009 (UTC)
<pre>
 
double absBearing = e.getBearingRadians() + getHeadingRadians();
 
double x = getX() + Math.sin(absBearing) * e.getDistance();
 
double y = getY() + Math.cos(absBearing) * e.getDistance();
 
</pre>
 
That's all. &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 15:21, 2 May 2009 (UTC)
 
  
Here's a method I use in my utils class (I first saw it in a [[PEZ]] bot):
+
:::::: Hey, usually we all share many of common ideas, but who can conclude every single step with detailed information will be the inventor =D ABC might be the inventor of Wave Surfing, but many bots have done similar to Wave Surfing, but ABC can conclude what to done before another people. Pual might be inventor of GuessFactor Targeting but David have done thing similar to in the same time. &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 02:09, 7 May 2009 (UTC)
<pre>
 
    public static Point2D.Double project(Point2D.Double sourceLocation,  
 
        double angle, double length) {
 
        return new Point2D.Double(sourceLocation.x + Math.sin(angle) * length,
 
            sourceLocation.y + Math.cos(angle) * length);
 
    }
 
    // You'd pass it something like:  
 
    // myLocation = new Point2D.Double(getX(), getY());  
 
    // enemyLocation = MyUtils.project(myLocation, absBearing, e.getDistance());
 
</pre>
 
--[[User:Voidious|Voidious]] 16:15, 2 May 2009 (UTC)
 
  
 +
::::::: Yeah, I suppose you're right.  I'm going to try to make the gun eventually.  It'll be pretty hard.  --[[User:Awesomeness|Awesomeness]] 02:13, 7 May 2009 (UTC)
  
Lastly, I need a way to "dodge" these simulated bullets and to figure out what angle the oppenent bot would be shooting from if it used linear targeting against meI don't know how to do either of these. [[User:Awesomeness|Awesomeness]] 16:31, 2 May 2009 (UTC)
+
::::: Just creating a new bot is inventing.  There are always new takes on old ideas, ways to tweak something that's been done and make it betterWhat flag do you want in the rumble? --[[User:Darkcanuck|Darkcanuck]] 02:23, 7 May 2009 (UTC)
  
To dodge, use [[Anti-Gravity Movement]], to assume linear firing, use this code:
+
:::::: American, please.  --[[User:Awesomeness|Awesomeness]] 17:13, 10 May 2009 (UTC)
<pre>
+
 
angle = Utils.normalRelativeAngle(absBaering +  Math.PI + Math.asin((Math.sin(e.getBearingRadians()) * getVelocity())/(20 - 3 * BULLET_POWER)));
+
Wow, thanks for clearing it! &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 08:21, 10 May 2009 (UTC)
</pre>
 
replace BULLET_POWER to which you get from energy drop. This prediction use non-iterative no-wall-stopping linear targeting. &raquo; <span style="font-size:0.9em;color:darkgreen;">[[User:Nat|Nat]] | [[User_talk:Nat|Talk]]</span> &raquo; 16:35, 2 May 2009 (UTC)
 

Latest revision as of 19:13, 10 May 2009

Archived talks:
Archived Talk 20090502 - Archived Talk 20090504

Help! I can't edit any pages because of some stupid database error! --Awesomeness 21:57, 6 May 2009 (UTC)

Hey, it works now... --Awesomeness 22:00, 6 May 2009 (UTC)

Okay, I'm almost done with the prototype of my bot. It's really big, so I'll put it here. I'm sure it has lots of problems with the antigrav movement, (just look at the console, which shows the x force and y force that the points generate) and I'm sure it doesn't work at all... However, do take a look at the debug graphics, I think they're cool. =) --Awesomeness 20:52, 4 May 2009 (UTC)

OH NO! Something I did with the antigrav code messed up the bullet sim code! Good thing I backed up the non-broken version before I added antigrav. Should I show that one instead? I can't figure out how to add antigrav, I guess I'm simply just not good enough. Oh well... =( --Awesomeness 20:58, 4 May 2009 (UTC)
Don't say that - you wouldn't believe how buggy the first version of Dookious was. =) And I had been programming for years, and had four semesters of Computer Science study under my belt. Seriously, keep at it, dude... --Voidious 21:04, 4 May 2009 (UTC)
I'm going to put the before-I-messed-it-up code on instead. --Awesomeness 22:11, 4 May 2009 (UTC)

What do you think of my targeting idea on my userpage? --Awesomeness 00:44, 7 May 2009 (UTC)

I think I've seen something like this before but I don't remember which so don't care. Now, I understand how I recorded thing to tree, but how it find the match? » Nat | Talk » 01:19, 7 May 2009 (UTC)
It would look through every branch in the tree, and it will look for matches. It simply takes the current speed, acceleration, turn rate, etc. and finds the closest match, or matches. If there are multiple branches that match, it would take the branch that occurs most. I suppose if they're even in occurence it might pick them randomly. Then again, it might balance out, choosing based on the closeness of the match and the number of occurences combined. There's lot's of ways to do it. --Awesomeness 01:50, 7 May 2009 (UTC)
OK, I think I remember which now. LambdaBot's state searching. =P » Nat | Talk » 01:55, 7 May 2009 (UTC)
It seems none of my ideas are ever new. Man! Everyone's thought of everything! Either way, I suppose mine might still be new because i'ts a targeting implementation, not movement. --Awesomeness 01:58, 7 May 2009 (UTC)
If I'd thought of it just a bit earlier, it'd finally be my first original idea... --Awesomeness 02:02, 7 May 2009 (UTC)
Hey, usually we all share many of common ideas, but who can conclude every single step with detailed information will be the inventor =D ABC might be the inventor of Wave Surfing, but many bots have done similar to Wave Surfing, but ABC can conclude what to done before another people. Pual might be inventor of GuessFactor Targeting but David have done thing similar to in the same time. » Nat | Talk » 02:09, 7 May 2009 (UTC)
Yeah, I suppose you're right. I'm going to try to make the gun eventually. It'll be pretty hard. --Awesomeness 02:13, 7 May 2009 (UTC)
Just creating a new bot is inventing. There are always new takes on old ideas, ways to tweak something that's been done and make it better. What flag do you want in the rumble? --Darkcanuck 02:23, 7 May 2009 (UTC)
American, please. --Awesomeness 17:13, 10 May 2009 (UTC)

Wow, thanks for clearing it! » Nat | Talk » 08:21, 10 May 2009 (UTC)