看了一眼自己的代码,我…哭了…
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <cctype>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#include <windows.h>
#include <conio.h>
#include <time.h>
using namespace std;
int n, m;
struct player {
int x, y;
int weight, size;
}a[10];
struct food {
int x, y;
int weight;
}b[100];
player grow(player x) {
x.size = sqrt(sqrt(x.weight)) - 1;
return x;
}
food reset(food x) {
// while(1);
srand((unsigned)time(0));
x.x = rand() % 30;
x.y = rand() % 30;
x.weight = rand() % 2 + 1;
return x;
}
bool eat(player x, player y) {
return x.size >= y.size && (x.size - y.size >= abs(x.x - y.x) + abs(x.y - y.y));
}
bool eatt(player x, food y) {
return x.size >= abs(x.x - y.x) + abs(x.y - y.y);
}
player AI(player x) {
if (! x.weight) return x;
int idx;
int minx = 25;
for (int i = 0; i < 30; i ++) {
if (abs(b[i].x - x.x) + abs(b[i].y - x.y) < minx) {
minx = abs(b[i].x - x.x) + abs(b[i].y - x.y);
idx = i;
}
}
if (eatt(x, b[idx])) {
x.weight += b[idx].weight;
x = grow(x)