ivaneeo's blog

          自由的力量,自由的生活。

            BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
            669 Posts :: 0 Stories :: 64 Comments :: 0 Trackbacks

          常用鏈接

          留言簿(34)

          我參與的團(tuán)隊(duì)

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          看rrobots的一個(gè)簡(jiǎn)單的例子:

          ----------------------- code -----------------------
          require 'robot'

          class NervousDuck
          ?? include Robot

          ? def tick events
          ??? turn_radar 1 if time == 0
          ??? turn_gun 30 if time < 3
          ??? accelerate 1
          ??? turn 2
          ??? fire 3 unless events['robot_scanned'].empty?
          ? end
          end

          ----------------------- code -----------------------

          這里至少要實(shí)現(xiàn)tick方法.

          下面是控制robot的一些方法和屬性:

          ? battlefield_height? #the height of the battlefield
          ? battlefield_width?? #the width of the battlefield
          ? energy????????????? #your remaining energy (if this drops below 0 you are dead)
          ? gun_heading???????? #the heading of your gun, 0 pointing east, 90 pointing
          ????????????????????? #north, 180 pointing west, 270 pointing south
          ? gun_heat??????????? #your gun heat, if this is above 0 you can't shoot
          ? heading???????????? #your robots heading, 0 pointing east, 90 pointing north,
          ????????????????????? #180 pointing west, 270 pointing south
          ? size??????????????? #your robots radius, if x <= size you hit the left wall
          ? radar_heading?????? #the heading of your radar, 0 pointing east,
          ????????????????????? #90 pointing north, 180 pointing west, 270 pointing south
          ? time??????????????? #ticks since match start
          ? speed?????????????? #your speed (-8/8)
          ? x?????????????????? #your x coordinate, 0...battlefield_width
          ? y?????????????????? #your y coordinate, 0...battlefield_height
          ? accelerate(param)?? #accelerate (max speed is 8, max accelerate is 1/-1,
          ????????????????????? #negativ speed means moving backwards)
          ? stop??????????????? #accelerates negativ if moving forward (and vice versa),
          ????????????????????? #may take 8 ticks to stop (and you have to call it every tick)
          ? fire(power)???????? #fires a bullet in the direction of your gun,
          ????????????????????? #power is 0.1 - 3, this power will heat your gun
          ? turn(degrees)?????? #turns the robot (and the gun and the radar),
          ????????????????????? #max 10 degrees per tick
          ? turn_gun(degrees)?? #turns the gun (and the radar), max 30 degrees per tick
          ? turn_radar(degrees) #turns the radar, max 60 degrees per tick
          ? dead??????????????? #true if you are dead
          ? say(msg)??????????? #shows msg above the robot on screen
          ? broadcast(msg)????? #broadcasts msg to all bots (they recieve 'broadcasts'
          ????????????????????? #events with the msg and rough direction)

          posted on 2006-11-18 00:33 ivaneeo 閱讀(466) 評(píng)論(0)  編輯  收藏 所屬分類: ruby-寶石也鋒芒
          主站蜘蛛池模板: 拜城县| 九江县| 盐源县| 张家川| 澄江县| 鹤壁市| 桂平市| 贺兰县| 成安县| 民权县| 蒙自县| 丹棱县| 镇安县| 筠连县| 积石山| 和田县| 随州市| 蛟河市| 吉木乃县| 酉阳| 红河县| 新津县| 大丰市| 白朗县| 庆安县| 斗六市| 东安县| 出国| 株洲市| 太白县| 穆棱市| 井研县| 大埔区| 饶阳县| 罗源县| 天长市| 孟州市| 沁阳市| 罗定市| 谷城县| 灌阳县|