Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
Lottery
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
罗颖骄
Lottery
Commits
4cae51e9
Commit
4cae51e9
authored
Oct 24, 2019
by
罗颖骄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat: 计分方式3-第二轮排放金币越排在前面的人越吃亏的bug解决
parent
cb67e02d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
Program.cs
Lottery/Lottery/Program.cs
+14
-0
No files found.
Lottery/Lottery/Program.cs
View file @
4cae51e9
...
@@ -43,15 +43,29 @@ namespace Lottery
...
@@ -43,15 +43,29 @@ namespace Lottery
//开始计分,该循环表示计分规则
//开始计分,该循环表示计分规则
//获取从www.random.org生成的真随机数
//获取从www.random.org生成的真随机数
IReadOnlyList
<
int
>
randoms
=
RandomOrg
.
GetRandomsAsync
(
persons
.
Count
).
Result
;
IReadOnlyList
<
int
>
randoms
=
RandomOrg
.
GetRandomsAsync
(
persons
.
Count
).
Result
;
Random
updateRandom
=
new
Random
();
for
(
int
j
=
0
;
j
<
persons
.
Count
;
j
++)
for
(
int
j
=
0
;
j
<
persons
.
Count
;
j
++)
{
{
//计分方式1:根据返回的随机数加金币
//计分方式1:根据返回的随机数加金币
//计分方式2:看命
//计分方式2:看命
//计分方式3:随即加上一个人的金币,看能否逆袭
//计分方式3:随即加上一个人的金币,看能否逆袭
//其他方式:可在下方对NewGrade属性进行操作
//其他方式:可在下方对NewGrade属性进行操作
if
(
i
>
1
)
{
// 计分方式3:bug——第二轮发金币时越排在前面的人获取到的上上一轮的NewGrade可能性越大,越排在后面的人获取到上轮NewGrade
// 解决策略->当前面的人抽取到前面已更新的OldGrade则照旧;若抽到后面的人,则增加一次计分方式1操作以此弥补差值
int
randomIndex
=
randoms
[
j
]
-
1
>=
j
?
updateRandom
.
Next
(
j
)
:
randoms
[
j
]
-
1
;
int
randomValue
=
randomIndex
==
0
?
randoms
[
j
]
:
persons
[
randomIndex
].
OldGrade
;
persons
[
j
].
NewGrade
+=
(
randoms
[
j
]
+
(
Math
.
Abs
(
persons
[
j
].
GetHashCode
()
<<
1
)
%
persons
.
Count
)
+
randomValue
);
}
else
{
persons
[
j
].
NewGrade
+=
(
randoms
[
j
]
+
persons
[
j
].
NewGrade
+=
(
randoms
[
j
]
+
(
Math
.
Abs
(
persons
[
j
].
GetHashCode
()
<<
1
)
%
persons
.
Count
)
+
(
Math
.
Abs
(
persons
[
j
].
GetHashCode
()
<<
1
)
%
persons
.
Count
)
+
persons
[
randoms
[
j
]
-
1
].
OldGrade
);
persons
[
randoms
[
j
]
-
1
].
OldGrade
);
}
if
(
i
==
3
&&
persons
[
j
].
BaseGrade
>
0
)
if
(
i
==
3
&&
persons
[
j
].
BaseGrade
>
0
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment