今天精神状态不好,和公司的领导请了假。为了抵抗我的痛苦,我在床上打坐冥想,从早上九点到下午三点二十六。嗯,感觉好多了。这种温和的暴力果然有效。

  之后吃了点东西,然后无聊的我就在想,明天的工作该做些什么。

  我的自定义时间系统还没有做完。

  我设想的是另一个世界的时间,我把秒,分钟以及小时,天,年都重新定义了一次。那么就把新定义的“秒”叫做“Selee”吧。类似的:

  秒:Selee,相当于现实世界的1200毫秒

  刻:Qulee,100 x Selee

  时:Hulee,3000 x Selee

  天:Dalee,21 x Hulee - 57 x Selee

  月:Molee,40 x Dalee

  年:Yelee, 398 x Dalee

  上面提到的57是要被修改的,因为我要实现闰年的概念。我计算过那个误差到底多少才合适,但是让我忘了。

  所以呢?这有什么用?没有用!

  总是有人一而再再而三地问“你写这个有什么用”。难道一定要有用的东西我才去弄吗?活着有什么用?没有用,因为你早晚得死,所以你为什么不去死?没有意义才是真正的意义。这是一个无法反驳的宇宙真理。

  一旦思维的石墙遇到了崩塌,那么就会看见更多没有意义的事。这种崩塌一次又一次带给了我惊喜,尽管这种惊喜没能给我的生活质量带来任何的提升。那么时间已经存在了,是不是应该创建“物体”的概念了?

是的,我说得没错。

  现实中的物品拥有的属性太多了,根本不是这幼稚的计算机能够模拟出来的。人也是个 物体,但特殊在人拥有感情,判断力,就是一个移动的弱智版计算机。但话说回来,无论所谓的感情和思想有多么得神圣和神奇,说到底都是由激素等物质决定的。

  而类似于这种影响性格和判断分支的物体,用一组动态参数控制再好不过了。比如一个人出去嫖被染了性病并幸运地治好了,那么他以后就不敢像以前那么放肆地嫖了。

  但现实中真的有那种“我就不信了我还能中奖”的人,那说明他的“倔强”参数比较高。

  类似石头等静态物品随机投放。那么就算是随机的,也不能是完全随机,这是偏向“集群”的。好吧,给一个柏林噪音好了。

  随机数谁给的。。。

  这里,必须创建一个“GodHand”类。我总有一种感觉,这个世界真的是有“上帝之手”存在,也许是我对大自然能够自我进化得如此神奇感到怀疑。

  OK,我觉得我可以把基础类和枚举创建出来了。

  首先,属性枚举。

  这里的重点是生物,不同的生物拥有的属性种类数量并不相同。其中,人类的脑回路更加难以预测,除了与其他生物相同的求生欲望和食物需求之外,精神需求是一大特点。

  其次,影响属性的事件枚举。

  每个生物遭遇的的事件和受到的影响力各不相同。事件根本无法枚举。那么可以使用一个统一的方式来模拟事件。我可以随机一个事件,这个事件带来的影响是,如果目标生物成功完成了这个事件,那么他会得到这个事件提供的属性变化,否则,会带来另一个变化。

举个例子。我现在创建了一个事件,这个事件的影响是对物体A的恐惧感+13,生物通常属性中的“胆量”-16。你可  以把这个事件想象成一只狗尝试去闻一个即将爆炸的爆竹(麻雷子知道是什么吗?),也可以认为是一只狗尝试吃一个柠檬。

  一只狗执行了这个事件可以认为只有一种结果,也就是说这只狗受到此事件带来的影响概率为100%。而对于人类或其他较高智慧的生物而言,这个事件带来的影响更加复杂,可能需要一个“提供参数”来支持事件的成功与否,并且需要一个服从正态分布的随机数来生成一个影响结果。就像最上面说的例子,一个十分“倔强”的人接着去嫖的概率是63%,那么一个比较“倔强”的人可能是34.32%。

  从此能看出,人与狗的区别之一在于:狗拥有的“倔强”属性上限相对于人类要低得多。如果要降低系统的复杂性,可以简单地认为狗没有倔强属性。

  另外,事件也分为主动事件和被动事件。

  这个比较容易理解。比如一个生物枚举类型为“人类”的物体,随着时间的增长,他的“异性追求欲望”会随之改变,当然,时间流逝的过程中他会执行其他事件,这有可能导致他“同性恋”、“异性恋”、“无性恋”、“双性恋”都有可能。假设结果是他找到了一个配偶BZ,然而是他追的BZ还是BZ追的他呢?

  身体不好并且“珍惜生命”属性正常并且“懒惰”属性不是偏低的人会主动寻找增加“健康”的事件来执行;喜欢旅行的人会被动地执行更多事件,而由于自身拥有通常属性的缘故,执行的事件结果会逐渐向某一侧发展,这可能会导致这个喜爱旅行的人某一项属性异常得高。这挺符合现实规律的。

  第三,属性关联。

  这部分我还没有想好,我不知道此功能是否有存在的必要,或者用其他的方式来代替。暂时想到的点子是将属性进行归类,这样属性之间的联系就非常清晰了。

  现在,我把瞎写的自定义时间系统先记下来。以后的东西没事就瞎琢磨琢磨。

TileeCfg.h

#include <stdint.h>
#include <array> #pragma once const int16_t OneSelee = 1200;
const int16_t Selee = OneSelee;
const int16_t Qulee = 100 * 1/*Selee*/;
const int32_t Holee = 30 * Qulee;
const int64_t Dalee = 21 * Holee;
const int16_t Deviation = +1 * 79 * 1/*Selee*/; //Dalee + Deviation is actual.
const int8_t LeapDay = 1;
const int64_t Yelee = 398 * Dalee; const int8_t MoleeCountEveryYelee = 10;
typedef std::array<int8_t, MoleeCountEveryYelee> MoleeType;
const MoleeType Molee = { 39, 39, 40, 40, 40, 40, 40, 40, 40, 40/*Dalee*/ };
const MoleeType LeapMolee = { 39, 39, 40, 40, 39, 40, 40, 40, 40, 40 }; //check Molee
const auto TotalDalees = [](const MoleeType& moleeDef, bool isLeap) -> bool
{
int total = 0;
for (int8_t delees : moleeDef)
{
total += delees;
} switch (isLeap)
{
case false:
return total == (Yelee / Dalee);
case true:
return total == (-1 * (Deviation / std::abs(Deviation)) * LeapDay + Yelee / Dalee);
}
return false;
}; const int64_t TileeStampStart_ms = 1325347200000; //2012-01-01 00:00:00
const int16_t BaseYelee = 680; //2E680: SPARK.

其中出现的 //2E680: SPARK. 是我写的小说中的大事件之一:第二纪元的680年:星火。

Tilee.h

#include "stdinc.h"
#include "TileeCfg.h"
#pragma once
namespace Lunacia
{ class Tilee final
{
public:
Tilee();
~Tilee(); public:
struct TileeInfo
{
public:
TileeInfo()
{
} TileeInfo(int16_t yelee, int8_t molee, int16_t dalee, int32_t holee, int64_t qulee, int64_t selee) :
yelee(yelee),
molee(molee),
dalee(dalee),
holee(holee),
qulee(qulee),
selee(selee)
{
} friend std::ostream& operator<<(std::ostream &out, const TileeInfo &ti)
{
//std::string strInfo;
//TileeInfo::GetInfoString(strInfo, ti);
out << ti.yelee << '/' << ti.molee << '/' << ti.dalee << ' ' << ti.holee << ':' << ti.qulee << ':' << ti.selee;
return out;
} public:
int16_t yelee = 0;
int8_t molee = 1;
int16_t dalee = 1;
int32_t holee = 0;
int64_t qulee = 0;
int64_t selee = 0;
}; public:
static void TimeSync(int64_t* const __out tileeStamp, const int* const __in syncPeriod); int64_t GetSeleeStamp() const;
void SetSyncPeriod(int syncPeriod);
void GetTileeInfo(TileeInfo& tileeInfo); private:
void SetTileeInfo();
inline int8_t GetPeriodYelee() const; public:
void GetTileeString(std::string& strInfo);
void GetTileeString(std::wstring& strInfo); private:
int64_t m_TileeStamp;
TileeInfo m_tileeInfo; int m_syncPeriod;
}; };

Tilee.cpp

#include "Tilee.h"
namespace Lunacia
{
Tilee::Tilee()
{
m_syncPeriod = 100;
m_TileeStamp = 0; if (!(TotalDalees(Molee, false) && TotalDalees(LeapMolee, true)))
{
ErrorThrow("Molee Define Error.");
return;
}
std::thread t(Tilee::TimeSync, &m_TileeStamp, &m_syncPeriod);
t.detach();
} Tilee::~Tilee()
{ } void Tilee::TimeSync(int64_t* const __out tileeStamp, const int* const __in syncPeriod)
{
while (true)
{
auto timeNow_ms =
std::chrono::system_clock::now().time_since_epoch() - \
std::chrono::milliseconds(TileeStampStart_ms); *tileeStamp =
std::chrono::duration_cast<std::chrono::milliseconds>(timeNow_ms).count() / \
OneSelee; Sleep(*syncPeriod);
}
} int64_t Tilee::GetSeleeStamp() const
{
return m_TileeStamp;
} void Tilee::SetSyncPeriod(int syncPeriod)
{
m_syncPeriod = syncPeriod;
} //If the return value is greater than zero,
//it means that each cycle has more passed through "LeapDay" days,
//and vice versa.
inline int8_t Tilee::GetPeriodYelee() const
{
return LeapDay * Dalee / (398 * Deviation);
} void Tilee::SetTileeInfo()
{
int8_t periodYelee = std::abs(GetPeriodYelee());
int64_t periodSelee = (periodYelee * 398 + LeapDay) * Dalee; int64_t remainSelee = (m_TileeStamp % periodSelee) % Yelee; //Remaintion Selee Of A Yelee . int curYelee = m_tileeInfo.yelee = static_cast<int16_t>(m_TileeStamp / periodSelee * periodYelee + 1 + BaseYelee);
bool isLeapYelee = curYelee % periodYelee == 0;
const MoleeType& curMoleeArray = (isLeapYelee) ? LeapMolee : Molee; int64_t throughSelees = 0; for (int8_t i = 0; i < MoleeCountEveryYelee; i++)
{
int8_t dalees = curMoleeArray[i];
throughSelees += dalees * Dalee;
if (remainSelee >= throughSelees)
{
continue;
}
throughSelees -= dalees * Dalee; m_tileeInfo.molee = i + 1; remainSelee = remainSelee - throughSelees;
m_tileeInfo.dalee = static_cast<int16_t>(remainSelee / Dalee + 1); remainSelee = remainSelee % Dalee;
m_tileeInfo.holee = static_cast<int32_t>(remainSelee / Holee); remainSelee = remainSelee % Holee; m_tileeInfo.qulee = remainSelee / Qulee;
m_tileeInfo.selee = remainSelee % Qulee; break;
} } void Tilee::GetTileeInfo(TileeInfo& tileeInfo)
{
SetTileeInfo();
tileeInfo = m_tileeInfo;
} void Tilee::GetTileeString(std::string& strInfo)
{
TileeInfo tiInfo;
GetTileeInfo(tiInfo);
strInfo = std::to_string(m_tileeInfo.yelee) + "/" + std::to_string(m_tileeInfo.molee) + "/" + std::to_string(m_tileeInfo.dalee) + " " +
std::to_string(m_tileeInfo.holee) + ":" + std::to_string(m_tileeInfo.qulee) + ":" + std::to_string(m_tileeInfo.selee);
} void Tilee::GetTileeString(std::wstring& strInfo)
{
TileeInfo tiInfo;
GetTileeInfo(tiInfo);
strInfo = std::to_wstring(m_tileeInfo.yelee) + L"/" + std::to_wstring(m_tileeInfo.molee) + L"/" + std::to_wstring(m_tileeInfo.dalee) + L" " +
std::to_wstring(m_tileeInfo.holee) + L":" + std::to_wstring(m_tileeInfo.qulee) + L":" + std::to_wstring(m_tileeInfo.selee);
} };

以上文件归属于同一个项目A, 项目配置类型为“静态库 .lib”.

以下为测试项目B(MFC,项目名MFC_Tilee),并引用项目A。两者字符集都设置为多字符集。

MFC_Tilee.h

CMFCTileeApp 类中 引入头文件 #include "../Lunacia/Tilee.h"
CMFCTileeApp 类中 public 成员变量添加 Lunacia::Tilee ti;

MFC_TileeDlg.cpp

对话框初始化函数 BOOL CMFCTileeDlg::OnInitDialog(); 中添加 SetTimer(0, 6, NULL); 并在类视图属性中添加 WM_TIMER 消息。
void CMFCTileeDlg::OnTimer(UINT_PTR nIDEvent)
{
std::string tileeInfo;
theApp.ti.GetTileeString(tileeInfo);
EditTilee.SetWindowText(tileeInfo.c_str()); UpdateData(FALSE);
CDialogEx::OnTimer(nIDEvent);
}

不知道为什么,同样的代码在VS2013中,对话框很顺畅,然而在2017中却偶尔出现闪烁。

感叹自己,曾希望自己成为一个天才,而今却是一只疯子。

最新文章

  1. HTTP常见头域
  2. msysgit之git bash方便的复制粘贴,默认工作目录,窗口大小,提高速度等小窍门
  3. Java栈的实例模拟
  4. 09_Sum游戏(UVa 10891 Game of Sum)
  5. Java常用排序算法+程序员必须掌握的8大排序算法
  6. Brute-force Algorithm_矩阵快速幂&amp;&amp;欧拉公式*****
  7. LeetCode Maximum Product Subarray 解题报告
  8. SQL Server索引进阶:第十三级,插入,更新,删除
  9. 基于Redis Sentinel的Redis集群(主从Sharding)高可用方案(转)
  10. Java Servlet 笔记3
  11. Vue2学习(1)
  12. MS SQL Server 2008 R2 常规操作
  13. vue 图片加载失败调用
  14. pytest九:使用自定义标记 mark
  15. Asp.Net中使用Couchbase——Memcached缓存入门篇
  16. 关于IntelliJ IDEA 文档无法编辑的解决办法
  17. OpenGL实现相机视频NV21格式转RGB格式
  18. getline的字符串读入
  19. bzoj 2282 消防
  20. [CF864F]Cities Excursions

热门文章

  1. wifi编辑 centos
  2. jquery slideDown 控制div出现的方向
  3. Mac下安装证书fiddlerRoot.cer
  4. for循环:用turtle画一颗五角星2
  5. java版数据结构与算法 (1综述)
  6. 运维shell全部语法进阶
  7. shell 统计字符串 字符个数
  8. 【5】用vector进行直接插入排序
  9. asp.net,根据gridview 中checkbox复选框选中的行对数据库进行操作
  10. Spring 注入集合