资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

java代码机器人 java人工智能代码

乞求大神荣光!!机器人的JAVA代码。

public class Bot {

创新互联主营蒲县网站建设的网络公司,主营网站建设方案,重庆APP开发公司,蒲县h5成都小程序开发搭建,蒲县网站营销推广欢迎蒲县等地区企业咨询

private ArrayListString commands;

public Bot(){

commands = new ArrayList();

}

public ArrayListString getCommands(){

return commands;

}

public static void main(String[ ] args){

Bot bot = new Bot();

Scanner sc = new Scanner(System.in);

System.out.println("请输入一个整数:");

int n = sc.nextInt();

int i = 0;

String command;

sc.nextLine();

while (i n){

command = sc.nextLine();

if (!isCorrectCommand(command)){

System.out.println("每条指令只由L、R和数字组成(数字是0~100之间的整数)。");

}else if (command.length() 256){

System.out.println("每条指令的长度不超过256个字符。");

} else{

bot.getCommands().add(command);

i++;

}

}

i = 0;

while (i n){

System.out.printf("%.2f",bot.go(i));

i++;

}

}

public double go(int index){

int direction = 2;

double x = 0;

double y = 0;

String command = commands.get(index);

String str="0";

int i = 0;

char temp;

while (i command.length()){

temp = command.charAt(i);

if (temp = 47 temp = 57){

str += temp;

}else if (temp == 'L'){

int length = Integer.parseInt(str);

switch(direction){

case 1: x = x - length;break;

case 2: y = y + length;break;

case 3: x = x + length;break;

case 4: y = y - length;break;

}

str = "0";

direction = (direction - 1)%4;

if (direction == 0){

direction = 4;

}

}else{

int length = Integer.parseInt(str);

switch(direction){

case 1: x = x - length;break;

case 2: y = y + length;break;

case 3: x = x + length;break;

case 4: y = y - length;break;

}

str = "0";

direction = (direction + 1)%4;

}

i++;

}

int length = Integer.parseInt(str);

switch(direction){

case 1: x = x - length;break;

case 2: y = y + length;break;

case 3: x = x + length;break;

case 4: y = y - length;break;

}

return Math.sqrt(x * x + y * y);

}

public static boolean isCorrectCommand(String command){

Pattern pt = Pattern.compile("(?:L\\d{1,3}|R\\d{1,3}|\\d{1,3})+");

if (pt.matcher(command).matches()){

return true;

}

return false;

}

}

用java程序实现

机器人类(源类):

public class Robot {

public void cry(){

System.out.println("机器人叫");

}

public void run(){

System.out.println("机器人跑");

}

}

狗类(目标类):

public class Dog {

public void cry(){

System.out.println("像狗一样叫");

}

public void run(){

System.out.println("像狗一样跑");

}

}

适配器类(继承源类并重写它的方法,目标类作为属性):

public class Adaper extends Robot{

private Dog dog;

public Adaper(Dog dog) {

this.dog=dog;

}

@Override

public void cry() {

dog.cry();

}

@Override

public void run() {

dog.run();

}

}

测试类

public class Test {

public static void main(String[] args) {

Dog dog=new Dog();

Robot robot=new Adaper(dog);

robot.cry();

robot.run();

}

}

oicq机器人转java

OICQ机器人转Java:

1. 下载OICQ SDK并安装:从OICQ官网上下载SDK并安装到你的电脑上。

2. 创建一个新的Java工程:使用Eclipse或者其他IDE来创建一个新的Java工程。

3. 导入OICQ SDK库文件:将SDK中的库文件添加到你的工程中。

4. 生成OICQ机器人代码:根据你想要实现的功能生成相应的代码。

5. 生成可执行文件并测试机器人代码:将生成的代码生成可执行文件并测试机器人代码是否正常工作。

JAVA设计一个人工智能的机器人

java机器人游戏最经典的是Robocode项目,里面有详细的文档以及源码,可以自己学习修改。(不要说自己参加这个项目,自己不认真学些东西,那可以面壁了)。下面是它的项目主页

java脚本机器人模块错误

脚本程序就有问题。java脚本机器人模块错误的原因是脚本程序就有问题,Java是一门面向对象的编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承、指针等概念,因此Java语言具有功能强大和简单易用两个特征。


新闻标题:java代码机器人 java人工智能代码
网站地址:http://cdkjz.cn/article/dodssce.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220