OSDN Git Service

Math.randomを独自の関数で上書き、アルゴリズムをメルセンヌ・ツイスタに変更
authorh2so5 <h2so5@git.sourceforge.jp>
Tue, 16 Oct 2012 10:54:47 +0000 (19:54 +0900)
committerh2so5 <h2so5@git.sourceforge.jp>
Tue, 16 Oct 2012 10:54:47 +0000 (19:54 +0900)
client/ScriptEnvironment.cpp
client/ScriptEnvironment.hpp
client/stdafx.h

index e75fd35..b0d5ed6 100644 (file)
Binary files a/client/ScriptEnvironment.cpp and b/client/ScriptEnvironment.cpp differ
index 741168a..9fdc3ef 100644 (file)
@@ -7,6 +7,7 @@
 #include <string>
 #include <functional>
 #include <memory>
+#include <random>
 #include <v8.h>
 #include <boost/thread.hpp>
 #include <boost/timer.hpp>
@@ -77,6 +78,8 @@ class ScriptEnvironment {
         static Handle<Value> Function_Script_clearTimeout(const Arguments& args);
         static Handle<Value> Function_Script_clearInterval(const Arguments& args);
 
+        static Handle<Value> Function_Math_random(const Arguments& args);
+
     private:
         void Error(const Handle<Value>& error);
 
@@ -92,6 +95,8 @@ class ScriptEnvironment {
         boost::condition_variable condition_;
         boost::mutex mutex_;
 
+               static std::mt19937 random_engine;
+
         static unsigned int max_execution_time;
         static char SCRIPT_PATH[];
 
index 234ec3b..16e2a41 100644 (file)
@@ -47,6 +47,7 @@
 #include <array>
 #include <string>
 #include <memory>
+#include <random>
 #include <iostream>
 #include <fstream>
 #include <algorithm>