⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wormsimple.cpp

📁 人工智能最简单问题的示例代码
💻 CPP
字号:
#include<time.h>
#include<stdio.h>
#include<stdlib.h>

#include<iostream>
using namespace std;

int strcmp1(char *a,char *b) {
	int res=0;

	while (*a==*b) {
		if (a=='\0') break;
		res++;a++;b++;
	}

	return res;
}

int main() {
	char str[100];

	srand((unsigned)time(NULL)); 
    while (true) {
        gets(str);
		if (strcmp1(str,"check_status")>=12) {
			cerr<<"ready"<<flush;
			continue;
		}
		else if (strcmp1(str,"beetlemove")>=10) {
			switch (rand()%4) {
				case 0:
					cerr<<"action up"<<flush;
					break;
				case 1:
					cerr<<"action down"<<flush;
					break;
				case 2:
					cerr<<"action left"<<flush;
					break;
				case 3:
					cerr<<"action right"<<flush;
			}
			continue;
		}
		else if (strcmp1(str,"snailmove")>=9) {
			switch (rand()%4) {
				case 0:
					cerr<<"action up"<<flush;
					break;
				case 1:
					cerr<<"action down"<<flush;
					break;
				case 2:
					cerr<<"action left"<<flush;
					break;
				case 3:
					cerr<<"action right"<<flush;
			}
			continue;
		}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -