博文

五子棋AI(II)(2005-08-07 11:03:00)

摘要:(3)    给出下了一个子后的分数:
int CMyChessDlg::GiveScore(int type, int x, int y)
{
        int i,score=0;
    for(i=0;i<572;i++)
    {
        //计算机下
        if(type==1)
        {
            if(ctable[x][y][i])
            {
                switch(win[1][i])
                {
                case 1:
           &nb......

阅读全文(2991) | 评论:0

五子棋的AI(I)(2005-08-07 11:02:00)

摘要:  “五子棋”软件设计报告
杭州电子科技大学 胡峰令
   在本次“五子棋“程序的编写中,只编写了人机对弈部分,运用了博弈树进行搜索,在选取最优的走步时使用极大极小分析法,考虑到搜索的时间复杂度和空间复杂度,在程序中只进行了2步搜索,即计算机在考虑下一步的走法时,只对玩家进行一步的推测。(程序中的棋盘规格为15*15)
   下面对具体做法进行描述:
1.    数据结构定义:
棋盘定义:int board[15][15];
在15*15的棋盘上,获胜的情况总共有572种,
如:
*    *    *    *    *    ……
……    ……    ……    ……    ……    ……
……    ……    ……    ……    ……    ……
……    ……    ……    ……    ……    ……
……    ……    ……    ……    ……  &nb......

阅读全文(5507) | 评论:1

QQ好友管理程序(2005-08-07 10:47:00)

摘要:#include "stdio.h"
#include "conio.h"

struct qq
{
char num[12];
char name[10];
char age[2];
}Qq[1];
main()
{
int kk=1;char choice;
loop2 : init();
loop : scanf("%c",&choice);
switch(choice)
{
case 'n': case 'N': newf();break;
case 'a': case 'A': break;
case 'l': case 'L': system("cls");listf();getch();system("cls");goto loop2;
case 'f': case 'F': findf();getch();goto loop2;
case 'd': case 'D': deletef();getch();goto loop2;
case 'q': case 'Q': return 0;
default: goto loop;
}
while(kk==1)
{
addf();
printf("enter 1 to continue add.\n");
scanf("%d",&kk);
system("cls");
}
goto loop2;
}


int init()
{
printf("\n**************************************\n");
printf("******第一次用本程序请按n(new)********\n");
printf("*********增加记录请按a(add)......

阅读全文(5207) | 评论:1

成绩系统(2005-08-07 10:37:00)

摘要:#include <iostream.h>
#include <string.h>
#include <fstream.h>

struct student
{
char num[10];
char name[20];
int  age;
int  score;
struct student *next;
};
class grade
{
private :
    struct student * head,* last;    
public :
    void init();
    void insert();
    int delete();
    int select();
    int modify();
    int display();
    int total();
    void savefile();
    void quit();
};

void grade::init()
{
printf("************************************主菜单************************************\n");
printf("\t1输入学生资料\t\t\t\t\t2删除学生资料\n");
printf("\t3查询学生资料\t\t\t\t\t4修改学生资料\n"......

阅读全文(3883) | 评论:0

聊天(C++)(2005-08-07 10:33:00)

摘要:1  局域网聊天的程序(C++版)  
  //server
#include <winsock.h>
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
#define PORT 100
#define socklen_t int
#pragma comment(lib, "wsock32.lib")
SOCKET s;
SOCKET client;
sockaddr_in from;
void ServerThread()
{
char message[256];
while(1)
{
strcpy(message,"");
int len=recv(client,message,sizeof(message),0);
if (strcmp(message,"")!=0)
{
cout<<"从"<<inet_ntoa(from.sin_addr)<<"得到消息:\n";
//cout<<"len:"<<len<<endl;
message[len]='\0';
cout<<message;
}
}
}
int main()
{
sockaddr_in srv;
int fromlen=sizeof(from);
char message[256]="Welcome!\n";
WSADATA wsadata;
WORD VersionRequested=MAKEWORD(1,1);
if (WSAStartup(VersionRequ......

阅读全文(5381) | 评论:1