好的,所以我使用perl来读取包含一些常规配置数据的文件.这些数据根据它们的含义组织成标题.一个例子如下:
[vars]
# This is how we define a variable!
$var = 10;
$str = "Hello thar!";
# This section contains flags which can be used to modify module behavior
# All modules read this file and if they understand any of the flags, use them
[flags]
Verbose = true; # Notice the errant whitespace!
[path]
WinPath = default; # Keyword which loads the standard PATH as defined by the operating system. Append with additonal values.
LinuxPath = default;
Run Code Online (Sandbox Code Playgroud)
目标:使用第一行作为示例"$ …
我需要一些关于如何解决算法问题的建议(即不是编程本身).以下是我的需求以及我如何尝试满足它们.任何改进意见都会受到欢迎.
首先让我解释一下我的目标.我想玩一些扑克大约十亿次.也许我正在尝试创建下一个PokerStars.net,也许我只是疯了.
我想创建一个程序,可以产生更好的随机卡片组,而不是典型的程序调用random().这些需要是由高质量随机数创建的生产质量套牌.我听说商业级扑克服务器为每张卡使用64位向量,从而确保每天玩的数百万扑克游戏的随机性.
我想保留我写的简单的东西.为此,该计划只需要一个输入来实现既定目标.我已经决定,无论何时程序开始,它都会记录当前时间并将其作为起点.我意识到这种方法对于商业环境来说是不可行的,但只要能够支持几十亿游戏,比简单的替代方案更好,我会很高兴.
我开始编写伪代码来解决这个问题,但遇到了一个棘手的问题.这对我来说很清楚,但它可能不适合你,所以请让我知道.
Psuedo代码如下:
Start by noting the system time.
Hash the current time (with MD5) around ten times (I chose the ten arbitrarily).
Take the resulting hash, and use it as the seed to the language-dependent random() function.
Call random() 52 times and store the results.
Take the values produced by random() and hash them.
Any hash function that produces at least 64-bits of output will do for this.
Truncate (if the hash …Run Code Online (Sandbox Code Playgroud)