Robocode学习笔记(二)

来源:互联网 发布:网络兼容模式怎么设置 编辑:程序博客网 时间:2024/05/02 04:32
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

  很多研究Robocode的 玩家都被其中的方向及坐标弄糊涂了。整个屏幕哪个是0度角,整个是坐标原点呢? 顺时针与逆时针的方向如何区分?

一段英文的翻译及说明:

  • heading - absolute angle in degrees with 0 facing up the screen, positive clockwise. 0 <= heading < 360.
  • bearing - relative angle to some object from your robot's heading, positive clockwise. -180 < bearing <= 180
  • heading:是机器人方向与屏幕正上方的角度差,方向在0到360之间.
  • bearing:是机器人的某个部件如雷达发现的目标与方向的角度差,顺时针为正角度在-180到180之间

几个在Robocode中很重要的概念:

  • 坐标系:Robocode整个坐标系都是战场屏幕以左下角为原点
  • 绝对方向系:Robocode中不管机器人在哪个方向都是以静态战场屏幕为参照的绝对角度(也即大家说的Heading),正上方为0度角。也即不管是Robot,Gun,Radar向北为0,向东为90,向南为180,向西为270。
  • 相对方向系:相对方向是Robot,Gun,Radar以机器人的动态heading角度为参照的角度差不再以整个静态屏幕为参照了,叫它相对因为机器人的heading是随着机器人移动而不停的在改变,heaing只是个相对物体。
  • 顺时针和逆时针是看另一机器人是在你的Heading角度的(0,180)还是(-180,0)之间。

  再次提醒:Heading是个静态角度,正上方总为0.不管是取Heading,还是取方向。Bearing是个角度差值,是由参照的Heading和发现时的Heading的差值。好了,方向的问题就说到这,欢迎大家来讨论。

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击