随笔 - 1  文章 - 0  trackbacks - 0
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(3)

随笔档案

搜索

  •  

最新评论

共2页: 1 2 
H好长的对话
re: 英语网站(超全) pass86 2007-07-19 12:58
谢谢LZ,赞。
re: subversion服务器的配置 pass86 2007-07-12 22:31
推荐subversion,赞一个
re: VS9中C++少得可怜的更新 pass86 2007-07-12 21:55
用VS是用的它的IDE,一些库,如MFC,这是我看中的,至于编译器,我还是看中GCC,
re: mutable的用法 pass86 2007-07-11 12:53
mutalbe是否是是标准的关键字呢?在GCC中编译不过去。
re: UUID是什么? pass86 2007-07-09 13:59
hava a look.
re: 远程过程调用 pass86 2007-07-09 13:57
have a look.
re: IDL是什么? pass86 2007-07-09 13:57
hava a look
re: subversion安装配置记录 pass86 2007-07-06 23:00
在WINDOWS下怎么配置呢?TortoiseSVN在WINDOWS下的。
支持第二种。
re: do...while(0)的妙用 pass86 2007-07-06 22:52
赞一个。
赞一个。
re: 管理信息系统论文 pass86 2007-06-25 17:07
是否有其它论文啊,如软件工程的,我需要。
re: COM组件简介 pass86 2007-06-22 23:30
路过。
记得以前学习的时候用了回溯的算法。
偶有过。
re: 程序员的十种级别 pass86 2007-06-21 17:47
先当个工头也不错啊。
re: Qt4.2.3编译记录 pass86 2007-06-21 17:37
在学习列表中,支持。
英文比较好啊。
re: VC调试进阶(2)--多个exe pass86 2007-06-13 13:57
基本操作。
偶也考,努力。
。NET 2003,应该就没有。
估计PFnCreateObject creatorFuncTable[MAX_TYPE_ID];因该是
PFnCreateObject* creatorFuncTable[MAX_TYPE_ID];
re: boost1.34.0编译日志 pass86 2007-06-07 16:45
...updated 5279 targets...
re: boost1.34.0编译日志 pass86 2007-06-07 16:36
搞定,原来是我用的vsvars32.bat应该在一个控制台下完成,因为它只在当前控制台中设置的环境变量生效。
LIB下生成了216个项目,1.2G。
re: boost1.34.0编译日志 pass86 2007-06-07 14:00
bjam "sTOOLS=vc-7_1" --prefix=D:\Boost install
编译中无法找到windows.h

完成结果
...failed updateing 244 targets...
...skiped 228 targets...
...updated 1022 targets...

WHY?

LIB文件夹下有102个项目。
我用GCC编译不过去,
re: boost1.34.0编译日志 pass86 2007-06-06 22:26
我把/*?/去掉了,代会编译试试。
我编译了一次1.33.1,只是复制了些头文件到我的目标我的文件架,没有生成。LIB文件,是怎么回事情呢,用的是。NET 2003选项,能够给我发个
。NET2003的编译明命令行吗,谢谢。
pass86@gmail.com
恩,是个知识点,细致入微,
学到了。
你俩都学C++阿。
re: C++遗传算法源程序 pass86 2007-05-26 17:38
我也写过一点,从书上改编的。
/********************************************************************
Filename: aiWorld.h
Purpose: 遗传算法,花朵演化。
Author: pass86
E-mail: pass86@gmail.com
Created: 2007/03/29
Id:
Copyright:
Licence:
*********************************************************************/
#ifndef AIWORLD_H_
#define AIWORLD_H_

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>

#define kMaxFlowers 10

using std::cout;
using std::endl;

class ai_World
{
public:
ai_World()
{
srand(time(0));
}
~ai_World() {}

int temperature[kMaxFlowers]; //温度
int water[kMaxFlowers]; //水质
int sunlight[kMaxFlowers]; //阳光
int nutrient[kMaxFlowers]; //养分
int beneficialInsect[kMaxFlowers]; //益虫
int harmfulInsect[kMaxFlowers]; //害虫

int currentTemperature;
int currentWater;
int currentSunlight;
int currentNutrient;
int currentBeneficialInsect;
int currentHarmfulInsect;

/**
第一代花朵
*/
void Encode();

/**
花朵适合函数
*/
int Fitness(int flower);

/**
花朵演化
*/
void Evolve();

/**
返回区间[start, end]的随机数
*/
inline int tb_Rnd(int start, int end)
{
if (start > end)
return 0;
else
{
//srand(time(0));
return (rand() % (end + 1) + start);
}
}

/**
显示数值
*/
void show();
};
// ----------------------------------------------------------------- //
void ai_World::Encode()
// ----------------------------------------------------------------- //

{
int i;

for (i=0;i<kMaxFlowers;i++)
{
temperature[i]=tb_Rnd(1,75);
water[i]=tb_Rnd(1,75);
sunlight[i]=tb_Rnd(1,75);
nutrient[i]=tb_Rnd(1,75);
beneficialInsect[i]=tb_Rnd(1,75);
harmfulInsect[i]=tb_Rnd(1,75);
}

currentTemperature=tb_Rnd(1,75);
currentWater=tb_Rnd(1,75);
currentSunlight=tb_Rnd(1,75);
currentNutrient=tb_Rnd(1,75);
currentBeneficialInsect=tb_Rnd(1,75);
currentHarmfulInsect=tb_Rnd(1,75);

currentTemperature=tb_Rnd(1,75);
currentWater=tb_Rnd(1,75);
currentSunlight=tb_Rnd(1,75);
currentNutrient=tb_Rnd(1,75);
currentBeneficialInsect=tb_Rnd(1,75);
currentHarmfulInsect=tb_Rnd(1,75);

}
// ----------------------------------------------------------------- //
int ai_World::Fitness(int flower)
// ----------------------------------------------------------------- //

