10種類のカードをコンプするのにかかるガチャ回数の分布をSqueak Smalltalkで

コンプガチャのヤバさ加減 が面白かったので Squeak Smalltalk でも書いて試してみました。Smalltalk の Bag というのは C++ でいうところの multiset です(逆ですが^^;)。

| hist cards |
hist := Bag new.
cards := 1 to: 10.

1000 timesRepeat: [
   | player |
   player := Bag new.
   [player add: cards atRandom; includesAllOf: cards] whileFalse.
   hist add: player size].

World findATranscript: nil.
hist sortedElements do: [:each |
   Transcript cr; show: each key printString, ':'.
   Transcript space; show: (String new: each value withAll: $#)]
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: #########
44: #########
45: ########
46: ####
47: #####
48: ####
49: ####
50: #######
51: #####
52: ###
53: ####
54: ###
55: #######
56: #####
57: ###
58: ##
59: ##
60: #
61: ##
62: ####
63: ###
64: #
65: ##
66: #
67: #
69: ##
71: #
72: #
75: ##
76: ###
77: #
83: #
89: #