欢迎来到天天文库
浏览记录
ID:26568440
大小:56.50 KB
页数:15页
时间:2018-11-27
《蚁群算法c程序代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#defineSPACE0x20#defineESC0x1b#defineANT_CHAR_EMPTY'+'#defineANT_CHAR_FOOD153#defineHOME_CHAR'H'#defineFOOD_CHAR'F'#defineFOOD_CHAR2'f'#defineFOOD_HOME_COLOR12#defineBLOCK_CHAR177#defineMAX_ANT50#defineINI_SPEED3#defineMAXX80#defineMAXY23#defineMAX_FOOD10000#defineTARGET
2、_FOOD200#defineMAX_SMELL5000#defineSMELL_DROP_RATE0.05#defineANT_ERROR_RATE0.02#defineANT_EYESHOT3#defineSMELL_GONE_SPEED50#defineSMELL_GONE_RATE0.05#defineTRACE_REMEMBER50#defineMAX_BLOCK100#defineNULL0#defineUP1#defineDOWN2#defineLEFT3#defineRIGHT4#defineSMELL_TYPE_FOO
3、D0#defineSMELL_TYPE_HOME1#include"stdio.h"#include"conio.h"#include"dos.h"#include"stdlib.h"#include"dos.h"#include"process.h"#include"ctype.h"#include"math.h"voidWorldInitial(void);voidBlockInitial(void);voidCreatBlock(void);voidSaveBlock(void);voidLoadBlock(void);voidH
4、omeFoodInitial(void);voidAntInitial(void);voidWorldChange(void);voidAntMove(void);voidAntOneStep(void);voidDealKey(charkey);voidClearSmellDisp(void);voidDispSmell(inttype);intAntNextDir(intxxx,intyyy,intddir);intGetMaxSmell(inttype,intxxx,intyyy,intddir);intIsTrace(intxx
5、x,intyyy);intMaxLocation(intnum1,intnum2,intnum3);intCanGo(intxxx,intyyy,intddir);intJudgeCanGo(intxxx,intyyy);intTurnLeft(intddir);intTurnRight(intddir);intTurnBack(intddir);intMainTimer(void);charWaitForKey(intsecnum);voidDispPlayTime(void);intTimeUse(void);voidHideCur
6、(void);voidResetCur(void);/*--------------- */structHomeStruct{ intxxx,yyy; intamount; intTargetFood;}home;structFoodStruct{ intxxx,yyy; intamount;}food;structAntStruct{ intxxx,yyy; intdir; intspeed; intSpeedTimer; intfood; intSmellAmount[2]; intt
7、racex[TRACE_REMEMBER]; inttracey[TRACE_REMEMBER]; intTracePtr; intIQ;}ant[MAX_ANT];intAntNow;inttimer10ms;structtimestarttime,endtime;intSmell[2][MAXX+1][MAXY+1];intblock[MAXX+1][MAXY+1];intSmellGoneTimer;intSmellDispFlag;intCanFindFood;intHardtoFindPath;/*-----Mai
8、n--------*/voidmain(void){ charKeyPress; inttu; clrscr(); HideCur(); WorldInitial(); do
此文档下载收益归作者所有