📄 head.h
字号:
/*========================head.h===================================*/
/*--------头文件,宏定义,函数申明------------*/
#include"stdio.h"
#include"stdlib.h"
#include"math.h"
#include"conio.h"
#include"time.h"
#include"graphics.h"
#define upkey 72 /*------上方向键-------*/
#define downkey 80 /*------下方向键-------*/
#define leftkey 75 /*------左方向键-------*/
#define rightkey 77 /*------右方向键-------*/
#define Enter 13 /*------回车键---------*/
#define ESC 27 /*------ESC键----------*/
#define WinColor LIGHTBLUE /*------进入界面背景色-*/
#define TitleColor BLACK /*------标题颜色-------*/
#define TextColor LIGHTGRAY /*------文本颜色-------*/
#define ChoiceColor WHITE /*------选项颜色-------*/
#define DisplayColor BLACK /*------演示界面背景色-*/
#define StarColor WHITE /*------星空颜色-------*/
#define TankColor WHITE /*------坦克颜色-------*/
#define GunColor RED /*------炮头颜色-------*/
#define LockColor RED /*------锁定颜色-------*/
#define WinLeft 22 /*------进入界面窗口左坐标-------*/
#define WinTop 3 /*------进入界面窗口顶坐标-------*/
#define WinRight 50 /*------进入界面窗口右坐标-------*/
#define WinBottom 12 /*------进入界面窗口底坐标-------*/
#define EnterX 10 /*------选项Enter坐标----*/
#define EnterY 5
#define ExitX 10 /*------选项EXIT坐标-----*/
#define ExitY 7
#define mMax 10 /*------最大目标数-----*/
#define nMax 10 /*------最多指标数-----*/
int n=6,m=3; /*目标数初始定为六个,目标指标定为3个*/
int best=0; /*最优目标在目标数组中的下标值*/
float f[mMax][nMax],H[nMax],Omiga[nMax]; /*----Omiga[i]为熵权-------*/
float r[mMax][nMax]; /*-----判断矩阵------------*/
float A[mMax][nMax]; /*--加熵权的标准化指标矩阵-*/
float X[nMax]; /*-------理想点------------*/
/*------演示矩形框结构----*/
struct RECT{
int left,top,right,bottom;
int width,height,d;
}rect;
/*------炮台结构---------*/
struct Emplacement{
int x,y;
int width,lenth;
int color;
}emp;
/*---------------------坦克目标属性---------------------------*/
struct Target{
int ID; /*---坦克标识符,用以识别该目标的唯一编号----*/
int x,y; /*---坦克坐标----*/
int r,color; /*---坦克半径和颜色--*/
float d; /*---距离----*/
int dIndex; /*---距离索引----*/
float T; /*---贴近度----*/
int TIndex; /*---贴近度索引----*/
int pIndex; /*---坦克排序索引---*/
int direction; /*---坦克当前运动方向---*/
float inva,distance,power;
/*----分别为坦克的三个指标:"侵略性"、"距炮台距离"、"攻击力"---*/
}Tank[nMax]; /*---定义坦克目标数组---*/
int color[3]={WHITE,YELLOW,RED}; /*---定义坦克的三种颜色值---*/
/*-----------------算法相关函数-------------------------*/
float Sigama(float a[],int L); /*求和*/
float findMax(float a[],int L); /*寻找最大值*/
float findMin(float a[],int L); /*寻找最小值*/
void Taxis(struct Target Tank[],int pNum);/*排序*/
void GetTData(); /*获得当前各个目标的状态,并形成指标数据*/
/*------------------算法步骤函数---------------------------*/
void FormMatrix(); /*构造初始指标判断矩阵*/
void FormEntropyMatrix(); /*构造加熵权的标准化指标矩阵A*/
void FindPerfectPoint(); /*找出理想点X[m]*/
void CalDistance(); /*计算被评方案到理想点的距离Tank[j].d*/
void CalCloseDegree(); /*计算被评方案与理想点的贴近度Tank[j].T*/
void FindBestT(); /*根据贴近度和距离排序,找出最优目标*/
void Arithmetic(); /*依次调用算法六个步骤*/
/*------------------动画演示函数-------------------------------*/
void InitBKGround(); /*初始进入界面*/
void Selected(int c,int x,int y); /*选项动态效果*/
void InitGraph(); /*图形初始化*/
void DrawEagle(); /*画大本营标志*/
void Emplacement(); /*画炮台*/
void ShowInt(int data,int x,int y); /*将整型转化为字符型并显示/
void DrawTank(struct Target T_pro,int Tcolor,int color); /*画坦克*/
void DisplayBG(); /*演示背景*/
void InitTarget(); /*初始化目标并显示*/
void DrawStarBG(); /*画初始星空背景*/
void DrawShineStar(int x,int y,int i,int color); /*在坐标(x,y)处画闪烁的星的图案*/
void Shine(); /*星空闪烁效果*/
int IsXYValid(struct Target T,int x,int y);
/*决定当前坦克是否按当前方向值运动,或是碰到边框而须改变方向*/
int Lock(struct Target T); /*锁定目标的效果*/
void DrawMissile(int x,int y,int r,int color); /*画导弹*/
void Attack(int x1,int y1,int x2,int y2,int color); /*攻击效果*/
void Blast(int x,int y,int r,int color); /*爆炸效果*/
void ShowClear(); /*显示目标全部清除的画面*/
int Display(); /*动画演示:找出当前最优目标并击毁*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -