-
Notifications
You must be signed in to change notification settings - Fork 0
/
snakeai.h
39 lines (38 loc) · 954 Bytes
/
snakeai.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef SNAKEAI_H
#define SNAKEAI_H
#include <QQueue>
#include "snake1.h"
#include <qmath.h>
#include <QStack>
#include "mysnaketest.h"
#include <QWidget>
class snakeai:public mysnaketest
{
public:
void keyPressEvent(QKeyEvent *key);
void paintEvent(QPaintEvent *event);
void eat();
void eat1();
void hit();
bool foodcontain();
bool overornot();
void rebegin();
protected:
bool canfindfood(Snake &snake1);
bool canfindtail(int x,int y,Snake &snake1);
void simpleai();
void initbfs();
void initvis();
void calcbfs(Snake &snake);
void calctailbfs(Snake &snake);
void calcempty(Snake &snake);
int calcdis(QPoint poin1,QPoint point2);
void calcdirection(Snake &snake1,int x,int y);
bool autoornot=true;
bool visited[43][83];
QPoint parent[43][83];
QStack<QPoint> s;
Snake1 snake2;
QString scoreLabel1;
};
#endif // SNAKEAI_H