j***u 发帖数: 836 | 1 要交CS作业、小project什么的同学有福了。抄抄我这个就可以对付了。
为了看清楚电脑是怎么发牌的,我用Perl语言编了以下这个小程序。
不会编程的同学,只要在自己电脑上安装有Perl(可以免费下载和安装,3分钟的事,见
后),就可以运行我的程序玩。
这个程序的核心在于$random_number = int(rand(34));
搞到1个在0和33之间的伪随机数。然后根据0到33各代表哪张麻将牌发出麻将。
程序先用了时间作种子。
$seed = time();
srand($seed);
根据网上资料,Perl的srand不可在循环里反复被call,否则反而带来重复。
用Windows的同学,先在右下角Start的命令里打cmd(或All Programs>Accessaries>
Command Promopt)打开Command窗口,打Perl -v看看有无Perl程序。没有的话google "
how to install Perl"之类。我建议免费下载并安装ActivePerl,然后copy & paste我
以下的源程序到1个text editor比如Notepad或WordPad.把文件存成1个Perl file,比如
PlayMe.pl,注意扩展名一定得是pl就行了。
然后,在Command窗口里cd到你刚才存文件的地方,比如,你如果刚才存在C:\
Users\hqtzjz1, 在Command窗口里,你就打cd C:\Users\hqtzjz1
然后,打出那文件名加回车键就运行了,比如:PlayMe.pl
我运行了多次,发现我的程序比老邢的随机数要好些,但对子数目的确还是多,而且,
的确有不少连着上牌的现象。这种连着上牌分俩种:一是连续发俩张同样的牌,你和上
下家一人一手;另一种是,你下一次(隔了4张牌)抓到同样的牌,即某个特定的人连
抓俩张。
你们多玩几次这个程序,可以得出相同结论。(在5楼有重要结论)
未名麻将虽然几乎可以肯定不是用Perl语言编的,但各种计算机语言是大同小异的。可
以肯定的是,买买提的程序也没比我这个把小时搞出来的东东高明到哪里去。只要没用
更好的更高级的随机方程,发出来的牌和这个小程序的也就差不多吧。
源程序如下:
#!/usr/bin/perl
$seed = time();
srand($seed);
### assign numbers for all of the 34 Mahjong tiles
%mahjongTiles = (
## Number 0 is Zhong (Middle)
0 => "Zhong",
## Number 1 is Fa
1 => "Fa",
## Number 2 is Bai (Blank)
2 => "Bai",
## Numbers 3 - 6 are East, South, West, North
3 => "East",
4 => "South",
5 => "West",
6 => "North",
## Numbers 7 - 15 are Wan's
7 => "1_Wan",
8 => "2_Wan",
9 => "3_Wan",
10 => "4_Wan",
11 => "5_Wan",
12 => "6_Wan",
13 => "7_Wan",
14 => "8_Wan",
15 => "9_Wan",
## Numbers 16 - 24 are Tiao's
16 => "1_Tiao",
17 => "2_Tiao",
18 => "3_Tiao",
19 => "4_Tiao",
20 => "5_Tiao",
21 => "6_Tiao",
22 => "7_Tiao",
23 => "8_Tiao",
24 => "9_Tiao",
## Numbers 25 - 33 are Bing's
25 => "1_Bing",
26 => "2_Bing",
27 => "3_Bing",
28 => "4_Bing",
29 => "5_Bing",
30 => "6_Bing",
31 => "7_Bing",
32 => "8_Bing",
33 => "9_Bing"
);
# use %allNumbers to keep track of how many tiles of a kind
# have been out there for all the tiles
# in order to make sure not more than 4 for each kind are out
%allNumbers = ();
# initiate all the counts to 0
foreach $k (sort{$a <=> $b} keys %mahjongTiles) {
$allNumbers{$k} = 0;
}
# use %numbersForA to keep track of how many tiles for each kind
# have been given to Player A
# in order to count how many pairs
# (including 3 and 4 pieces) Paly A gets
%numbersForA = ();
# initiate all the counts to 0
foreach $k (sort{$a <=> $b} keys %mahjongTiles) {
$numbersForA{$k} = 0;
}
# use %numbersForB to keep track of how many tiles for each kind
# have been given to Player B
# in order to count how many pairs
# (including 3 and 4 pieces) Paly B gets
%numbersForB = ();
# initiate all the counts to 0
foreach $k (sort{$a <=> $b} keys %mahjongTiles) {
$numbersForB{$k} = 0;
}
# use %numbersForC to keep track of how many tiles for each kind
# have been given to Player C
# in order to count how many pairs
# (including 3 and 4 pieces) Paly C gets
%numbersForC = ();
# initiate all the counts to 0
foreach $k (sort{$a <=> $b} keys %mahjongTiles) {
$numbersForC{$k} = 0;
}
# use %numbersForD to keep track of how many tiles for each kind
# have been given to Player D
# in order to count how many pairs
# (including 3 and 4 pieces) Paly C gets
%numbersForD = ();
# initiate all the counts to 0
foreach $k (sort{$a <=> $b} keys %mahjongTiles) {
$numbersForD{$k} = 0;
}
$ctPairsForA = $ctPairsForB = $ctPairsForC = $ctPairsForD = 0;
### start the game;
### there are total of 136 pieces to give out;
### so there are 136 rounds to give 1 tile per round
for ($round = 1; $round <= 136; $round++) {
## **** key statement here: get the random number [0 to 33] **
$random_number = int(rand(34));
## whenever total number of the same tiles given out is
## more than 4, redo it -- get a random number again
while ($allNumbers{$random_number} >= 4) {
## **** key statement here: get the random number [0 to 33]
$random_number = int(rand(34));
}
## the 4 players take turns to get the random number
$playerId = ($round - 1) % 4;
if ($playerId == 0) { ### player A
$numbersForA{$random_number}++;
$allNumbers{$random_number}++;
$ctPairsForA++ if $numbersForA{$random_number} == 2;
} elsif ($playerId == 1) { ### player B
$numbersForB{$random_number}++;
$allNumbers{$random_number}++;
$ctPairsForB++ if $numbersForB{$random_number} == 2;
} elsif ($playerId == 2) { ### player C
$numbersForC{$random_number}++;
$allNumbers{$random_number}++;
$ctPairsForC++ if $numbersForC{$random_number} == 2;
} elsif ($playerId == 3) { ### player D
$numbersForD{$random_number}++;
$allNumbers{$random_number}++;
$ctPairsForD++ if $numbersForD{$random_number} == 2;
} else { ## not possible to have player number
## as anything other than 0, 1, 2, 3
print "nProgram mistake....exit....nn";
exit;
}
# round 53 is when every player already has a set of 13
# (13 times 4 = 52), marked as "At start (Qi3 Shou3)"
if ($round == 53) {
print "At start (Qi3 Shou3)n";
print "--------------------------------------------n";
## print the start set for player A
print "A: ";
foreach $k (sort{$a <=> $b} keys %mahjongTiles) {
if ($numbersForA{$k} > 0) {
for ($i = 1; $i <= $numbersForA{$k}; $i++) {
print "$mahjongTiles{$k}|"
}
}
}
## print the start set for player B
print "nB: ";
foreach $k (sort{$a <=> $b} keys %mahjongTiles) {
if ($numbersForB{$k} > 0) {
for ($i = 1; $i <= $numbersForB{$k}; $i++) {
print "$mahjongTiles{$k}|"
}
}
}
## print the start set for player C
print "nC: ";
foreach $k (sort{$a <=> $b} keys %mahjongTiles) {
if ($numbersForC{$k} > 0) {
for ($i = 1; $i <= $numbersForC{$k}; $i++) {
print "$mahjongTiles{$k}|"
}
}
}
## print the start set for player D
print "nD: ";
foreach $k (sort{$a <=> $b} keys %mahjongTiles) {
if ($numbersForD{$k} > 0) {
for ($i = 1; $i <= $numbersForD{$k}; $i++) {
print "$mahjongTiles{$k}|"
}
}
}
## print number of pairs for each player at beginning of game
print "nnNumber of pairs so far (2+ same mahjongTiles)n";
print "---------------------------------------------------n";
print "At$ctPairsForAnBt$ctPairsForBnCt";
print "$ctPairsForCnDt$ctPairsForDnnn";
print "nn#tAtBtCtDn";
print "---------------------------------------------------n";
}
## print each tile the payers get from round 53
if ($round >= 53) {
print "$round";
for ($player = $playerId; $player >= 0; $player--) {
print "t";
}
print "$mahjongTiles{$random_number}n";
}
## print the number of pairs for each player
## at 1) halway of the game and 2) end of the game
if ($round == 96 or $round == 136) {
print "nnNumber of pairs so far (2+ same mahjongTiles)n";
print "-------------------------------------------------n";
print "At$ctPairsForAnBt$ctPairsForBnCt";
print "$ctPairsForCnDt$ctPairsForDnnn";
}
}
## end of the program
exit;
先贴1个运行结果如下(后面再分析更多运行结果),可以看出,这把牌,一起手,A有
2对,B没对子,C和D各3对(C和D肯定想搞7对了)。
牌打到,一半(96张后),不打错的话,A和C能各有6对(听了!) D也5对差1张就听
了,最少的B,从没有对子,也抓了3对。
如果一直没有人胡,到最后,ABCD可各抓10,10,9,12对。
再看牌的连续性:第56和第57张,连上了俩张南风;第90和93的2饼,以及91和96的9条
,都是相隔不远就来了。
Sample run result:
At start (Qi3 Shou3)
--------------------------------------------
A: Fa|Fa|East|West|West|5_Wan|8_Wan|2_Tiao|3_Tiao|5_Tiao|1_Bing|2_Bing|5_
Bing|6_Bing|
B: Zhong|Fa|East|North|5_Wan|9_Wan|1_Tiao|4_Tiao|6_Tiao|7_Tiao|7_Bing|8_Bing
|9_Bing|
C: Fa|East|3_Wan|8_Wan|9_Wan|9_Wan|2_Tiao|2_Tiao|4_Tiao|4_Tiao|1_Bing|4_Bing
|6_Bing|
D: Zhong|South|North|1_Tiao|2_Tiao|4_Tiao|5_Tiao|5_Tiao|9_Tiao|9_Tiao|8_Bing
|9_Bing|9_Bing|
Number of pairs so far (2+ same mahjongTiles)
---------------------------------------------------
A 2
B 0
C 3
D 3
# A B C D
---------------------------------------------------
53 2_Tiao
54 7_Wan
55 2_Wan
56 South
57 South
58 6_Tiao
59 4_Wan
60 3_Bing
61 East
62 6_Wan
63 West
64 7_Wan
65 8_Wan
66 2_Wan
67 4_Wan
68 1_Tiao
69 1_Wan
70 4_Wan
71 6_Bing
72 7_Bing
73 1_Bing
74 5_Bing
75 7_Wan
76 1_Wan
77 1_Tiao
78 4_Bing
79 8_Bing
80 3_Tiao
81 1_Bing
82 8_Tiao
83 West
84 South
85 4_Wan
86 4_Bing
87 6_Bing
88 2_Wan
89 6_Wan
90 2_Bing
91 9_Tiao
92 7_Tiao
93 2_Bing
94 9_Bing
95 7_Tiao
96 9_Tiao
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 6
B 3
C 6
D 5
97 8_Tiao
98 7_Tiao
99 6_Wan
100 2_Wan
101 6_Tiao
102 Zhong
103 8_Bing
104 Bai
105 North
106 6_Wan
107 3_Wan
108 5_Bing
109 8_Wan
110 8_Tiao
111 3_Bing
112 1_Wan
113 6_Tiao
114 3_Wan
115 3_Tiao
116 3_Bing
117 5_Wan
118 3_Bing
119 1_Wan
120 3_Tiao
121 8_Tiao
122 5_Tiao
123 Zhong
124 North
125 5_Bing
126 9_Wan
127 Bai
128 7_Wan
129 Bai
130 5_Wan
131 4_Bing
132 3_Wan
133 7_Bing
134 2_Bing
135 7_Bing
136 Bai
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 10
B 10
C 9
D 12 |
j***u 发帖数: 836 | 2 再看下面这把牌,起手大家对子都不多(最多的才俩对),但是后面打到一半,C不打
错1张的话,已经可以自摸7对,如果黄庄,最后各人能分别能抓7,7,11,9对。
从发牌连续性看:70和71连来俩张南风,然后仅隔1张,第73张又是南风;
87和88的连续的来1条;
98和99的9饼;
115和116的1饼,仅隔1张118又来1张;
121和122的7万,之前仅隔1张199也是7万;
134到136最后3张连着3张8条。
At start (Qi3 Shou3)
--------------------------------------------
A: Zhong|Fa|East|North|North|2_Wan|2_Tiao|3_Tiao|5_Tiao|6_Tiao|7_Tiao|9_Tiao
|4_Bing|9_Bing|
B: Zhong|North|2_Wan|3_Wan|5_Wan|9_Wan|1_Tiao|5_Tiao|7_Tiao|9_Tiao|4_Bing|5_
Bing|9_Bing|
C: East|South|3_Wan|3_Wan|5_Wan|6_Wan|2_Tiao|4_Tiao|5_Tiao|6_Tiao|3_Bing|4_
Bing|6_Bing|
D: Fa|West|1_Wan|3_Wan|4_Wan|5_Wan|9_Wan|3_Tiao|4_Tiao|2_Bing|2_Bing|5_Bing|
5_Bing|
Number of pairs so far (2+ same mahjongTiles)
---------------------------------------------------
A 1
B 0
C 1
D 2
# A B C D
---------------------------------------------------
53 9_Bing
54 East
55 8_Bing
56 East
57 2_Wan
58 1_Tiao
59 Fa
60 8_Bing
61 6_Wan
62 Bai
63 5_Wan
64 9_Wan
65 4_Tiao
66 6_Bing
67 4_Bing
68 Zhong
69 4_Wan
70 South
71 South
72 7_Tiao
73 South
74 Bai
75 6_Wan
76 2_Wan
77 8_Wan
78 9_Tiao
79 Zhong
80 7_Wan
81 2_Bing
82 3_Tiao
83 2_Bing
84 North
85 5_Bing
86 Bai
87 1_Tiao
88 1_Tiao
89 4_Wan
90 8_Wan
91 6_Tiao
92 6_Wan
93 9_Tiao
94 Bai
95 6_Bing
96 7_Tiao
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 4
B 3
C 7
D 4
97 2_Tiao
98 9_Bing
99 9_Bing
100 8_Bing
101 1_Bing
102 5_Tiao
103 2_Tiao
104 3_Tiao
105 6_Bing
106 7_Bing
107 Fa
108 3_Bing
109 8_Bing
110 9_Wan
111 1_Wan
112 7_Bing
113 8_Wan
114 4_Tiao
115 1_Bing
116 1_Bing
117 1_Wan
118 1_Bing
119 7_Wan
120 7_Bing
121 7_Wan
122 7_Wan
123 4_Wan
124 8_Wan
125 6_Tiao
126 7_Bing
127 3_Bing
128 West
129 3_Bing
130 West
131 8_Tiao
132 1_Wan
133 West
134 8_Tiao
135 8_Tiao
136 8_Tiao
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 7
B 7
C 11
D 9 |
j***u 发帖数: 836 | 3 再贴1个,这把分析特定玩家连抓牌:
A在105和109连抓俩张南风(注意A在96张后已经4对了,丢了第5对会很心疼);
接着不久,A在117和121连抓俩张7条(前面隔1张115时候,C也抓了7条)。
At start (Qi3 Shou3)
--------------------------------------------
A: 2_Wan|6_Wan|7_Wan|9_Wan|1_Tiao|3_Tiao|6_Tiao|3_Bing|5_Bing|6_Bing|6_Bing|
6_Bing|8_Bing|8_Bing|
B: Fa|Bai|6_Wan|7_Wan|8_Wan|8_Wan|2_Tiao|6_Tiao|9_Tiao|1_Bing|3_Bing|4_Bing|
8_Bing|
C: East|South|North|1_Wan|4_Wan|7_Wan|7_Wan|3_Tiao|9_Tiao|4_Bing|5_Bing|7_
Bing|8_Bing|
D: Zhong|West|3_Wan|6_Wan|6_Wan|8_Wan|9_Wan|1_Tiao|5_Tiao|5_Tiao|7_Tiao|8_
Tiao|6_Bing|
Number of pairs so far (2+ same mahjongTiles)
---------------------------------------------------
A 2
B 1
C 1
D 2
# A B C D
---------------------------------------------------
53 3_Bing
54 5_Bing
55 Bai
56 2_Tiao
57 4_Wan
58 1_Tiao
59 4_Wan
60 Zhong
61 1_Wan
62 East
63 3_Tiao
64 3_Tiao
65 Fa
66 Zhong
67 8_Tiao
68 2_Bing
69 5_Bing
70 5_Wan
71 2_Wan
72 8_Wan
73 6_Tiao
74 4_Tiao
75 1_Bing
76 2_Bing
77 Zhong
78 2_Wan
79 6_Tiao
80 1_Wan
81 9_Tiao
82 2_Wan
83 9_Tiao
84 1_Bing
85 Bai
86 West
87 1_Bing
88 1_Wan
89 South
90 4_Bing
91 4_Wan
92 1_Tiao
93 4_Tiao
94 Fa
95 3_Bing
96 2_Tiao
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 4
B 4
C 5
D 8
97 5_Wan
98 5_Wan
99 3_Wan
100 West
101 4_Bing
102 North
103 Bai
104 9_Wan
105 South
106 5_Tiao
107 3_Bing
108 4_Tiao
109 South
110 2_Tiao
111 3_Wan
112 9_Wan
113 East
114 2_Bing
115 7_Tiao
116 Fa
117 7_Tiao
118 East
119 4_Tiao
120 North
121 7_Tiao
122 5_Wan
123 3_Wan
124 5_Tiao
125 8_Tiao
126 West
127 7_Bing
128 8_Tiao
129 2_Bing
130 North
131 9_Bing
132 7_Bing
133 7_Bing
134 9_Bing
135 9_Bing
136 9_Bing
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 6
B 9
C 10
D 11 |
m*****g 发帖数: 12253 | 4 牛,果然搞it的就是牛啊,
【在 j***u 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 再贴1个,这把分析特定玩家连抓牌: : A在105和109连抓俩张南风(注意A在96张后已经4对了,丢了第5对会很心疼); : 接着不久,A在117和121连抓俩张7条(前面隔1张115时候,C也抓了7条)。 : At start (Qi3 Shou3) : -------------------------------------------- : A: 2_Wan|6_Wan|7_Wan|9_Wan|1_Tiao|3_Tiao|6_Tiao|3_Bing|5_Bing|6_Bing|6_Bing| : 6_Bing|8_Bing|8_Bing| : B: Fa|Bai|6_Wan|7_Wan|8_Wan|8_Wan|2_Tiao|6_Tiao|9_Tiao|1_Bing|3_Bing|4_Bing| : 8_Bing| : C: East|South|North|1_Wan|4_Wan|7_Wan|7_Wan|3_Tiao|9_Tiao|4_Bing|5_Bing|7_
|
j***u 发帖数: 836 | 5 再多帖些,大家自己慢慢看吧。
反正是牌都是集中着上。
结论:刚抓的牌,对手可能也刚抓了! |
j***u 发帖数: 836 | 6 At start (Qi3 Shou3)
--------------------------------------------
A: North|2_Wan|2_Wan|3_Wan|4_Wan|9_Wan|5_Tiao|7_Tiao|8_Tiao|8_Tiao|9_Tiao|3_
Bing|5_Bing|6_Bing|
B: East|West|North|5_Wan|5_Wan|8_Wan|2_Tiao|4_Tiao|6_Tiao|7_Tiao|4_Bing|4_
Bing|7_Bing|
C: Fa|Bai|East|West|3_Wan|7_Wan|1_Tiao|5_Tiao|3_Bing|4_Bing|6_Bing|7_Bing|8_
Bing|
D: Fa|2_Wan|8_Wan|8_Wan|1_Tiao|2_Tiao|3_Tiao|3_Tiao|8_Tiao|9_Tiao|2_Bing|3_
Bing|3_Bing|
Number of pairs so far (2+ same mahjongTiles)
---------------------------------------------------
A 2
B 2
C 0
D 3
# A B C D
---------------------------------------------------
53 North
54 6_Tiao
55 7_Wan
56 Fa
57 5_Bing
58 4_Wan
59 5_Wan
60 4_Bing
61 2_Tiao
62 6_Wan
63 7_Tiao
64 7_Tiao
65 1_Wan
66 West
67 8_Wan
68 7_Wan
69 5_Tiao
70 Zhong
71 7_Bing
72 Bai
73 8_Tiao
74 Bai
75 Bai
76 6_Wan
77 2_Wan
78 6_Bing
79 3_Tiao
80 4_Tiao
81 1_Bing
82 5_Tiao
83 1_Wan
84 2_Bing
85 West
86 1_Tiao
87 1_Tiao
88 6_Bing
89 5_Wan
90 4_Tiao
91 Zhong
92 2_Bing
93 9_Wan
94 2_Bing
95 4_Tiao
96 7_Wan
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 5
B 5
C 4
D 6
97 7_Bing
98 3_Tiao
99 8_Bing
100 9_Bing
101 6_Wan
102 9_Wan
103 Zhong
104 6_Tiao
105 1_Wan
106 1_Bing
107 1_Wan
108 6_Wan
109 1_Bing
110 5_Bing
111 4_Wan
112 3_Wan
113 4_Wan
114 East
115 North
116 8_Bing
117 6_Tiao
118 9_Bing
119 1_Bing
120 Fa
121 9_Tiao
122 3_Wan
123 8_Bing
124 9_Tiao
125 9_Wan
126 East
127 Zhong
128 2_Tiao
129 9_Bing
130 North
131 9_Bing
132 South
133 5_Bing
134 South
135 South
136 South
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 9
B 7
C 7
D 10 |
j***u 发帖数: 836 | 7 At start (Qi3 Shou3)
--------------------------------------------
A: Zhong|Bai|East|West|5_Wan|8_Wan|2_Tiao|4_Tiao|7_Tiao|3_Bing|5_Bing|5_Bing
|6_Bing|7_Bing|
B: Fa|3_Wan|3_Wan|4_Wan|6_Wan|3_Tiao|4_Tiao|5_Tiao|8_Tiao|9_Tiao|5_Bing|6_
Bing|8_Bing|
C: Fa|South|West|1_Wan|2_Wan|4_Wan|4_Wan|6_Wan|7_Wan|3_Tiao|7_Tiao|1_Bing|2_
Bing|
D: South|4_Wan|7_Wan|7_Wan|8_Wan|1_Tiao|2_Tiao|3_Tiao|5_Tiao|7_Tiao|8_Tiao|5
_Bing|9_Bing|
Number of pairs so far (2+ same mahjongTiles)
---------------------------------------------------
A 1
B 1
C 1
D 1
# A B C D
---------------------------------------------------
53 3_Bing
54 2_Tiao
55 West
56 9_Bing
57 Fa
58 2_Bing
59 East
60 North
61 South
62 2_Bing
63 1_Bing
64 7_Tiao
65 1_Tiao
66 4_Bing
67 4_Tiao
68 East
69 5_Wan
70 West
71 Bai
72 1_Tiao
73 North
74 South
75 8_Tiao
76 8_Wan
77 3_Tiao
78 4_Bing
79 6_Tiao
80 5_Tiao
81 5_Wan
82 4_Tiao
83 3_Wan
84 1_Wan
85 1_Bing
86 8_Wan
87 7_Bing
88 9_Bing
89 1_Tiao
90 6_Tiao
91 2_Tiao
92 Zhong
93 1_Wan
94 3_Wan
95 3_Bing
96 9_Tiao
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 3
B 4
C 3
D 6
97 3_Bing
98 7_Wan
99 4_Bing
100 8_Tiao
101 5_Wan
102 6_Bing
103 Fa
104 6_Bing
105 3_Bing
106 Zhong
107 2_Bing
108 9_Tiao
109 6_Tiao
110 9_Wan
111 6_Wan
112 9_Bing
113 9_Wan
114 1_Bing
115 8_Bing
116 9_Tiao
117 6_Tiao
118 Zhong
119 9_Wan
120 8_Bing
121 East
122 7_Bing
123 Bai
124 8_Bing
125 9_Wan
126 7_Bing
127 5_Tiao
128 4_Bing
129 6_Wan
130 2_Wan
131 1_Wan
132 Bai
133 2_Wan
134 2_Wan
135 North
136 North
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 7
B 8
C 8
D 10 |
j***u 发帖数: 836 | 8 At start (Qi3 Shou3)
--------------------------------------------
A: Fa|South|South|North|North|2_Wan|5_Wan|5_Wan|3_Tiao|3_Tiao|1_Bing|6_Bing|
8_Bing|9_Bing|
B: Fa|4_Wan|8_Wan|8_Wan|3_Tiao|5_Tiao|7_Tiao|8_Tiao|8_Tiao|8_Tiao|9_Tiao|7_
Bing|8_Bing|
C: Fa|Fa|West|1_Wan|2_Wan|5_Wan|7_Wan|7_Wan|8_Wan|2_Tiao|5_Tiao|3_Bing|7_
Bing|
D: Bai|East|East|South|3_Wan|8_Tiao|9_Tiao|3_Bing|5_Bing|6_Bing|6_Bing|7_
Bing|8_Bing|
Number of pairs so far (2+ same mahjongTiles)
---------------------------------------------------
A 4
B 2
C 2
D 2
# A B C D
---------------------------------------------------
53 2_Wan
54 7_Tiao
55 5_Tiao
56 2_Bing
57 9_Bing
58 Bai
59 1_Bing
60 2_Tiao
61 9_Wan
62 1_Bing
63 3_Bing
64 Bai
65 East
66 7_Tiao
67 North
68 Zhong
69 South
70 5_Wan
71 9_Bing
72 7_Wan
73 Bai
74 4_Tiao
75 East
76 2_Bing
77 6_Tiao
78 4_Bing
79 7_Tiao
80 Zhong
81 1_Bing
82 4_Wan
83 4_Bing
84 1_Tiao
85 6_Wan
86 3_Wan
87 7_Bing
88 6_Wan
89 West
90 West
91 3_Wan
92 1_Wan
93 3_Tiao
94 1_Wan
95 8_Wan
96 6_Bing
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 6
B 4
C 6
D 5
97 North
98 3_Wan
99 Zhong
100 8_Bing
101 3_Bing
102 West
103 6_Tiao
104 2_Bing
105 2_Bing
106 4_Wan
107 4_Wan
108 7_Wan
109 5_Tiao
110 2_Wan
111 9_Tiao
112 2_Wan
113 6_Wan
114 6_Wan
115 6_Tiao
116 6_Tiao
117 9_Bing
118 1_Tiao
119 4_Bing
120 Zhong
121 1_Wan
122 9_Tiao
123 4_Tiao
124 4_Tiao
125 1_Tiao
126 9_Wan
127 5_Bing
128 9_Wan
129 2_Tiao
130 1_Tiao
131 2_Tiao
132 4_Tiao
133 5_Bing
134 9_Wan
135 4_Bing
136 5_Bing
Number of pairs so far (2+ same mahjongTiles)
-------------------------------------------------
A 7
B 9
C 9
D 9 |
R*******e 发帖数: 575 | 9 牛呀。
破解了我们对未名麻将的种种猜想。
【在 j***u 的大作中提到】![](/moin_static193/solenoid/img/up.png) : At start (Qi3 Shou3) : -------------------------------------------- : A: Fa|South|South|North|North|2_Wan|5_Wan|5_Wan|3_Tiao|3_Tiao|1_Bing|6_Bing| : 8_Bing|9_Bing| : B: Fa|4_Wan|8_Wan|8_Wan|3_Tiao|5_Tiao|7_Tiao|8_Tiao|8_Tiao|8_Tiao|9_Tiao|7_ : Bing|8_Bing| : C: Fa|Fa|West|1_Wan|2_Wan|5_Wan|7_Wan|7_Wan|8_Wan|2_Tiao|5_Tiao|3_Bing|7_ : Bing| : D: Bai|East|East|South|3_Wan|8_Tiao|9_Tiao|3_Bing|5_Bing|6_Bing|6_Bing|7_ : Bing|8_Bing|
|
O***O 发帖数: 264 | 10 牛,
请教一下老五:
老刑的麻将开始后,我怎么监测它的运行,然后算出下张来什么牌,虽然是随机的,,, |
|
|
g*********g 发帖数: 1139 | 11 赞
【在 j***u 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 要交CS作业、小project什么的同学有福了。抄抄我这个就可以对付了。 : 为了看清楚电脑是怎么发牌的,我用Perl语言编了以下这个小程序。 : 不会编程的同学,只要在自己电脑上安装有Perl(可以免费下载和安装,3分钟的事,见 : 后),就可以运行我的程序玩。 : 这个程序的核心在于$random_number = int(rand(34)); : 搞到1个在0和33之间的伪随机数。然后根据0到33各代表哪张麻将牌发出麻将。 : 程序先用了时间作种子。 : $seed = time(); : srand($seed); : 根据网上资料,Perl的srand不可在循环里反复被call,否则反而带来重复。
|
j***u 发帖数: 836 | 12 你没看到我在5楼下的(其中1个)结论?
就是:你刚抓到的牌,别人可能也是刚抓到或即将抓到。
根据这个和前面别人和自己打出的牌决定你的取舍吧。
已经听的,可以更好地选择听啥。
听不了又觉得危险的,可以小心选不炮的。
我的程序帮不到监测老刑的麻将运行。只是有相似的地方罢了。
【在 O***O 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 牛, : 请教一下老五: : 老刑的麻将开始后,我怎么监测它的运行,然后算出下张来什么牌,虽然是随机的,,,
|
R*******e 发帖数: 575 | 13 如果你能算出下张来什么牌,你每天不自摸10次七对才怪。没人敢跟你打了:)
【在 O***O 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 牛, : 请教一下老五: : 老刑的麻将开始后,我怎么监测它的运行,然后算出下张来什么牌,虽然是随机的,,,
|
b***m 发帖数: 2112 | 14 太太牛了。。。
泪流满面。。。
【在 j***u 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 要交CS作业、小project什么的同学有福了。抄抄我这个就可以对付了。 : 为了看清楚电脑是怎么发牌的,我用Perl语言编了以下这个小程序。 : 不会编程的同学,只要在自己电脑上安装有Perl(可以免费下载和安装,3分钟的事,见 : 后),就可以运行我的程序玩。 : 这个程序的核心在于$random_number = int(rand(34)); : 搞到1个在0和33之间的伪随机数。然后根据0到33各代表哪张麻将牌发出麻将。 : 程序先用了时间作种子。 : $seed = time(); : srand($seed); : 根据网上资料,Perl的srand不可在循环里反复被call,否则反而带来重复。
|
t*s 发帖数: 383 | 15 太职业了,赞一下!
【在 j***u 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 要交CS作业、小project什么的同学有福了。抄抄我这个就可以对付了。 : 为了看清楚电脑是怎么发牌的,我用Perl语言编了以下这个小程序。 : 不会编程的同学,只要在自己电脑上安装有Perl(可以免费下载和安装,3分钟的事,见 : 后),就可以运行我的程序玩。 : 这个程序的核心在于$random_number = int(rand(34)); : 搞到1个在0和33之间的伪随机数。然后根据0到33各代表哪张麻将牌发出麻将。 : 程序先用了时间作种子。 : $seed = time(); : srand($seed); : 根据网上资料,Perl的srand不可在循环里反复被call,否则反而带来重复。
|
g*********g 发帖数: 1139 | 16 用136个随机数来代表136张牌,会更符合实际麻将些,这样每次牌发出去对应的那个数
就不再调用,只从剩下的数里去调。
从概率的角度比较好理解,比如翻开一张牌是东风,那么下面一张牌是东风的概率是
3/135。 但是如果只有34个随机数,因为东风没发完,下面一张是东风的概率还是1/34。
实际麻将里136张牌的话概率是一直在变化的。用136个随机数来代表136张牌就可以解
决这个主要问题,更接近实际情况。程序可能会稍微麻烦些。
【在 j***u 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 要交CS作业、小project什么的同学有福了。抄抄我这个就可以对付了。 : 为了看清楚电脑是怎么发牌的,我用Perl语言编了以下这个小程序。 : 不会编程的同学,只要在自己电脑上安装有Perl(可以免费下载和安装,3分钟的事,见 : 后),就可以运行我的程序玩。 : 这个程序的核心在于$random_number = int(rand(34)); : 搞到1个在0和33之间的伪随机数。然后根据0到33各代表哪张麻将牌发出麻将。 : 程序先用了时间作种子。 : $seed = time(); : srand($seed); : 根据网上资料,Perl的srand不可在循环里反复被call,否则反而带来重复。
|
M****f 发帖数: 211 | 17 老吴牛啊,看完我不想玩麻将了,哈哈,因为太“随机”了。。。
【在 j***u 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 要交CS作业、小project什么的同学有福了。抄抄我这个就可以对付了。 : 为了看清楚电脑是怎么发牌的,我用Perl语言编了以下这个小程序。 : 不会编程的同学,只要在自己电脑上安装有Perl(可以免费下载和安装,3分钟的事,见 : 后),就可以运行我的程序玩。 : 这个程序的核心在于$random_number = int(rand(34)); : 搞到1个在0和33之间的伪随机数。然后根据0到33各代表哪张麻将牌发出麻将。 : 程序先用了时间作种子。 : $seed = time(); : srand($seed); : 根据网上资料,Perl的srand不可在循环里反复被call,否则反而带来重复。
|
J**S 发帖数: 25790 | 18 老农不识字,不懂码,看不懂学术,还是顶一下。。 |
w******0 发帖数: 3908 | |
j***u 发帖数: 836 | 20 谢谢美女夸奖。
你的新装扮很养眼。赞事业线!
打分开始啦。
【在 w******0 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 哇..高山仰止...
|
w******0 发帖数: 3908 | 21 谢谢jim啦!~~又可以换衣服了!不过这套比较贵还是教授掏腰包的~容我多骚包两天...
哈哈哈~
【在 j***u 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 谢谢美女夸奖。 : 你的新装扮很养眼。赞事业线! : 打分开始啦。
|