{
int theFitness;


theFitness=abs(temperature[flower]-currentTemperature);
theFitness=theFitness+abs(water[flower]-currentWater);
theFitness=theFitness+abs(sunlight[flower]-currentSunlight);
theFitness=theFitness+abs(nutrient[flower]-currentNutrient);
theFitness=theFitness+abs(beneficialInsect[flower]-currentBeneficialInsect);
theFitness=theFitness+abs(harmfulInsect[flower]-currentHarmfulInsect);

return (theFitness);

}
// ----------------------------------------------------------------- //
void ai_World::Evolve()
// ----------------------------------------------------------------- //

{
int fitTemperature[kMaxFlowers];
int fitWater[kMaxFlowers];
int fitSunlight[kMaxFlowers];
int fitNutrient[kMaxFlowers];
int fitBeneficialInsect[kMaxFlowers];
int fitHarmfulInsect[kMaxFlowers];
int fitness[kMaxFlowers];
int i;
int leastFit=0;
int leastFitIndex;

for (i=0;i<kMaxFlowers;i++)
if (Fitness(i)>leastFit)
{
leastFit=Fitness(i);
leastFitIndex=i;
}

temperature[leastFitIndex]=temperature[tb_Rnd(0,kMaxFlowers - 1)];
water[leastFitIndex]=water[tb_Rnd(0,kMaxFlowers - 1)];
sunlight[leastFitIndex]=sunlight[tb_Rnd(0,kMaxFlowers - 1)];
nutrient[leastFitIndex]=nutrient[tb_Rnd(0,kMaxFlowers - 1)];
beneficialInsect[leastFitIndex]=beneficialInsect[tb_Rnd(0,kMaxFlowers - 1)];
harmfulInsect[leastFitIndex]=harmfulInsect[tb_Rnd(0,kMaxFlowers - 1)];

for (i=0;i<kMaxFlowers;i++)
{
fitTemperature[i]=temperature[tb_Rnd(0,kMaxFlowers - 1)];
fitWater[i]=water[tb_Rnd(0,kMaxFlowers - 1)];
fitSunlight[i]=sunlight[tb_Rnd(0,kMaxFlowers - 1)];
fitNutrient[i]=nutrient[tb_Rnd(0,kMaxFlowers - 1)];
fitBeneficialInsect[i]=beneficialInsect[tb_Rnd(0,kMaxFlowers - 1)];
fitHarmfulInsect[i]=harmfulInsect[tb_Rnd(0,kMaxFlowers - 1)];
}

for (i=0;i<kMaxFlowers;i++)
{
temperature[i]=fitTemperature[i];
water[i]=fitWater[i];
sunlight[i]=fitSunlight[i];
nutrient[i]=fitNutrient[i];
beneficialInsect[i]=fitBeneficialInsect[i];
harmfulInsect[i]=fitHarmfulInsect[i];
}

for (i=0;i<kMaxFlowers;i++)
{
if (tb_Rnd(1,100)==1)
temperature[i]=tb_Rnd(1,75);
if (tb_Rnd(1,100)==1)
water[i]=tb_Rnd(1,75);
if (tb_Rnd(1,100)==1)
sunlight[i]=tb_Rnd(1,75);
if (tb_Rnd(1,100)==1)
nutrient[i]=tb_Rnd(1,75);
if (tb_Rnd(1,100)==1)
beneficialInsect[i]=tb_Rnd(1,75);
if (tb_Rnd(1,100)==1)
harmfulInsect[i]=tb_Rnd(1,75);
}

}
void ai_World::show()
{
// cout << "\t temperature water sunlight nutrient beneficialInsect harmfulInsect\n";
cout << "current\t " << currentTemperature << "\t " << currentWater << "\t ";
cout << currentSunlight << "\t " << currentNutrient << "\t ";
cout << currentBeneficialInsect << "\t " << currentHarmfulInsect << "\n";
for (int i=0;i<kMaxFlowers;i++)
{
cout << "Flower " << i << ": ";
cout << temperature[i] << "\t ";
cout << water[i] << "\t ";
cout << sunlight[i] << "\t ";
cout << nutrient[i] << "\t ";
cout << beneficialInsect[i] << "\t ";
cout << harmfulInsect[i] << "\t ";
cout << endl;
}
}
#endif // AIWORLD_H_

//test.cpp
#include <iostream>
#include "ai_World.h"

using namespace std;

int main()
{
ai_World a;
a.Encode();
// a.show();
for (int i = 0; i < 10; i++)
{
cout << "Generation " << i << endl;
a.Evolve();
a.show();
}

system("PAUSE");
return 0;
}
re: boost asio 2:threading pass86 2007-05-25 17:41
乱码显示源代码
re: C++模版全掌握(实例) pass86 2007-05-25 17:10
HAO.
re: 有一类程序员 pass86 2007-05-22 17:40
其实每个人不是一生下来就是高手。
这样的人我到遇到。
还是应该虚心学习。
不知道.a文件做什么的,在boost中看到,偶孤陋寡闻。
由此看来是库文件。
下下来看看,速度太慢。
VC6.0编译错误:
console.cpp(72) : fatal error C1010: unexpected end of file while looking for precompiled header directive
但是用其它IDE能编译成功,为什么呢?
这个东西真的挺有用的,DEBUG时用,不用MessageBox那么麻烦了。
re: 如何实现UI pass86 2007-05-08 13:49
UI的设计愈来愈重要,它能增强用户的体验,但是用过很多软件後发现,单纯的用图片来做UI并不大吸引人,有点死板。
Picasa2的UI做的就很好啊,用户的体验很好,不知怎么做的,貌似用了OPENGL。
共2页: 1 2