Re: [vim/vim] add rand(), srand() (#1277)
Yegappan Lakshmanan wrote: > >> Mines.vim, which generates a minefield, does so using a pseudo-random >> number generator (which comes with it, btw, since I wrote that in vim). >> > I leveraged your pseudo-random number generator for the battleship > game Vim plugin. (https://github.com/yegappan/battleship). > > - Yegappan > Thank you, Yegappan, for telling me! Chip -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [vim/vim] add rand(), srand() (#1277)
Hi, On Thu, Jun 15, 2017 at 1:00 PM, Charles E Campbellwrote: > Bram Moolenaar wrote: >> >> Yasuhiro Matsumoto wrote: >> >> > This add Xorshift random generator. In general implementation, srand() >> > may be called from some plugins in several times. So it need to have >> > statefull random generator like Xorshift. Below is an usage of >> > srand(). >> > >> > ```vim >> > :echo srand() >> > [123456789, 362436069, 521288629, 88675123] >> > :echo srand(-1) >> > [1479837050,, 362436069, 521288629, 88675123] >> > :echo srand(2) >> > [2, 362436069, 521288629, 88675123] >> > ``` >> > srand return four numbers as list. When expr is not given, the x >> element of xorshift become 123456789. When negative number is given, x >> become time(NULL). When positive number is given, x become it given. >> > >> > Below is an usage of rand() >> > >> > ```vim >> > let a = srand() >> > :echo rand(a) >> > 597902826 >> > :echo rand(a) >> > 458295558 >> > :echo rand(a) >> > 1779455562 >> > :echo rand(a) >> > 663552176 >> > :echo rand(a) >> > 507026878 >> > ``` >> >> What plugin needs a pseudo-random number generator? > Mines.vim, which generates a minefield, does so using a pseudo-random > number generator (which comes with it, btw, since I wrote that in vim). > I leveraged your pseudo-random number generator for the battleship game Vim plugin. (https://github.com/yegappan/battleship). - Yegappan -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [vim/vim] add rand(), srand() (#1277)
Bram Moolenaar wrote: > > Yasuhiro Matsumoto wrote: > > > This add Xorshift random generator. In general implementation, srand() > > may be called from some plugins in several times. So it need to have > > statefull random generator like Xorshift. Below is an usage of > > srand(). > > > > ```vim > > :echo srand() > > [123456789, 362436069, 521288629, 88675123] > > :echo srand(-1) > > [1479837050,, 362436069, 521288629, 88675123] > > :echo srand(2) > > [2, 362436069, 521288629, 88675123] > > ``` > > srand return four numbers as list. When expr is not given, the x > element of xorshift become 123456789. When negative number is given, x > become time(NULL). When positive number is given, x become it given. > > > > Below is an usage of rand() > > > > ```vim > > let a = srand() > > :echo rand(a) > > 597902826 > > :echo rand(a) > > 458295558 > > :echo rand(a) > > 1779455562 > > :echo rand(a) > > 663552176 > > :echo rand(a) > > 507026878 > > ``` > > What plugin needs a pseudo-random number generator? Mines.vim, which generates a minefield, does so using a pseudo-random number generator (which comes with it, btw, since I wrote that in vim). Regards, Chip Campbell -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.