fujidig #4290(2007/11/21 13:17 GMT) [ 秀丸マクロ ] Rating1/1=1.00
乱数を発生させる関数がなかったのでそこから実装。
HSP ( #4289 ) と同じ結果になるように Visual C++ の rand と同じアルゴリズム・定数を使いました。 #4289 と乱数の種を同じにしたら同じ結果になるでしょう。 ( HSP の randomize の引数、秀丸マクロの srand サブルーチンの引数 )
see: 良い乱数・悪い乱数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
call srand tickcount; call bingo 10; call bingo 3; call bingo 3; call bingo 10; endmacro; bingo: ##i = 0; while( ##i < ##1 ) { ##dest[##i] = ##i + 1; ##i = ##i + 1; } ##i = 0; while( ##i < ##1 ) { call rand; ##r = ##return % ( ##1 - ##i ) + ##i; ##tmp = ##dest[##r]; ##dest[##r] = ##dest[##i]; ##dest[##i] = ##tmp; ##i = ##i + 1; } ##i = 0; while( ##i < ##1 ) { if ( ##i > 0 ) { insert " "; } insert str( ##dest[##i] ); ##i = ##i + 1; } insert "\n"; return; rand: #rand_x = #rand_x * 214013 + 2531011; if ( #rand_x < 0 ) { return ( ( #rand_x + 1 ) / 65536 - 1 ) & 32767; } return #rand_x / 65536 & 32767; srand: #rand_x = ##1; return;
Rating1/1=1.00-0+
[ reply ]
fujidig
#4290()
[
秀丸マクロ
]
Rating1/1=1.00
乱数を発生させる関数がなかったのでそこから実装。
HSP ( #4289 ) と同じ結果になるように Visual C++ の rand と同じアルゴリズム・定数を使いました。 #4289 と乱数の種を同じにしたら同じ結果になるでしょう。 ( HSP の randomize の引数、秀丸マクロの srand サブルーチンの引数 )
see: 良い乱数・悪い乱数
call srand tickcount; call bingo 10; call bingo 3; call bingo 3; call bingo 10; endmacro; bingo: ##i = 0; while( ##i < ##1 ) { ##dest[##i] = ##i + 1; ##i = ##i + 1; } ##i = 0; while( ##i < ##1 ) { call rand; ##r = ##return % ( ##1 - ##i ) + ##i; ##tmp = ##dest[##r]; ##dest[##r] = ##dest[##i]; ##dest[##i] = ##tmp; ##i = ##i + 1; } ##i = 0; while( ##i < ##1 ) { if ( ##i > 0 ) { insert " "; } insert str( ##dest[##i] ); ##i = ##i + 1; } insert "\n"; return; rand: #rand_x = #rand_x * 214013 + 2531011; if ( #rand_x < 0 ) { return ( ( #rand_x + 1 ) / 65536 - 1 ) & 32767; } return #rand_x / 65536 & 32767; srand: #rand_x = ##1; return;Rating1/1=1.00-0+
[ reply ]