diff --git a/level1/p09_maze/main.c b/level1/p09_maze/main.c new file mode 100644 index 00000000..3df24a61 --- /dev/null +++ b/level1/p09_maze/main.c @@ -0,0 +1,46 @@ +#include"maze.c" +#include"userinput.c" +int test(pmaze m) +{ + position enter; + enter._x = 1; + enter._y = 0; + randommaze(m); + //printmaze(m); + antoFootpath(m, enter); + //printmaze(m); + return m->_map[Maplong-2][Mapwidth-1]; +} + +int main() +{ + maze m; + int frist=1; + //test(&m); + printf("地图正在生成,请等待"); + while(test(&m)!=2); + system("cls"); + printf("地图已生成\n"); + printf("w向上移动 s向下移动 a向左移动 d向右移动 p输出正确路径\n"); + printmaze(&m); + while(1) + { + if(kbhit()) + { + ch=getch(); + system("cls"); + printf("w向上移动 s向下移动 a向左移动 d向右移动 p输出正确路径\n"); + if(exitmaze(&m)) + { + system("cls"); + printf("you go out the maze"); + exit(1); + } + userinput(&m, ch); + printmaze(&m); + } + } +// printf("please choose the pattern"); + // scanf("%d",&n); + return 0; +} diff --git a/level1/p09_maze/main.o b/level1/p09_maze/main.o new file mode 100644 index 00000000..e6e46ac7 Binary files /dev/null and b/level1/p09_maze/main.o differ diff --git a/level1/p09_maze/maze.c b/level1/p09_maze/maze.c new file mode 100644 index 00000000..87099d3f --- /dev/null +++ b/level1/p09_maze/maze.c @@ -0,0 +1,239 @@ +#include"maze.h" +void initmaze(pmaze m, int Map[Maplong][Mapwidth]) +{ + assert(m!=NULL); + int i,j; + for(i=0; i_map[i][j]=Map[i][j]; + } + } +} +void randommaze(pmaze m) +{ + int i,j,k; + srand(time(NULL)); + m->_map[1][0]=m->_map[Maplong-2][Mapwidth-1]=1; + for(i=0; i_map[0][i]=m->_map[Maplong-1][i]=0; + } + for(j=2;j_map[j][0]=m->_map[j-2][Mapwidth-1]=0; + } + for(i=1; i_map[i][j]=1; + else + { + if((i==1&&j==1)||(i==Maplong-2&&Mapwidth-2==j)) + { + m->_map[i][j]=1; + } + else + { + m->_map[i][j]=0; + } + } + } + } +} +int exitmaze(pmaze m) +{ + if(position_x==Maplong-2&&position_y==Mapwidth-1) + { + return 1; + } + return 0; +} +void antoprintmaze(pmaze m) +{ + int i,j; + for(i=0; i_map[i][j]) + { + case(0): + printf("0"); + break; + case(1): + printf(" "); + break; + case(2): + printf("*"); + break; + case(3): + printf(" "); + break; + default: + break; + } + } + printf("\n"); + } + printf("\n"); +} +void initstack(pstack m) +{ + assert(m!=NULL); + m->top=0; +} +void popstack(pstack m) +{ + assert(m!=NULL); + if(m->top) + m->top--; +} +void pushstack(pstack m,mazenode n) +{ + assert(m!=NULL); + if(m->top==Maxstep) + return; + else + { + m->num[m->top]=n; + m->top++; + } +} +int emptystack(pstack s) +{ + assert(s!=NULL); + if(0==s->top) + return 1; + return 0; +} +mazenode Stacktop(pstack s) +{ + assert((s!=NULL)); + if(0==s->top) + { + printf("error"); + exit(1); + } + return s->num[s->top-1]; +} +int entermaze(pmaze m,position e) +{ + assert(m!=NULL); + if((e._x==0||e._x==Maplong-1||e._y==0||e._y==Mapwidth-1)&&(e._x>=0)&&(e._x=0)&&(e._y_map[e._x][e._y]) + { + return 1; + } + return 0; +} +void printmaze(pmaze m) +{ + int i,j; + for(i=0; i_map[i][j]; + px=i; + py=j; + one=0; + } + m->_map[i][j]=4; + } + switch(m->_map[i][j]) + { + case(0): + printf("0"); + break; + case(1): + printf(" "); + break; + case(2): + printf(" "); + break; + case(3): + printf(" "); + break; + case(4): + printf("@"); + break; + default: + break; + } + } + printf("\n"); + } + printf("\n"); + +} +//void footpath(pmaze m,positon e) +void antoFootpath(pmaze m,position e) +{ + assert(m!=NULL); + Stack s; + initstack(&s); + pushstack(&s,e); + while(!emptystack(&s)) + { + position now; + position next; + now=Stacktop(&s); + m->_map[now._x][now._y]=2; + if(now._x==Maplong-2&&now._y==Mapwidth-1) + { + return; + } + else + { + next=now; + next._x+=1; + if(Passmaze(m,next)) + { + pushstack(&s,next); + continue; + } + next=now; + next._y+=1; + if(Passmaze(m,next)) + { + pushstack(&s,next); + continue; + } + next=now; + next._y-=1; + if(Passmaze(m,next)) + { + pushstack(&s,next); + continue; + } + next=now; + next._x-=1; + if(Passmaze(m,next)) + { + pushstack(&s,next); + continue; + } + m->_map[now._x][now._y]=3; + popstack(&s); + } + } + + +} diff --git a/level1/p09_maze/maze.h b/level1/p09_maze/maze.h new file mode 100644 index 00000000..4df9d715 --- /dev/null +++ b/level1/p09_maze/maze.h @@ -0,0 +1,52 @@ +#ifndef MAZE_H_INCLUDED +#define MAZE_H_INCLUDED +#include +#include +#include +#include +#include +#include +#define Maplong 20 +#define Mapwidth 20 +#define Maxstep 500 +int position_x=1; +int position_y=0; +int one=1; +int temp; +int px; +int py; +char ch; +typedef struct position +{ + int _x; + int _y; +}position; +typedef position mazenode ; +typedef struct Stack +{ + int top; + mazenode num[Maxstep]; +}Stack,*pstack; +typedef struct maze +{ + int _map[Maplong][Mapwidth]; +}maze,*pmaze; +void antoprintmaze(pmaze m); +void initmaze(pmaze m,int Map[Maplong][Mapwidth]); +void initstack(pstack m); +void popstack(pstack m); +void pushstack(pstack m,mazenode n ); +//void Random(); +int Passmaze(pmaze m,position e); +void Footpath(pmaze m,position e); +int emptystack(pstack s); +mazenode Stacktop(pstack s); +int entermaze(pmaze m,position e); +int outmaze(position m,position e); +void printmaze(pmaze m); +void randommaze(); +void antoFootpath(pmaze m,position e); +int exitmaze(pmaze m); +void wall(pmaze m); + +#endif // MAZE_H_INCLUDED diff --git a/level1/p09_maze/test.c b/level1/p09_maze/test.c new file mode 100644 index 00000000..6525a52c --- /dev/null +++ b/level1/p09_maze/test.c @@ -0,0 +1,19 @@ +#include"maze.c" +void test() +{ + maze m; + position enter; + enter._x = 1; + enter._y = 0; + randommaze(&m); + printmaze(&m); + Footpath(&m, enter); + printmaze(&m); +} + +int main() +{ + test(); + + return 0; +} diff --git a/level1/p09_maze/userinput.c b/level1/p09_maze/userinput.c new file mode 100644 index 00000000..c2a5c713 --- /dev/null +++ b/level1/p09_maze/userinput.c @@ -0,0 +1,45 @@ +#include"userinput.h" +void userinput(pmaze m,char ch) +{ + + if(ch=='w') + { + position_x--; + if(m->_map[position_x][position_y]==0) + { + position_x++; + } + } + if(ch=='s') + { + position_x++; + if(m->_map[position_x][position_y]==0) + { + position_x--; + } + } + if(ch=='a') + { + position_y--; + if(m->_map[position_x][position_y]==0) + { + position_y++; + } + } + if(ch=='d') + { + position_y++; + if(m->_map[position_x][position_y]==0) + { + position_y--; + } + } + if(ch=='p') + { + antoprintmaze(m); + exit(1); + } + one=1; + m->_map[px][py]=temp; + +} diff --git a/level1/p09_maze/userinput.h b/level1/p09_maze/userinput.h new file mode 100644 index 00000000..7cb5a160 --- /dev/null +++ b/level1/p09_maze/userinput.h @@ -0,0 +1,7 @@ +#ifndef USERINPUT_H_INCLUDED +#define USERINPUT_H_INCLUDED +#include"maze.h" +void userinput(pmaze m,char ch); + + +#endif // USERINPUT_H_INCLUDED diff --git a/level1/p10_pushBoxes/README.md b/level1/p10_pushBoxes/README.md deleted file mode 100755 index 5895c0d2..00000000 --- a/level1/p10_pushBoxes/README.md +++ /dev/null @@ -1,9 +0,0 @@ -### 棰樼洰锛氭帹绠卞瓙灏忔父鎴忥紙鍩轰簬console锛 - -### 鍔熻兘瑕佹眰锛 - -1. 灏唒09杩峰娓告垙鏀归犱负鈥滄帹绠卞瓙鈥濇父鎴忥紱 -1. 鍦ㄥ湴鍥句腑澧炲姞绠卞瓙銆佺瀛愮洰鏍囦綅缃瓑鍥惧舰锛 -1. 褰撶帺瀹跺皢鎵鏈夌瀛愬綊浣嶏紝鍒欐樉绀虹帺瀹惰耽寰椾簡娓告垙锛 -1. 鎸夌帺瀹惰蛋鍔ㄦ鏁拌鍒嗭紱 -1. 璁捐澶氫釜鍏冲崱锛屾瘡涓鍏崇殑鍦板浘浠庢枃浠朵腑璇诲彇锛岀帺瀹舵瘡鍏崇殑鍒嗘暟璁板綍鍒版枃浠朵腑锛 \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox.sln b/level1/p10_pushBoxes/pushbox.sln new file mode 100644 index 00000000..d521b441 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox.sln @@ -0,0 +1,31 @@ +锘 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.539 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pushbox", "pushbox\pushbox.vcxproj", "{DF5647C8-EC58-413F-A9F0-35EB57D4E8F8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF5647C8-EC58-413F-A9F0-35EB57D4E8F8}.Debug|x64.ActiveCfg = Debug|x64 + {DF5647C8-EC58-413F-A9F0-35EB57D4E8F8}.Debug|x64.Build.0 = Debug|x64 + {DF5647C8-EC58-413F-A9F0-35EB57D4E8F8}.Debug|x86.ActiveCfg = Debug|Win32 + {DF5647C8-EC58-413F-A9F0-35EB57D4E8F8}.Debug|x86.Build.0 = Debug|Win32 + {DF5647C8-EC58-413F-A9F0-35EB57D4E8F8}.Release|x64.ActiveCfg = Release|x64 + {DF5647C8-EC58-413F-A9F0-35EB57D4E8F8}.Release|x64.Build.0 = Release|x64 + {DF5647C8-EC58-413F-A9F0-35EB57D4E8F8}.Release|x86.ActiveCfg = Release|Win32 + {DF5647C8-EC58-413F-A9F0-35EB57D4E8F8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5F51AABB-00EA-42FF-B6F6-E1807D268969} + EndGlobalSection +EndGlobal diff --git a/level1/p10_pushBoxes/pushbox/Debug/basic.obj b/level1/p10_pushBoxes/pushbox/Debug/basic.obj new file mode 100644 index 00000000..53cc11e9 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/basic.obj differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/exam.obj b/level1/p10_pushBoxes/pushbox/Debug/exam.obj new file mode 100644 index 00000000..25ed3b62 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/exam.obj differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/main.obj b/level1/p10_pushBoxes/pushbox/Debug/main.obj new file mode 100644 index 00000000..6a762dc1 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/main.obj differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/main.obj.enc b/level1/p10_pushBoxes/pushbox/Debug/main.obj.enc new file mode 100644 index 00000000..b0599cb2 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/main.obj.enc differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/move.obj b/level1/p10_pushBoxes/pushbox/Debug/move.obj new file mode 100644 index 00000000..3d212774 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/move.obj differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/pushbox.Build.CppClean.log b/level1/p10_pushBoxes/pushbox/Debug/pushbox.Build.CppClean.log new file mode 100644 index 00000000..1ad5a56c --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/Debug/pushbox.Build.CppClean.log @@ -0,0 +1,17 @@ +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\vc141.pdb +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\vc141.idb +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\userinput.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\move.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\main.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\basic.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\show.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\exam.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\debug\pushbox.exe +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\debug\pushbox.ilk +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\debug\pushbox.pdb +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\pushbox.tlog\cl.command.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\pushbox.tlog\cl.read.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\pushbox.tlog\cl.write.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\pushbox.tlog\link.command.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\pushbox.tlog\link.read.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\pushbox\pushbox\pushbox\debug\pushbox.tlog\link.write.1.tlog diff --git a/level1/p10_pushBoxes/pushbox/Debug/pushbox.log b/level1/p10_pushBoxes/pushbox/Debug/pushbox.log new file mode 100644 index 00000000..197e7d58 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/Debug/pushbox.log @@ -0,0 +1,2 @@ +锘 userinput.c + pushbox.vcxproj -> C:\Users\灏樺焹\Desktop\绋嬪簭璁捐\pushbox\pushbox\Debug\pushbox.exe diff --git a/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/CL.command.1.tlog b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/CL.command.1.tlog new file mode 100644 index 00000000..2636cccf Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/CL.command.1.tlog differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/CL.read.1.tlog b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/CL.read.1.tlog new file mode 100644 index 00000000..11f7e79b Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/CL.read.1.tlog differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/CL.write.1.tlog b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/CL.write.1.tlog new file mode 100644 index 00000000..9380a8ba Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/CL.write.1.tlog differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/link.command.1.tlog b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/link.command.1.tlog new file mode 100644 index 00000000..bd38aa24 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/link.command.1.tlog differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/link.read.1.tlog b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/link.read.1.tlog new file mode 100644 index 00000000..98a91c81 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/link.read.1.tlog differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/link.write.1.tlog b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/link.write.1.tlog new file mode 100644 index 00000000..50134964 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/link.write.1.tlog differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/pushbox.lastbuildstate b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/pushbox.lastbuildstate new file mode 100644 index 00000000..1bd791c2 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/Debug/pushbox.tlog/pushbox.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 +Debug|Win32|C:\Users\灏樺焹\Desktop\绋嬪簭璁捐\pushbox\pushbox\| diff --git a/level1/p10_pushBoxes/pushbox/Debug/second.obj b/level1/p10_pushBoxes/pushbox/Debug/second.obj new file mode 100644 index 00000000..bc800eaa Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/second.obj differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/show.obj b/level1/p10_pushBoxes/pushbox/Debug/show.obj new file mode 100644 index 00000000..6c178bf7 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/show.obj differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/userinput.obj b/level1/p10_pushBoxes/pushbox/Debug/userinput.obj new file mode 100644 index 00000000..c64bf574 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/userinput.obj differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/vc141.idb b/level1/p10_pushBoxes/pushbox/Debug/vc141.idb new file mode 100644 index 00000000..d22367f4 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/vc141.idb differ diff --git a/level1/p10_pushBoxes/pushbox/Debug/vc141.pdb b/level1/p10_pushBoxes/pushbox/Debug/vc141.pdb new file mode 100644 index 00000000..f08c68a3 Binary files /dev/null and b/level1/p10_pushBoxes/pushbox/Debug/vc141.pdb differ diff --git a/level1/p10_pushBoxes/pushbox/basic.c b/level1/p10_pushBoxes/pushbox/basic.c new file mode 100644 index 00000000..89626be6 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/basic.c @@ -0,0 +1,11 @@ +#include"basic.h" +int position_x = 1; +int position_y=0; +int py=0; +int px=0; +int box_x ; +int box_y ; +int number=1; +int direction = 0; +char ch; +int scorenumber=0; \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/basic.h b/level1/p10_pushBoxes/pushbox/basic.h new file mode 100644 index 00000000..7bbdb7ad --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/basic.h @@ -0,0 +1,37 @@ +#ifndef BASIC_H_INCLUDED +#define BASIC_H_INCLUDED +#define MAXPATH 1000 +#define Maplong 6 +#define Mapwidth 6 +#define out_x 2 +#define out_y 5 + +#include +#include +#include +#include +#include +int map[Maplong][Mapwidth]; +int rmap[Maplong][Mapwidth]; +extern int position_x; +extern int box_x ; +extern int box_y ; +extern int position_y; +extern int direction; +extern int scorenumber; +extern int number; +extern int py;//还原移动后的值 +extern int px;// +extern char ch; +typedef struct node +{ + int x; + int y; +}node; +typedef struct path +{ + node num[MAXPATH]; + int top; +}*ppath; +#endif // !BASIC_H_INCLUDED + diff --git a/level1/p10_pushBoxes/pushbox/exam.c b/level1/p10_pushBoxes/pushbox/exam.c new file mode 100644 index 00000000..e5efc6f7 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/exam.c @@ -0,0 +1,11 @@ +#include "exam.h" +int exam() +{ + if (box_x == out_x && box_y == out_y) + { + printf("you win \n"); + number++; + return 1; + } + return 0; +} \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/exam.h b/level1/p10_pushBoxes/pushbox/exam.h new file mode 100644 index 00000000..36bc1ddd --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/exam.h @@ -0,0 +1,6 @@ +#pragma once +#ifndef EXAM_H_INCLUDED +#define EXAM_H_INCLUDED +#include"basic.h" +int exam(); +#endif // !1 \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/main.c b/level1/p10_pushBoxes/pushbox/main.c new file mode 100644 index 00000000..28961215 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/main.c @@ -0,0 +1,46 @@ +#include"show.h" +#include"useinput.h" +#include"move.h" +#include"exam.h" +#include"second.h" +int main() +{ + int i,j; + if(freopen("text.txt", "r", stdin)==NULL) + printf("error"); + for (i = 0; i < Maplong; i++) + { + for (j = 0; j < Mapwidth; j++) + { + scanf("%d", &map[i][j]); + rmap[i][j] = map[i][j]; + if (map[i][j] == 2) + { + box_x = i; + box_y = j; + } + } + } + freopen("CON", "r", stdin); + printf("第一关地图已生成\n"); + printf("输入r从新开始\n"); + print(); + while (1) + { + if (_kbhit()) + { + ch = _getch(); + Sleep(50); + system("cls"); + printf("w向上移动 s向下移动 a向左移动 d向右移动 r重来\n"); + userinput(ch); + boxmove(); + print(); + printf("your score are %d \n", scorenumber); + if (exam()) + { + second(); + } + } + } +} diff --git a/level1/p10_pushBoxes/pushbox/move.c b/level1/p10_pushBoxes/pushbox/move.c new file mode 100644 index 00000000..26201f70 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/move.c @@ -0,0 +1,37 @@ +#include "move.h" + +void boxmove() +{ + int temp1; + if (map[box_x][box_y] == 2)//1空地 2box 4人物 + { + if (map[box_x + 1][box_y] == 1 &&px==box_x - 1&&py==box_y && direction == 1) + { + temp1 = box_x; + box_x++; + map[box_x][box_y] = 2; + map[temp1][box_y] = 1; + } + if (map[box_x - 1][box_y] == 1 && px==box_x + 1&&py == box_y && direction == 2) + { + temp1 = box_x; + box_x--; + map[box_x][box_y] = 2; + map[temp1][box_y] = 1; + } + if (map[box_x][box_y + 1] == 1 && py==box_y -1 && px == box_x && direction == 3) + { + temp1 = box_y; + box_y++; + map[box_x][box_y] = 2; + map[box_x][temp1] = 1; + } + if (map[box_x][box_y - 1] == 1 &&py==box_y + 1 && px == box_x && direction == 4) + { + temp1 = box_y; + box_y--; + map[box_x][box_y] = 2; + map[box_x][temp1] = 1; + } + } +} diff --git a/level1/p10_pushBoxes/pushbox/move.h b/level1/p10_pushBoxes/pushbox/move.h new file mode 100644 index 00000000..781a0ad5 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/move.h @@ -0,0 +1,8 @@ +#ifndef MOVE_H_INCLUDED +#define MOVE_H_INCLUDED +#include"basic.h" +void boxmove(); +#endif // !MOVE_H_INCLUDED + + + diff --git a/level1/p10_pushBoxes/pushbox/pushbox.vcxproj b/level1/p10_pushBoxes/pushbox/pushbox.vcxproj new file mode 100644 index 00000000..5cf22062 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/pushbox.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + 15.0 + {DF5647C8-EC58-413F-A9F0-35EB57D4E8F8} + Win32Proj + pushbox + 10.0.17763.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/pushbox.vcxproj.filters b/level1/p10_pushBoxes/pushbox/pushbox.vcxproj.filters new file mode 100644 index 00000000..db033121 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/pushbox.vcxproj.filters @@ -0,0 +1,60 @@ +锘 + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/pushbox.vcxproj.user b/level1/p10_pushBoxes/pushbox/pushbox.vcxproj.user new file mode 100644 index 00000000..be250787 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/pushbox.vcxproj.user @@ -0,0 +1,4 @@ +锘 + + + \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/second.c b/level1/p10_pushBoxes/pushbox/second.c new file mode 100644 index 00000000..5fb7bee5 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/second.c @@ -0,0 +1,39 @@ +#include "second.h" +void second() +{ + if (number > 2) + { + printf("you finish all congratulating!!!!!"); + exit(1); + } + int i, j; + char ch1[2]; + printf("是否继续? (y/n )\n"); + scanf("%s", ch1); + if(strcmp(ch1, "y") == 0) + { + printf("第二关地图已生成\n"); + if (freopen("text1.txt", "r", stdin) == NULL) + printf("error"); + for (i = 0; i < Maplong; i++) + { + for (j = 0; j < Mapwidth; j++) + { + scanf("%d", &map[i][j]); + rmap[i][j] = map[i][j]; + if (map[i][j] == 2) + { + box_x = i; + box_y = j; + } + } + } + position_x = 1; + position_y = 0; + freopen("CON", "r", stdin); + } + if (strcmp(ch1, "n") == 0) + { + exit(1); + } +} \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/second.h b/level1/p10_pushBoxes/pushbox/second.h new file mode 100644 index 00000000..e7ef070c --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/second.h @@ -0,0 +1,7 @@ +#ifndef SECOND_H_INCLUDED +#define SECOND_H_INCLUDED + +#include"basic.h" + +void second(); +#endif // !SECONG_H_INCLUDED diff --git a/level1/p10_pushBoxes/pushbox/show.c b/level1/p10_pushBoxes/pushbox/show.c new file mode 100644 index 00000000..c4f15ded --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/show.c @@ -0,0 +1,40 @@ +#include"show.h" +void print() +{ + int i, j; + int temp; + for (i = 0; i < Maplong; i++) + { + for (j = 0; j < Mapwidth; j++) + { + if (i == position_x && j == position_y) + { + temp = map[i][j]; + px = i; + py = j; + map[i][j] = 4; + } + switch (map[i][j]) + { + case(0): + printf("□");//■□○╳墙 + break; + case(1): + printf(" ");//空地 + break; + case(2): + printf("■");//BOX + break; + case(4): + printf("○");//人物 + break; + default: + break; + } + } + printf("\n"); + } + map[px][py] = temp; + printf("\n"); + +} \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/show.h b/level1/p10_pushBoxes/pushbox/show.h new file mode 100644 index 00000000..0066cb3c --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/show.h @@ -0,0 +1,6 @@ +#ifndef SHOW_H_INCLUDED +#define SHOW_H_INCLUDED +#include"basic.h" +void print(); +#endif // !SHOW_H_INCLUDED + diff --git a/level1/p10_pushBoxes/pushbox/text.txt b/level1/p10_pushBoxes/pushbox/text.txt new file mode 100644 index 00000000..28f3ff32 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/text.txt @@ -0,0 +1,6 @@ +0 0 0 0 0 0 +1 1 1 1 1 0 +0 1 1 1 1 1 +0 1 2 1 1 0 +0 1 1 1 1 0 +0 0 0 0 0 0 \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/text1.txt b/level1/p10_pushBoxes/pushbox/text1.txt new file mode 100644 index 00000000..71d40302 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/text1.txt @@ -0,0 +1,6 @@ +0 0 0 0 0 0 +1 1 1 0 0 0 +0 0 1 1 1 1 +0 1 2 1 1 0 +0 1 1 1 0 0 +0 0 0 0 0 0 \ No newline at end of file diff --git a/level1/p10_pushBoxes/pushbox/useinput.h b/level1/p10_pushBoxes/pushbox/useinput.h new file mode 100644 index 00000000..da93497b --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/useinput.h @@ -0,0 +1,5 @@ +#ifndef USEINPUT_H_INCLUDED +#define USEINPUT_H_INCLUDED +#include"basic.h" +void userinput(char ch); +#endif // !USEINPUT_H_INCLUDED diff --git a/level1/p10_pushBoxes/pushbox/userinput.c b/level1/p10_pushBoxes/pushbox/userinput.c new file mode 100644 index 00000000..c53752a2 --- /dev/null +++ b/level1/p10_pushBoxes/pushbox/userinput.c @@ -0,0 +1,72 @@ +#include"useinput.h" + +void userinput(char ch) +{ + int i,j; + if (ch == 'w') + { + position_x--; + direction = 2; + scorenumber++; + if (map[position_x][position_y] == 0||(map[position_x][position_y]==2 &&map[position_x-1][position_y]==0)) + { + position_x++; + scorenumber--; + direction = 0; + } + } + if (ch == 's') + { + position_x++; + direction = 1; + scorenumber++; + if (map[position_x][position_y] == 0 || (map[position_x][position_y] == 2 && map[position_x + 1][position_y] == 0)) + { + position_x--; + scorenumber--; + direction = 0; + } + } + if (ch == 'a') + { + direction = 4; + position_y--; + scorenumber++; + if (map[position_x][position_y] == 0 || (map[position_x][position_y] == 2 && map[position_x ][position_y-1] == 0)) + { + position_y++; + scorenumber--; + direction = 0; + } + } + if (ch == 'd') + { + position_y++; + direction = 3; + scorenumber++; + if (map[position_x][position_y] == 0 || (map[position_x][position_y] == 2&& map[position_x ][position_y+1] == 0)) + { + position_y--; + scorenumber--; + direction = 0; + } + } + if (ch == 'r') + { + for (i = 0; i < Maplong; i++) + { + for (j = 0; j < Mapwidth; j++) + { + + map[i][j] = rmap[i][j]; + if (rmap[i][j] == 2) + { + box_x = i; + box_y = j; + position_x = 1; + position_y = 0; + } + } + } + } +} diff --git a/level1/p12_warehouse/README.md b/level1/p12_warehouse/README.md deleted file mode 100755 index cd146f6a..00000000 --- a/level1/p12_warehouse/README.md +++ /dev/null @@ -1,11 +0,0 @@ -### 棰樼洰锛氱畝鍗曡繘閿瀛 - -### 鍔熻兘瑕佹眰锛 - -1. 瀹炵幇濡備笅鐨勮彍鍗曪紙鎸夋暟瀛楅夋嫨鑿滃崟鍔熻兘锛夛細 - - 鏄剧ず瀛樿揣鍒楄〃 - - 鍏ュ簱 - - 鍑哄簱 - - 閫鍑虹▼搴 -1. 瀹炵幇鑿滃崟瀵瑰簲鍔熻兘锛堥渶璁板綍璐х墿鐨勫瀷鍙枫佹暟閲忕瓑淇℃伅锛夛紱 -1. 绋嬪簭鍚姩鏃朵粠鏂囦欢涓鍙栧綋鍓嶅簱瀛樻暟鎹紝閫鍑烘椂淇濆瓨搴撳瓨鏁版嵁锛 \ No newline at end of file diff --git a/level1/p12_warehouse/basic.c b/level1/p12_warehouse/basic.c new file mode 100644 index 00000000..0bfd3994 --- /dev/null +++ b/level1/p12_warehouse/basic.c @@ -0,0 +1 @@ +#include"basic.h" diff --git a/level1/p12_warehouse/basic.h b/level1/p12_warehouse/basic.h new file mode 100644 index 00000000..bbafb90e --- /dev/null +++ b/level1/p12_warehouse/basic.h @@ -0,0 +1,15 @@ +#ifndef BASIC_H_INCLUDED +#define BASIC_H_INCLUDED +#define LEN sizeof(struct storage) +#include +#include +#include +#include +struct storage +{ + char name[10]; + double weight; +} cargo[100]; + + +#endif // BASIC_H_INCLUDED diff --git a/level1/p12_warehouse/main.c b/level1/p12_warehouse/main.c new file mode 100644 index 00000000..0777a42b --- /dev/null +++ b/level1/p12_warehouse/main.c @@ -0,0 +1,37 @@ +#include "menu.h" +#include "show.h" +#include "putinto.h" +#include "out.h" +int main() +{ + int n; + menu(); + scanf("%d",&n); + while(1) + { + switch(n) + { + case 1: + show(); + break; + case 2: + putinto(); + break; + case 3: + out(); + break; + case 4: + printf("goodbye"); + exit(1); + break; + default: + printf("the number is error,please input again"); + break; + } + _getch(); + system("cls"); + menu(); + scanf("%d",&n); + } + return 0; +} diff --git a/level1/p12_warehouse/menu.c b/level1/p12_warehouse/menu.c new file mode 100644 index 00000000..d176f6a0 --- /dev/null +++ b/level1/p12_warehouse/menu.c @@ -0,0 +1,13 @@ +#include"menu.h" +void menu() +{ + system("cls"); + printf("\n\n\n\n\n\n"); + printf("\t\t|--------------MENU--------------|\n"); + printf("\t\t|\t 1.show the list |\n"); + printf("\t\t|\t 2.put in the storage |\n"); + printf("\t\t|\t 3.deliver from storage |\n"); + printf("\t\t|\t 4.exit |\n"); + printf("\t\t|--------------------------------|\n\n"); + printf("\t\t\t please choose (1-4):"); +} diff --git a/level1/p12_warehouse/menu.h b/level1/p12_warehouse/menu.h new file mode 100644 index 00000000..ab1e2305 --- /dev/null +++ b/level1/p12_warehouse/menu.h @@ -0,0 +1,7 @@ +#ifndef MENU_H_INCLUDED +#define MENU_H_INCLUDED +#include"basic.h" +void menu(); + + +#endif // MENU_H_INCLUDED diff --git a/level1/p12_warehouse/out.c b/level1/p12_warehouse/out.c new file mode 100644 index 00000000..2c23a51c --- /dev/null +++ b/level1/p12_warehouse/out.c @@ -0,0 +1,59 @@ +#include"out.h" +void out() +{ + FILE *fp; + char sname[10]; + int i,j,m=0; + char ch[2]; + if((fp=fopen(" text.txt","ab+"))==NULL) + { + printf("can not open\n"); + return; + } + while(!feof(fp)) + if(fread(&cargo[m],LEN,1,fp)==1) + m++; + fclose(fp); + if(m==0) + { + printf("no record!\n"); + return; + } + printf("please input the name:"); + scanf("%s",sname); + for(i=0; i C:\Users\灏樺焹\Desktop\绋嬪簭璁捐\warehouse\warehouse\Debug\warehouse.exe diff --git a/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/CL.command.1.tlog b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/CL.command.1.tlog new file mode 100644 index 00000000..eead6b47 Binary files /dev/null and b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/CL.command.1.tlog differ diff --git a/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/CL.read.1.tlog b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/CL.read.1.tlog new file mode 100644 index 00000000..90482bff Binary files /dev/null and b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/CL.read.1.tlog differ diff --git a/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/CL.write.1.tlog b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/CL.write.1.tlog new file mode 100644 index 00000000..a618c4fb Binary files /dev/null and b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/CL.write.1.tlog differ diff --git a/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/link.command.1.tlog b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/link.command.1.tlog new file mode 100644 index 00000000..b442a1cc Binary files /dev/null and b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/link.command.1.tlog differ diff --git a/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/link.read.1.tlog b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/link.read.1.tlog new file mode 100644 index 00000000..740e0a46 Binary files /dev/null and b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/link.read.1.tlog differ diff --git a/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/link.write.1.tlog b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/link.write.1.tlog new file mode 100644 index 00000000..29aba678 Binary files /dev/null and b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/link.write.1.tlog differ diff --git a/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/warehouse.lastbuildstate b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/warehouse.lastbuildstate new file mode 100644 index 00000000..bbe1ea1c --- /dev/null +++ b/level1/p12_warehouse/warehouse/warehouse/Debug/warehouse.tlog/warehouse.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 +Debug|Win32|C:\Users\灏樺焹\Desktop\绋嬪簭璁捐\warehouse\warehouse\| diff --git a/level1/p12_warehouse/warehouse/warehouse/warehouse.vcxproj b/level1/p12_warehouse/warehouse/warehouse/warehouse.vcxproj new file mode 100644 index 00000000..479cebe0 --- /dev/null +++ b/level1/p12_warehouse/warehouse/warehouse/warehouse.vcxproj @@ -0,0 +1,172 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + 15.0 + {38126ADD-1B54-49DF-AE8A-E932B5A9F407} + Win32Proj + warehouse + 10.0.17763.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + NotUsing + Level3 + Disabled + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/level1/p12_warehouse/warehouse/warehouse/warehouse.vcxproj.filters b/level1/p12_warehouse/warehouse/warehouse/warehouse.vcxproj.filters new file mode 100644 index 00000000..2b0a90cf --- /dev/null +++ b/level1/p12_warehouse/warehouse/warehouse/warehouse.vcxproj.filters @@ -0,0 +1,57 @@ +锘 + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + \ No newline at end of file diff --git a/level1/p12_warehouse/warehouse/warehouse/warehouse.vcxproj.user b/level1/p12_warehouse/warehouse/warehouse/warehouse.vcxproj.user new file mode 100644 index 00000000..be250787 --- /dev/null +++ b/level1/p12_warehouse/warehouse/warehouse/warehouse.vcxproj.user @@ -0,0 +1,4 @@ +锘 + + + \ No newline at end of file diff --git a/level1/p12_warehouse/warehouse/warehouse/x64/Debug/warehouse.Build.CppClean.log b/level1/p12_warehouse/warehouse/warehouse/x64/Debug/warehouse.Build.CppClean.log new file mode 100644 index 00000000..c78d7230 --- /dev/null +++ b/level1/p12_warehouse/warehouse/warehouse/x64/Debug/warehouse.Build.CppClean.log @@ -0,0 +1,18 @@ +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\vc141.pdb +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\vc141.idb +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\test.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\show.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\putinto.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\out.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\menu.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\main.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\basic.obj +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\x64\debug\warehouse.ilk +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\x64\debug\warehouse.exe +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\x64\debug\warehouse.pdb +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\warehouse.tlog\cl.command.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\warehouse.tlog\cl.read.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\warehouse.tlog\cl.write.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\warehouse.tlog\link.command.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\warehouse.tlog\link.read.1.tlog +c:\users\灏樺焹\desktop\绋嬪簭璁捐\warehouse\warehouse\warehouse\x64\debug\warehouse.tlog\link.write.1.tlog diff --git a/level1/p12_warehouse/warehouse/warehouse/x64/Debug/warehouse.log b/level1/p12_warehouse/warehouse/warehouse/x64/Debug/warehouse.log new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/level1/p12_warehouse/warehouse/warehouse/x64/Debug/warehouse.log @@ -0,0 +1 @@ +锘 \ No newline at end of file diff --git a/wuziqi/alfa.c b/wuziqi/alfa.c new file mode 100644 index 00000000..e6534a80 --- /dev/null +++ b/wuziqi/alfa.c @@ -0,0 +1,84 @@ +#include"alfa.h" +#include"generate_evaluate.h" + +int minalfa(int deep, int alfa, int beta) +{ + //return allcalculate(); + int score = allcalculate(); + int i,x,y; + int cut = 0; + board_empty queue; + int tmpscore; + if (deep <= 0||exam()) + { + return score; + } + //empty(&queue); + generate_evaluate(&queue); + for (i = 0; i < queue.len; i++) + { + cut++; + x = queue.board9[i].x; + y = queue.board9[i].y; + board[x][y] = 4; + userposition_x = x; + userposition_y = y; + tmpscore = maxalfa(deep - 1, alfa, beta ); + board[x][y] = 0; + if (cut > 10) + { + break; + } + if (tmpscore =beta) + { + break; + } + + } + return beta; + +} +int maxalfa(int deep, int alfa, int beta) +{ + int res = allcalculate(); + int i, x, y; + int cut = 0; + int tmpscore; + board_empty queue; + if (deep <= 0 || exam())//上一步可能产生输赢 + { + return res; + } + //生成可以下棋子的空子序列 + //empty(&queue); + generate_evaluate(&queue); + for (i = 0; i < queue.len; i++) + { + cut++; + x = queue.board9[i].x; + y = queue.board9[i].y; + board[x][y] = 2; //尝试下一个子 + userposition_x = x; + userposition_y = y; + tmpscore = minalfa(deep - 1,alfa, beta); + board[x][y] = 0; //恢复成空子 + if (cut > 10) + { + break; + } + if (tmpscore >alfa) + { + alfa= tmpscore; + } + if (alfa >= beta) + { + break; + } + } + return alfa; + +} diff --git a/wuziqi/alfa.h b/wuziqi/alfa.h new file mode 100644 index 00000000..e8110c62 --- /dev/null +++ b/wuziqi/alfa.h @@ -0,0 +1,10 @@ +#ifndef ALFA_H_INCLUDED +#define ALFA_H_INCLUDED +#include"basic.h" +#include"allcalculate.h" +#include"exam.h" +#include"empty.h" +int maxalfa(int deep,int alfa,int beta); +int minalfa(int deep, int alfa, int beta); + +#endif // ALFA_H_INCLUDED diff --git a/wuziqi/allcalculate.c b/wuziqi/allcalculate.c new file mode 100644 index 00000000..5921e20d --- /dev/null +++ b/wuziqi/allcalculate.c @@ -0,0 +1,81 @@ +#include "allcalculate.h" +#include"calculate.h" +int allcalculate() +{ + int i, j, k; + int score = 0; + for (i = 0; i < width; i++) + { + for (j = 0; j < length; j++) + { + board1[j] = board[i][j]; + } + score += calculate(board1) + anticalculate(board1); + for (k = 0; k < 15; k++) + { + board1[k] = 5; + } + } + for (j = 0; j < length; j++) + { + for (i = 0; i < width; i++) + { + board1[i] = board[i][j]; + } + score += calculate(board1) + anticalculate(board1); + for (k = 0; k < 15; k++) + { + board1[k] = 5; + } + } + for (i = 4; i < width; i++) + { + for (j = 0; j < i + 1; j++) + { + board1[j] = board[i - j][j]; + } + score += calculate(board1) + anticalculate(board1); + for (k = 0; k < 15; k++) + { + board1[k] = 5; + } + } + for (i = width - 5; i > 0; i--) + { + for (j = 0; j < length - i; j++) + { + board1[j] = board[i + j][j]; + } + score += calculate(board1) + anticalculate(board1); + for (k = 0; k < 15; k++) + { + board1[k] = 5; + } + } + for (j = length - 5; j > -1; j--) + { + for (i = 0; i < width - j; i++) + { + board1[i] = board[i][j + i]; + } + score += calculate(board1) + anticalculate(board1); + for (k = 0; k < 15; k++) + { + board1[k] = 5; + } + } + for (j = 1; j < length - 4; j++) + { + for (i = width - 1; i > j - 1; i--) + { + board1[width - i - 1] = board[i][width + j - 1 - i]; + } + score += calculate(board1) + anticalculate(board1); + for (k = 0; k < 15; k++) + { + board1[k] = 5; + } + } + //printf("%d\n",score ); + return score; +} \ No newline at end of file diff --git a/wuziqi/allcalculate.h b/wuziqi/allcalculate.h new file mode 100644 index 00000000..014f9e97 --- /dev/null +++ b/wuziqi/allcalculate.h @@ -0,0 +1,5 @@ +#ifndef ALLCALCULATE_H_INCLUDED +#define ALLCALCULATE_H_INCLUDED +#include"basic.h" +int allcalculate(); +#endif \ No newline at end of file diff --git a/wuziqi/assume.c b/wuziqi/assume.c new file mode 100644 index 00000000..ab95f942 --- /dev/null +++ b/wuziqi/assume.c @@ -0,0 +1,57 @@ +#include"assume.h" +#include"allcalculate.h" +#include"basic.h" +#include"empty.h" +#include"generate_evaluate.h" +void assume() +{ + int i,j=0; + int x, y; + //int test = 0; + int scoremax=0; + int scorenumberi=0; + int scorenumberj=0; + int maxscore=MIN; + int alfa = MIN; + int beta = MAX; + board_empty tempposition; + board_empty sureposition; + //empty(&tempposition); + generate_evaluate(&tempposition);//生成排序后的点顺序 + for (i = 0; i +#include +#include +#include +#include +#include +#include + +#define BASIC_H_INCLUDED +#define length 15 +#define width 15 +#define Maxside 100 +#define MIN -0x3f3f3f3f +#define MAX 0x3f3f3f3f +#define depth 6//层数 +#define ONE 1 + +#define TWO 100 +#define THREE 10000 +#define FOUR 1000000 +#define FIVE 10000000 +#define BLOCKED_ONE 1 +#define BLOCKED_TWO 10 +#define BLOCKED_THREE 1000 +#define BLOCKED_FOUR 100000 +extern int position_x; +extern int userposition_y; +extern int userposition_x; +extern int count; +extern int time1 ; +extern int position_y; +extern int board[length][width]; +extern char ch; +extern int temp_x; +extern int temp_y; +extern int number; +extern int first3 ; +extern int first; +extern char a; +extern int point; +extern int position2_x; +extern int position2_y; +extern int board1[15]; +extern int first1; +extern int scoreMatrix[length][width]; +POINT positionpoint; +typedef struct positionboard +{ + int x; + int y; + +}board_s; +typedef struct emptyboard +{ + board_s board9[width*length]; + int len; +}board_empty; +typedef struct position +{ + int _x; + int _y; +}boardnode; +typedef struct child +{ + int x; + int y; +}child; +typedef struct fiveboard +{ + board_s board9[width*length]; + int len; +}five; +typedef struct comfourboard +{ + board_s board9[width*length]; + int len; +}comfour; +typedef struct humfours +{ + board_s board9[width*length]; + int len; +}humfour; +typedef struct humblockedfours +{ + board_s board9[width*length]; + int len; +}humblockedfour; +typedef struct comblockedfours +{ + board_s board9[width*length]; + int len; +}comblockedfour; +typedef struct comtwothrees +{ + board_s board9[width*length]; + int len; +}comtwothree; +typedef struct humtwothrees +{ + board_s board9[width*length]; + int len; +}humtwothree; +typedef struct comthrees +{ + board_s board9[width*length]; + int len; +}comthree; +typedef struct humthrees +{ + board_s board9[width*length]; + int len; +}humthree; +typedef struct comtwos +{ + board_s board9[width*length]; + int len; +}comtwo; +typedef struct humtwos +{ + board_s board9[width*length]; + int len; +}humtwo; +typedef struct neighbor +{ + int _x; + int _y; +}neighbor; +#endif // BASIC_H_INCLUDED diff --git a/wuziqi/calculate.c b/wuziqi/calculate.c new file mode 100644 index 00000000..6862113e --- /dev/null +++ b/wuziqi/calculate.c @@ -0,0 +1,629 @@ +#include"basic.h" +#include"calculate.h" +int calculate(int* board1)//估值算法 +{ + int pointstring = 0; + int tempscore = 0; + int i; + for (i = 0; i < 10; i++) + { + if (board1[i] == 2 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 2) + { + pointstring = 1; + tempscore += FIVE; + + } + + + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 0) + { + pointstring = 2; + tempscore += FOUR; + + } + + + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 4) + { + pointstring = 7; + tempscore += BLOCKED_FOUR; + + } + + + else if (board1[i] == 2 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2) + { + pointstring = 9; + tempscore += BLOCKED_FOUR; + + } + + + else if (board1[i] == 4 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 0) + { + pointstring = 8; + tempscore += BLOCKED_FOUR; + + } + + + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 2) + { + pointstring = 10; + tempscore += BLOCKED_FOUR; + + } + + + else if (board1[i] == 2 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 2) + { + pointstring = 11; + tempscore += BLOCKED_FOUR; + + } + + + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 0 ) + { + + pointstring = 3; + tempscore += THREE; + + } + + + + + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 2 && board1[i + 5] == 0) + { + pointstring = 5; + tempscore += THREE; + + } + + + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += THREE; + + } + + + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 4) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + } + // {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 4) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + } + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 0 && board1[i + 5] == 4) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 2 && board1[i + 5] == 4) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + + else if (board1[i] == 4 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + + else if (board1[i] == 4 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 2 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + else if (board1[i] == 4 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 2) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 2) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 0) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 2 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + else if (board1[i] == 2 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 0 && board1[i + 4] == 2) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 2) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + else if (board1[i] == 2 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 0) + { + pointstring = 6; + tempscore += BLOCKED_THREE; + } + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 12; + tempscore += TWO; + } + + + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 2 && board1[i + 5] == 0) + { + pointstring = 13; + tempscore += TWO; + + } + + //{"000110", "001010", "001100", "001100", "010100", "011000", "000110", "010010", "010100", "001010", "010010", "011000", }; + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 14; + tempscore += TWO; + + } + + //{"000112", "001012", "010012", "10001", "2010102", "2011002", "211000", "210100", "210010", "2001102"}; + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 2 && board1[i + 5] == 4) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + + } + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 4) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + + } //{"000112", "001012", "010012", "10001", "2010102", "2011002", "211000", "210100", "210010", "2001102"}; + + + + else if (board1[i] == 0 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 0 && board1[i + 4] == 2 && board1[i + 5] == 4) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + + } //{"000112", "001012", "010012", "10001", "2010102", "2011002", "211000", "210100", "210010", "2001102"}; + + + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 0 && board1[i + 4] == 2 ) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + + } //{"000112", "001012", "010012", "10001", "2010102", "2011002", "211000", "210100", "210010", "2001102"}; + + + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 2 && board1[i + 5] == 0 && board1[i + 6] == 4) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + + } //{"000112", "001012", "010012", "10001", "2010102", "2011002", "211000", "210100", "210010", "2001102"}; + + + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 2 && board1[i + 4] == 0 && board1[i + 5] == 0 && board1[i + 6] == 4) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + + } + + + else if (board1[i] == 4 && board1[i + 1] == 2 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + + } + + else if (board1[i] == 4 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + + } //{"000112", "001012", "010012", "10001", "2010102", "2011002", "211000", "210100", "210010", "2001102"}; + + else if (board1[i] == 4 && board1[i + 1] == 2 && board1[i + 2] == 0 && board1[i + 3] == 0 && board1[i + 4] == 2 && board1[i + 5] == 0) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + } + + + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 2 && board1[i + 5] == 0 && board1[i + 6] == 4) + { + pointstring = 13; + tempscore += BLOCKED_TWO; + + } + + + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 2 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 15; + tempscore += ONE; + + } + + + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 2 && board1[i + 3] == 0 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 16; + tempscore += ONE; + + } + } + return tempscore; + } + int anticalculate(int board1[]) + { + + int pointstring = 0; + int tempscore = 0; + int i; + for (i = 0; i < 10; i++) + { + if (board1[i] == 4 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 4) + { + pointstring = 1; + tempscore += -FIVE; + + } + + + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 4 && board1[i + 5] == 0) + { + pointstring = 2; + tempscore += -FOUR; + + } + + + else if (board1[i] == 4 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 0) + { + pointstring = 7; + tempscore += -BLOCKED_FOUR; + + } + + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 4) + { + pointstring = 8; + tempscore += -BLOCKED_FOUR; + + } + + else if (board1[i] == 4 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 4) + { + pointstring = 9; + tempscore += -BLOCKED_FOUR; + + } + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 4) + { + pointstring += 10; + tempscore += -BLOCKED_FOUR; + + } + else if (board1[i] == 4 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 4) + { + pointstring = 11; + tempscore += -BLOCKED_FOUR; + + } + + + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 0) + { + + pointstring = 3; + tempscore += -THREE; + + } + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 4 && board1[i + 5] == 0) + { + pointstring = 5; + tempscore += -THREE; + + } + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 4 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += -THREE; + + } + + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 4 && board1[i + 5] == 2) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 4 && board1[i + 5] == 2) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 4 && board1[i + 5] == 2) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] ==4 && board1[i + 4] == 0 && board1[i + 5] == 2) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 2 && board1[i + 1] == 4 && board1[i + 2] == 4&& board1[i + 3] == 4 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + // {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + } + else if (board1[i] == 2 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 4 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + // {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + } + else if (board1[i] == 2 && board1[i + 1] == 4 && board1[i + 2] ==0 && board1[i + 3] == 4 && board1[i + 4] == 4 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + // {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + } + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 4 && board1[i + 5] == 0) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + // {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + } + + + + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 4) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + } + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 4) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 4 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 0 && board1[i + 4] == 4) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + } + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 4) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 0) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 4) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + } + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 4) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + }// {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + + else if (board1[i] == 4 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 0) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + // {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + } + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 4) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + } + // {"002221", "020221", "022021", "022201", "122200", "122020", "120220", "102220", "00222", "20022", "20202", "20220", "02022", "20022", "22002", "22020", "02202", "20202", "22002", "22200", }; + + + else if (board1[i] == 4 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 0 && board1[i + 4] == 4) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + } + else if (board1[i] == 4 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 0) + { + pointstring = 6; + tempscore += -BLOCKED_THREE; + + } + + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 12; + tempscore += -TWO; + + } + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 4 && board1[i + 5] == 0) + { + pointstring = 13; + tempscore += -TWO; + + } + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 14; + tempscore += -TWO; + + } + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 4 && board1[i + 5] == 2) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + + } //{"000112", "001012", "010012", "10001", "2010102", "2011002", "211000", "210100", "210010", "2001102"}; + + + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 4 && board1[i + 5] == 2) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + + } + else if (board1[i] == 0 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 0 && board1[i + 4] == 4 && board1[i + 5] == 2) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + + } + else if (board1[i] == 4 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 0 && board1[i + 4] == 4) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + //{"000112", "001012", "010012", "10001", "2010102", "2011002", "211000", "210100", "210010", "2001102"}; + } + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 4 && board1[i + 5] == 0 && board1[i + 6] == 2) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + + } + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 4 && board1[i + 4] == 0 && board1[i + 5] == 0 && board1[i + 6] == 2) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + + } + else if (board1[i] == 2 && board1[i + 1] == 4 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + + } + else if (board1[i] == 2 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + + } + else if (board1[i] == 2 && board1[i + 1] == 4 && board1[i + 2] == 0 && board1[i + 3] == 0 && board1[i + 4] == 4 && board1[i + 5] == 0) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + + } + else if (board1[i] == 2 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 4 && board1[i + 5] == 0 && board1[i + 6] == 2) + { + pointstring = 13; + tempscore += -BLOCKED_TWO; + + } + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 0 && board1[i + 3] == 4 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 15; + tempscore += -ONE; + + } + else if (board1[i] == 0 && board1[i + 1] == 0 && board1[i + 2] == 4 && board1[i + 3] == 0 && board1[i + 4] == 0 && board1[i + 5] == 0) + { + pointstring = 16; + tempscore += -ONE; + + } + } + return tempscore; + +} \ No newline at end of file diff --git a/wuziqi/calculate.h b/wuziqi/calculate.h new file mode 100644 index 00000000..c5d85a8f --- /dev/null +++ b/wuziqi/calculate.h @@ -0,0 +1,6 @@ +#ifndef CALCULATE_H_INCLUDED +#define CALCULATE_H_INCLUDED +#include"basic.h" +int calculate(int board1[]); +int anticalculate(int board1[]); +#endif // CALCULATE_H_INCLUDED diff --git a/wuziqi/empty.c b/wuziqi/empty.c new file mode 100644 index 00000000..2c80a6b7 --- /dev/null +++ b/wuziqi/empty.c @@ -0,0 +1,19 @@ +#include"empty.h" +#include"near.h" +void empty(board_empty* empty1)//空闲的位置 +{ + int i, j, k = 0; + for (i = 0; i < width; i++) + { + for (j = 0; j < length; j++) + { + if ((board[i][j] == 0) && near1(i, j))//有棋子的空子,做为可下子的队列 + { + empty1->board9[k].x = i; + empty1->board9[k].y = j; + empty1->len = k + 1; + k++; + } + } + } +} \ No newline at end of file diff --git a/wuziqi/empty.h b/wuziqi/empty.h new file mode 100644 index 00000000..f1a075f6 --- /dev/null +++ b/wuziqi/empty.h @@ -0,0 +1,5 @@ +#ifndef EMPTY_H_INCLUDED +#define EMPTY_H_INCLUDED +#include"basic.h" +void empty(board_empty * empty); +#endif // diff --git a/wuziqi/evaluate.c b/wuziqi/evaluate.c new file mode 100644 index 00000000..fd2781d0 --- /dev/null +++ b/wuziqi/evaluate.c @@ -0,0 +1,21 @@ +#include"evaluate.h" +#include"examasume.h" +int evaluate(int x,int y)//对于一个点的四个方向的估值 +{ + int i,j; + i = x; + j = y; + int score=0; + score+=leftrightexamassume(i,j)+updownexamassume(i,j)+leftuprightdownexamassume(i,j)+leftdownrightupexamassume(i,j); + return score; +} +int evaluatehuman(int x, int y) +{ + int i, j; + i = x; + j = y; + int score = 0; + score += -leftrightexamassumehuman(i, j) - updownexamassumehuman(i, j) - leftuprightdownexamassumehuman(i, j) -leftdownrightupexamassumehuman(i, j); + + return score; +} diff --git a/wuziqi/evaluate.h b/wuziqi/evaluate.h new file mode 100644 index 00000000..f55b9547 --- /dev/null +++ b/wuziqi/evaluate.h @@ -0,0 +1,6 @@ +#ifndef EVALUATE_H_INCLUDED +#define EVALUATE_H_INCLUDED +#include"basic.h" +int evaluate(int x,int y); +int evaluatehuman(int x, int y); +#endif // EVALUATE_H_INCLUDED diff --git a/wuziqi/exam.c b/wuziqi/exam.c new file mode 100644 index 00000000..ccd43ff3 --- /dev/null +++ b/wuziqi/exam.c @@ -0,0 +1,126 @@ +#include"exam.h" +int exam()//判断胜负 +{ + int i; + for (i = -4; i < 5; i++) + { + if (board[userposition_x + i][userposition_y] == 2||board[userposition_x+i][userposition_y ] == 5) + { + count++; + } + else + { + count = 0; + } + if (count == 5) + { + return 2; + } + } + for (i = -4; i < 5; i++) + { + if (board[userposition_x][userposition_y + i] == 2 || board[userposition_x][userposition_y + i] == 5) + { + count++; + } + else + { + count = 0; + } + if (count == 5) + { + return 2; + } + } + for (i = -4; i < 5; i++) + { + if (board[userposition_x + i][userposition_y + i] == 2 || board[userposition_x+i][userposition_y + i] == 5) + { + count++; + } + else + { + count = 0; + } + if (count == 5) + { + return 2; + } + } + for (i = -4; i < 5; i++) + { + if (board[userposition_x + i][userposition_y - i] == 2 || board[userposition_x+i][userposition_y - i] == 5) + { + count++; + } + else + { + count = 0; + } + if (count == 5) + { + return 2; + } + } + for (i = -4; i < 5; i++) + { + if (board[userposition_x + i][userposition_y] == 4) + { + count++; + } + else + { + count = 0; + } + if (count == 5) + { + return 4; + } + } + for (i = -4; i < 5; i++) + { + if (board[userposition_x][userposition_y + i] == 4 ) + { + count++; + } + else + { + count = 0; + } + if (count == 5) + { + return 4; + } + } + for (i = -4; i < 5; i++) + { + if (board[userposition_x + i][userposition_y + i] == 4 ) + { + count++; + } + else + { + count = 0; + } + if (count == 5) + { + return 4; + } + } + for (i = -4; i < 5; i++) + { + if (board[userposition_x + i][userposition_y - i] == 4 ) + { + count++; + } + else + { + count = 0; + } + if (5 == count) + { + return 4; + } + } + return 0; +} \ No newline at end of file diff --git a/wuziqi/exam.h b/wuziqi/exam.h new file mode 100644 index 00000000..b83ca478 --- /dev/null +++ b/wuziqi/exam.h @@ -0,0 +1,7 @@ +#ifndef EXAM_H_INCLUDED +#define EXAM_H_INCLUDED +#include "basic.h" +int exam(); + + +#endif // EXAM_H_INCLUDED diff --git a/wuziqi/examassume.c b/wuziqi/examassume.c new file mode 100644 index 00000000..fccfdb1e --- /dev/null +++ b/wuziqi/examassume.c @@ -0,0 +1,146 @@ +#include"examasume.h" +#include"calculate.h" +int leftrightexamassume(int position1_x,int position1_y)//四个方向的估值 +{ + int i,j; + for (i = 0; i < 9; i++) + { + board1[i] = 9; + } + for(i=1; i<5; i++) + { + if((position1_y-i)>-1) + board1[4-i]=board[position1_x][position1_y-i]; + if((position1_y+i)-1) + board1[4-i]=board[position1_x-i][position1_y]; + if((position1_x+i)-1&&(position1_y-i)>-1) + board1[4-i]=board[position1_x-i][position1_y-i]; + if((position1_x+i)-1) + board1[4-i]=board[position1_x+i][position1_y-i]; + if((position1_x-i)>-1&&(position1_y+i)-1) + board1[4-i]=board[position1_x][position1_y-i]; + if((position1_y+i)-1) + board1[4-i]=board[position1_x-i][position1_y]; + if((position1_x+i)-1&&(position1_y-i)>-1) + board1[4-i]=board[position1_x-i][position1_y-i]; + if((position1_x+i)-1) + board1[4-i]=board[position1_x+i][position1_y-i]; + if((position1_x-i)>-1&&(position1_y+i)len; + int i, j; + int temp; + for (i = 0; i < len; i++) + { + score[i] = evaluatehuman(empty1->board9[i].x, empty1->board9[i].y) ; + } + for(i=0;i score[j + 1]) + { + temp=empty1->board9[j+1].x; + empty1->board9[j + 1].x = empty1->board9[j].x; + empty1->board9[j].x=temp; + temp = empty1->board9[j + 1].y; + empty1->board9[j + 1].y = empty1->board9[j].y; + empty1->board9[j].y = temp; + temp =score[j]; + score[j] = score[j+1]; + score[j+1] = temp; + } + } + } + + +}*/ +void generate_evaluate(board_empty* empty1) +{ + int number = 0; + board_empty Five; + Five.len = 0; + board_empty Comfour; + Comfour.len = 0; + board_empty Humfour; + Humfour.len = 0; + board_empty Comblock; + Comblock.len = 0; + board_empty Humblock; + Humblock.len = 0; + board_empty Comtwothree; + Comtwothree.len = 0; + board_empty Humtwothree; + Humtwothree.len = 0; + board_empty Comthree; + Comthree.len = 0; + board_empty Comblockthree; + Comblockthree.len = 0; + board_empty Humblockthree; + Humblockthree.len = 0; + board_empty Humthree; + Humthree.len = 0; + board_empty Comtwo; + Comtwo.len = 0; + board_empty Humtwo; + Humtwo.len = 0; + board_empty Comblocktwo; + Comblocktwo.len = 0; + board_empty Humblocktwo; + Humblocktwo.len = 0; + board_empty Other; + Other.len = 0; + int i, j; + int a0,a1,a2, a3, a4, a5, a6, a7, a8, a9, a10,a11,a12,a13,a14,a15,a16,a17; + a0 = a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = a10 = a11 = a12 = a13=a14=a15=a16=a17=0; + int scoreHum; + int scoreCom; + empty1->len = 0; + for (int i = 0; i < length; i++) { + for (int j = 0; j < width; j++) { + if (board[i][j] == 0 && near1(i, j))//必须是有邻居的才行 + { scoreHum = evaluatehuman(i, j); + scoreCom = evaluate(i, j); + if (scoreCom >=FIVE) + {//先看电脑能不能连成5 + empty1->board9[a0].x = i; + empty1->board9[a0].y = j; + empty1->len += 1; + return; + } + else if (scoreHum >= FIVE) + {//再看玩家能不能连成5 + + Five.len = a1 + 1; + Five.board9[a1].x = i; + Five.board9[a1].y = j; + a1++; + } + else if (scoreCom >= FOUR) + { + Comfour.len = a2 + 1; + Comfour.board9[a2].x = i; + Comfour.board9[a2].y = j; + a2++; + } + else if (scoreHum >= FOUR) + { + Humfour.len = a5 + 1; + Humfour.board9[a5].x = i; + Humfour.board9[a5].y = j; + a5++; + } + else if (scoreCom >= BLOCKED_FOUR) + { + Comblock.len = a3 + 1; + Comblock.board9[a3].x = i; + Comblock.board9[a3].y = j; + a3++; + + } + else if (scoreHum >= BLOCKED_FOUR) + { + Humblock.len = a4 + 1; + Humblock.board9[a4].x = i; + Humblock.board9[a4].y = j; + a4++; + } + else if (scoreCom >= 2 * THREE) + { + //双三 + Comtwothree.len = a6 + 1; + Comtwothree.board9[a6].x = i; + Comtwothree.board9[a6].y = j; + a6++; + } + else if (scoreHum >= 2 * THREE) + { + Humtwothree.len = a7 + 1; + Humtwothree.board9[a7].x = i; + Humtwothree.board9[a7].y = j; + a7++; + } + else if (scoreCom >= THREE) + { + Comthree.len = a8 + 1; + Comthree.board9[a8].x = i; + Comthree.board9[a8].y = j; + a8++; + } + else if (scoreHum >= THREE) + { + Humthree.len = a9 + 1; + Humthree.board9[a9].x = i; + Humthree.board9[a9].y = j; + a9++; + } + else if (scoreCom >= BLOCKED_THREE) + { + Comblockthree.len = a15 + 1; + Comblockthree.board9[a15].x = i; + Comblockthree.board9[a15].y = j; + a15++; + } + else if (scoreHum >= BLOCKED_THREE) + { + Humblockthree.len = a14 + 1; + Humblockthree.board9[a14].x = i; + Humblockthree.board9[a14].y = j; + a14++; + } + else if (scoreCom >= TWO) + { + Comtwo.len = a10 + 1; + Comtwo.board9[a10].x = i; + Comtwo.board9[a10].y = j; + a10++; + } + else if (scoreHum >= TWO) + { + Humtwo.len = a11 + 1; + Humtwo.board9[a11].x = i; + Humtwo.board9[a11].y = j; + a11++; + } + else if (scoreCom >= BLOCKED_TWO) + { + Comblocktwo.len = a16 + 1; + Comblocktwo.board9[a16].x = i; + Comblocktwo.board9[a16].y = j; + a16++; + } + else if (scoreHum >= BLOCKED_TWO) + { + Humblocktwo.len = a17 + 1; + Humblocktwo.board9[a17].x = i; + Humblocktwo.board9[a17].y = j; + a17++; + } + else + { + Other.len = a12 + 1; + Other.board9[a12].x = i; + Other.board9[a12].y = j; + a12++; + } + + } + } + } + + //如果成五,是必杀棋,直接返回 + if (Five.len) + { + for (i = 0; i < Five.len; i++) + { + empty1->board9[i].x = Five.board9[i].x; + empty1->board9[i].y = Five.board9[i].y; + empty1->len ++; + } + return; + } + + if (Comfour.len > 0 || Humfour.len > 0) + { + for (i = 0; i < Comfour.len; i++) + { + empty1->board9[i].x = Comfour.board9[i].x; + empty1->board9[i].y = Comfour.board9[i].y; + empty1->len ++; + } + for (i = Comfour.len,j=0; j < Humfour.len; j++) + { + empty1->board9[i+j].x = Humfour.board9[j].x; + empty1->board9[i+j].y = Humfour.board9[j].y; + empty1->len ++; + } + return ; + } + if (Comtwothree.len > 0 || Humtwothree.len > 0) + { + for (i = 0; i < Comtwothree.len; i++) + { + empty1->board9[i].x = Comtwothree.board9[i].x; + empty1->board9[i].y = Comtwothree.board9[i].y; + empty1->len ++; + } + for (i = Comtwothree.len, j = 0; j < Humtwothree.len; j++) + { + empty1->board9[i + j].x = Humtwothree.board9[j].x; + empty1->board9[i + j].y = Humtwothree.board9[j].y; + empty1->len ++; + } + return; + } + //以上都是杀棋,直接返回 + //以下按顺序存入 + for (i = 0; i < Comblock.len; i++) + { + empty1->board9[i].x = Comblock.board9[i].x; + empty1->board9[i].y = Comblock.board9[i].y; + empty1->len++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comblock.len,j= 0; j < Humblock.len; j++) + { + empty1->board9[i+j].x = Humblock.board9[j].x; + empty1->board9[i+j].y = Humblock.board9[j].y; + empty1->len++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comblock.len+ Humblock.len,j=0;j < Comthree.len; j++) + { + empty1->board9[i+j].x = Comthree.board9[j].x; + empty1->board9[i+j].y = Comthree.board9[j].y; + empty1->len ++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comthree.len+Comblock.len + Humblock.len, j = 0; j < Humthree.len; j++) + { + empty1->board9[i + j].x = Humthree.board9[j].x; + empty1->board9[i + j].y = Humthree.board9[j].y; + empty1->len ++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comthree.len+ Humthree.len + Comblock.len + Humblock.len, j = 0; j < Comblockthree.len; j++) + { + empty1->board9[i + j].x = Comblockthree.board9[j].x; + empty1->board9[i + j].y = Comblockthree.board9[j].y; + empty1->len++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comthree.len + Humthree.len+ Comblockthree.len + Comblock.len + Humblock.len, j = 0; j < Humblockthree.len; j++) + { + empty1->board9[i + j].x = Humblockthree.board9[j].x; + empty1->board9[i + j].y = Humblockthree.board9[j].y; + empty1->len++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comthree.len+ Humthree.len+ Comblockthree.len+Humblockthree.len + Comblock.len + Humblock.len, j = 0; j < Comtwo.len; j++) + { + empty1->board9[i + j].x = Comtwo.board9[j].x; + empty1->board9[i + j].y = Comtwo.board9[j].y; + empty1->len ++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comthree.len + Humthree.len+ Comtwo.len + Comblockthree.len + Humblockthree.len + Comblock.len + Humblock.len, j = 0; j board9[i + j].x = Humtwo.board9[j].x; + empty1->board9[i + j].y = Humtwo.board9[j].y; + empty1->len ++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comthree.len + Humthree.len + Comblockthree.len + Humblockthree.len+Comtwo.len+ Humtwo.len + Comblock.len + Humblock.len, j = 0; j < Comblocktwo.len; j++) + { + empty1->board9[i + j].x = Comblocktwo.board9[j].x; + empty1->board9[i + j].y = Comblocktwo.board9[j].y; + empty1->len++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comthree.len + Humthree.len + Comblockthree.len + Humblockthree.len + Comtwo.len + Humtwo.len+ Comblocktwo.len + Comblock.len + Humblock.len, j = 0; j < Humblocktwo.len; j++) + { + empty1->board9[i + j].x = Humblocktwo.board9[j].x; + empty1->board9[i + j].y = Humblocktwo.board9[j].y; + empty1->len++; + number++; + if (number > 10) + { + return; + } + } + for (i = Comthree.len + Humthree.len + Comtwo.len + Comblockthree.len + Humblockthree.len + Humtwo.len + Comblocktwo.len + Humblocktwo.len + Comblock.len + Humblock.len, j = 0; j < Other.len; j++) + { + empty1->board9[i + j].x = Other.board9[j].x; + empty1->board9[i + j].y = Other.board9[j].y; + empty1->len ++; + number++; + if (number > 10) + { + return; + } + } + return ; + } \ No newline at end of file diff --git a/wuziqi/generate_evaluate.h b/wuziqi/generate_evaluate.h new file mode 100644 index 00000000..d6d991d5 --- /dev/null +++ b/wuziqi/generate_evaluate.h @@ -0,0 +1,9 @@ +#ifndef GENERATE_EVALUATE_H_INCLUDED +#define GENERATE_EVALUATE_H_INCLUDED +#include"basic.h" +#include"empty.h" +#include"near.h" +#include"evaluate.h" +void generate_evaluate(board_empty* empty1); +#endif // !GENERATE_EVALUATE_H_INCLUDED + diff --git a/wuziqi/input.h b/wuziqi/input.h new file mode 100644 index 00000000..713a0370 --- /dev/null +++ b/wuziqi/input.h @@ -0,0 +1,7 @@ +#ifndef INPUT_H_INCLUDED +#define INPUT_H_INCLUDED +#include"basic.h" +int input1(); + + +#endif // INPUT_H_INCLUDED diff --git a/wuziqi/input1.c b/wuziqi/input1.c new file mode 100644 index 00000000..d54e2de5 --- /dev/null +++ b/wuziqi/input1.c @@ -0,0 +1,36 @@ +#include"userinput.h" +int input1() +{ + switch(ch)//键盘输入 + { + case 'w': + if(position_x>0) + position_x--; + break; + case 's': + if(position_x0) + position_y--; + break; + case 'd': + if(position_y C:\Users\灏樺焹\Desktop\wuziqi\wuziqi\Debug\wuziqi.exe diff --git a/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/CL.command.1.tlog b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/CL.command.1.tlog new file mode 100644 index 00000000..6c5f334b Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/CL.command.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/CL.read.1.tlog b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/CL.read.1.tlog new file mode 100644 index 00000000..1defa0a7 Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/CL.read.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/CL.write.1.tlog b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/CL.write.1.tlog new file mode 100644 index 00000000..d4bc300a Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/CL.write.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/link.command.1.tlog b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/link.command.1.tlog new file mode 100644 index 00000000..50d52cd6 Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/link.command.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/link.read.1.tlog b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/link.read.1.tlog new file mode 100644 index 00000000..4d3eebc2 Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/link.read.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/link.write.1.tlog b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/link.write.1.tlog new file mode 100644 index 00000000..62c541a2 Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/link.write.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/wuziqi.lastbuildstate b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/wuziqi.lastbuildstate new file mode 100644 index 00000000..373e9eed --- /dev/null +++ b/wuziqi/wuziqi/wuziqi/Debug/wuziqi.tlog/wuziqi.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 +Debug|Win32|C:\Users\灏樺焹\Desktop\wuziqi\wuziqi\| diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.Build.CppClean.log b/wuziqi/wuziqi/wuziqi/Release/wuziqi.Build.CppClean.log new file mode 100644 index 00000000..bec16a17 --- /dev/null +++ b/wuziqi/wuziqi/wuziqi/Release/wuziqi.Build.CppClean.log @@ -0,0 +1,30 @@ +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\vc141.pdb +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\window.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\userinput.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\test.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\show.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\near.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\menu.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\main.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\input1.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\generate_evaluate.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\examassume.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\exam.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\evaluate.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\empty.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\calculate.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\basic.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\assume.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\allcalculate.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\alfa.obj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\release\wuziqi.exe +c:\users\灏樺焹\desktop\wuziqi\wuziqi\release\wuziqi.pdb +c:\users\灏樺焹\desktop\wuziqi\wuziqi\release\wuziqi.ipdb +c:\users\灏樺焹\desktop\wuziqi\wuziqi\release\wuziqi.iobj +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\wuziqi.tlog\cl.command.1.tlog +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\wuziqi.tlog\cl.read.1.tlog +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\wuziqi.tlog\cl.write.1.tlog +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\wuziqi.tlog\link.command.1.tlog +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\wuziqi.tlog\link.read.1.tlog +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\wuziqi.tlog\link.write.1.tlog +c:\users\灏樺焹\desktop\wuziqi\wuziqi\wuziqi\release\wuziqi.tlog\wuziqi.write.1u.tlog diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.log b/wuziqi/wuziqi/wuziqi/Release/wuziqi.log new file mode 100644 index 00000000..cd0c07fe --- /dev/null +++ b/wuziqi/wuziqi/wuziqi/Release/wuziqi.log @@ -0,0 +1,8 @@ +锘 assume.c +c:\users\灏樺焹\desktop\wuziqi\assume.c(50): warning C4244: 鈥滃嚱鏁扳: 浠庘渢ime_t鈥濊浆鎹㈠埌鈥渦nsigned int鈥濓紝鍙兘涓㈠け鏁版嵁 + 姝e湪鐢熸垚浠g爜 + 2 of 33 functions ( 6.1%) were compiled, the rest were copied from previous compilation. + 0 functions were new in current compilation + 0 functions had inline decision re-evaluated but remain unchanged + 宸插畬鎴愪唬鐮佺殑鐢熸垚 + wuziqi.vcxproj -> C:\Users\灏樺焹\Desktop\wuziqi\wuziqi\Release\wuziqi.exe diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/CL.command.1.tlog b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/CL.command.1.tlog new file mode 100644 index 00000000..f15bc96e Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/CL.command.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/CL.read.1.tlog b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/CL.read.1.tlog new file mode 100644 index 00000000..f3efe6d5 Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/CL.read.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/CL.write.1.tlog b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/CL.write.1.tlog new file mode 100644 index 00000000..eb8a44a5 Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/CL.write.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/link.command.1.tlog b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/link.command.1.tlog new file mode 100644 index 00000000..fb56d64d Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/link.command.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/link.read.1.tlog b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/link.read.1.tlog new file mode 100644 index 00000000..0cce3da5 Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/link.read.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/link.write.1.tlog b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/link.write.1.tlog new file mode 100644 index 00000000..55281c4a Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/link.write.1.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/wuziqi.lastbuildstate b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/wuziqi.lastbuildstate new file mode 100644 index 00000000..df866a47 --- /dev/null +++ b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/wuziqi.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 +Release|Win32|C:\Users\灏樺焹\Desktop\wuziqi\wuziqi\| diff --git a/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/wuziqi.write.1u.tlog b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/wuziqi.write.1u.tlog new file mode 100644 index 00000000..c5281976 Binary files /dev/null and b/wuziqi/wuziqi/wuziqi/Release/wuziqi.tlog/wuziqi.write.1u.tlog differ diff --git a/wuziqi/wuziqi/wuziqi/wuziqi.vcxproj b/wuziqi/wuziqi/wuziqi/wuziqi.vcxproj new file mode 100644 index 00000000..ddca3542 --- /dev/null +++ b/wuziqi/wuziqi/wuziqi/wuziqi.vcxproj @@ -0,0 +1,197 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NotUsing + + + + + + + + + + 15.0 + {67F70508-6162-4266-A5B4-3C198D0A64B6} + Win32Proj + wuziqi + 10.0.17763.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/wuziqi/wuziqi/wuziqi/wuziqi.vcxproj.filters b/wuziqi/wuziqi/wuziqi/wuziqi.vcxproj.filters new file mode 100644 index 00000000..56d84c5d --- /dev/null +++ b/wuziqi/wuziqi/wuziqi/wuziqi.vcxproj.filters @@ -0,0 +1,126 @@ +锘 + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + \ No newline at end of file diff --git a/wuziqi/wuziqi/wuziqi/wuziqi.vcxproj.user b/wuziqi/wuziqi/wuziqi/wuziqi.vcxproj.user new file mode 100644 index 00000000..be250787 --- /dev/null +++ b/wuziqi/wuziqi/wuziqi/wuziqi.vcxproj.user @@ -0,0 +1,4 @@ +锘 + + + \ No newline at end of file