Javascript random ordering with seed

后端 未结 4 1843
故里飘歌
故里飘歌 2021-01-02 09:47

I want to randomly shuffle a list of 4 items but with a seed so that so long as you have the same seed the you will get the same order of items.

[\"a\", \"b\         


        
4条回答
  •  生来不讨喜
    2021-01-02 10:41

    You can create random numbers to do the sorting using the XOR Shift method. Example. Then just replace Math.random() in your old code with new Xor128(seed).make(3)[2] / 4294967296 * 2

提交回复
热议问题