Skip to content

Instantly share code, notes, and snippets.

View oupo's full-sized avatar

oupo oupo

  • Japan
View GitHub Profile
/* emcc u64mul.cpp -o u64mul.js -s EXPORTED_FUNCTIONS="['_u64mul']" -g0 */
#include <stdio.h>
#include <stdint.h>
#include <emscripten.h>
typedef uint32_t u32;
typedef uint64_t u64;
extern "C" {
void u64mul(u32 ahi, u32 alo, u32 bhi, u32 blo, u32 *pc) {
// 日替わりseedで0x00000000に至るグラフを生成します
// see also raffle-seed-search.cpp
// https://gist.github.com/oupo/6271febe004f9fe7e036
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <assert.h>
#include <vector>
6c078965: 226 -1186 72 1462856 10.240
5d588b65: 1230 -253 -709 2079590 10.494
41c64e6d: 710 -825 167 1212614 10.105
00010dcd: -88 -52 1436 2072544 10.491
00010001: 1 -2 1 6 1.292
00010003: 9 -6 1 118 3.441
12345679: 89 -225 0 58546 7.919
11111111: -1 -15 0 226 3.910
require "myutil"
printf = function() end -- printfを呼ぶものはデバッグメッセージという扱い
IN_BATTLE = false
COUNT = 351
OK = nil
END = true
MOVIE_MODE = true
@oupo
oupo / npc.rb
Last active August 29, 2015 14:08
class LCG
def initialize(seed)
@seed = seed
end
def rand()
@seed = (@seed * 0x41c64e6d + 0x6073) % 2**32
@seed >> 16
end
end
#include <stdio.h>
#include <stdint.h>
typedef uint32_t u32;
/* x[0] = 0, x[n+1] = (a * x[n] + b) mod 2^k
で与えられる数列{x[n]}において、x[n] = sを満たすnを求める
ただし数列の周期は2^kになっていなければならない */
u32 calc_index(u32 a, u32 b, u32 s, u32 k) {
if (k == 0) {
パッチールの模様(DPtのグラフィック版)について
RSEのグラフィックでのパッチールの模様については以下を参照してください
http://www5.atwiki.jp/metamon/pages/34.html
http://no2.pic.bz/document/others.html
http://www.freewebs.com/gatorshark/Spinda%20Painter.htm
RSE版とはそれぞれのブチの左上座標と形が違うだけです。
パッチールのグラフィックは以下より取得できます。
// original: http://d.hatena.ne.jp/housuu2002/20091104/1257283619
//孵化乱数列の再現
//cf http://sou31.hp.infoseek.co.jp/pokemon/ran/ran_0.htm#6
#include <iostream>
#include <iomanip>
#include <cstring>
unsigned long mersenne(unsigned long FSeed){ //FSeed が初期Seed
function calc_trainer_id_by_seed(seed) {
var mt0 = seed >>> 0;
var mt1 = mul(1812433253, mt0 ^ (mt0 >>> 30)) + 1;
var mt2 = mul(1812433253, mt1 ^ (mt1 >>> 30)) + 2;
var mt_last = mt2;
for (var i = 3; i <= 398; i++) {
mt_last = mul(1812433253, mt_last ^ (mt_last >>> 30)) + i;
}
var value;
value = (mt1 & 0x80000000) | (mt2 & 0x7fffffff);
@oupo
oupo / msort.rb
Created March 4, 2010 02:48
http://codezine.jp/article/detail/2886 のプログラムをRubyに移植しました
#!ruby
# http://codezine.jp/article/detail/2886 のプログラムをRubyに移植しました
def main
merge_sort "input.txt", "result.txt"
end
def merge_sort(in_path, out_path)
open_multi([in_path, "rb"], [out_path, "wb"]) do |rf, wf|