So, after sifting through my code for a bit, I figured out why my LOS was so buggy. When using the Java's Math.tan() function, it inputs the angle in radians. I was using degrees, so I had to convert the angle from degrees to radians. I then (most unfortunately) had two very-similarly name variables, one which held the degree in radians and the other which held it in degrees. Everything about what I wrote WOULD have worked, except that some of my if/then/else statements which I used to filter out a few cases were designed to work with degrees... Except I had plugged in the radian version into them all!
But, now it's fixed. I love how making horrid mistakes like this helps me become a better programmer, because it's just one more thing in the back of my head that nags me while I'm writing code. (and yes, this is the main reason I'm working on this project; to become a better programmer)
So, the LOS works fine. It's directional and your agent can only see in a variable field of vision centered on whatever direction he/she is facing. Tomorrow I'll add a screenshot, as I'm on my laptop and I can't figure out where my printscreen key is. next I've just got to impletement an 'explored' array, so that things that the agent has seen in the past will show up also;
My LOS effectively casts 'rays' of sight from the agent in the directions needed. I'm aware that this isn't the best way to do this, and I'm sure I'll change it in the future.
Saturday, July 11, 2009
Subscribe to:
Post Comments (Atom)
1 comment:
Meh, don't worry about it, it's not like CPU usage is the biggest concern in a RL nowadays! At least you have a good understanding of how that algorithm works. And it does work :)
Post a Comment