🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.comp.lang.java
Article #211

Re: ��������Robocode����

#211
From: Mr.Bug
Date: Sat, 18 Feb 2006 12:39
52 lines
2127 bytes
ѧϰһ��crazy��Ȼ��д����ǿ��
package sample;
import robocode.*;
public class Crazy extends AdvancedRobot
{
 boolean movingForward;
 public void run() {
  while (true)
  {
   setAhead(40000);
   movingForward = true;
   setTurnRight(90);
   waitFor(new TurnCompleteCondition(this));
   setTurnLeft(180);
   waitFor(new TurnCompleteCondition(this));
   setTurnRight(180);
   waitFor(new TurnCompleteCondition(this));
  }
 }
 public void onHitWall(HitWallEvent e)
 {
  reverseDirection();
 }
 public void reverseDirection() {
  if (movingForward)
  {
   setBack(40000);
   movingForward = false;
  }
  else
  {
   setAhead(40000);
   movingForward = true;
  }
 }
 public void onScannedRobot(ScannedRobotEvent e)
 {
  fire(1);
 }
 public void onHitRobot(HitRobotEvent e)
 {
  if (e.isMyFault())
   reverseDirection();
 }
}
"�IJ���" <a@a.a> д���ʼ� news:dt6r2f$ajc$1@news.yaako.com...
> ͦ�����
> �Ǹ���crazy�Ļ�������ǿ
> ��ϧ��д����
>
> ����ǰ�Ĵ�о��ս����˼
>
Technical Details
Message-ID: <dt74in$k7k$1@news.yaako.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.media.kyoto-u.ac.jp!news.cn99.com!news.yaako.com!not-for-mail
References: <43f6034c.57369853@cnusenet.3322.org> <dt6r2f$ajc$1@news.yaako.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10d5a2,c6da0d7483f14df9
X-Google-Thread: 107c7f,c6da0d7483f14df9
X-Google-Attributes: gid10d5a2,gid107c7f,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.media.kyoto-u.ac.jp!news.cn99.com!news.yaako.com!not-for-mail
From: "Mr.Bug" <guohaicn@hotmail.com>
Newsgroups: cn.comp.lang.java,cn.fan
Subject: Re: ��������Robocode����
Date: Sat, 18 Feb 2006 20:39:52 +0800
Organization: Bentium Ltd. (CN99)
Lines: 54
Message-ID: <dt74in$k7k$1@news.yaako.com>
References: <43f6034c.57369853@cnusenet.3322.org> <dt6r2f$ajc$1@news.yaako.com>
NNTP-Posting-Host: 61.51.235.128
X-Trace: news.yaako.com 1140266391 20724 61.51.235.128 (18 Feb 2006 12:39:51 GMT)
X-Complaints-To: usenet@news.yaako.com
NNTP-Posting-Date: Sat, 18 Feb 2006 12:39:51 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506