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
6b62965f
Commit
6b62965f
authored
Oct 24, 2019
by
十年打工还是工,梭哈一夜往皇宫
🤡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并更新
parent
e96ed1de
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
18 deletions
+36
-18
NetConnect.cs
Lottery/Lottery/NetConnect.cs
+2
-1
Program.cs
Lottery/Lottery/Program.cs
+32
-14
RandomOrg.cs
Lottery/Lottery/RandomOrg.cs
+2
-3
No files found.
Lottery/Lottery/NetConnect.cs
View file @
6b62965f
...
...
@@ -12,7 +12,8 @@ namespace Lottery
try
{
Ping
ping
=
new
Ping
();
PingReply
reply
=
ping
.
Send
(
"www.baidu.com"
);
//PingReply reply = ping.Send("www.baidu.com");
PingReply
reply
=
ping
.
Send
(
"www.random.org"
);
ping
.
Dispose
();
return
reply
.
Status
==
IPStatus
.
Success
;
}
...
...
Lottery/Lottery/Program.cs
View file @
6b62965f
...
...
@@ -45,44 +45,62 @@ namespace Lottery
IReadOnlyList
<
int
>
randoms
=
RandomOrg
.
GetRandomsAsync
(
persons
.
Count
).
Result
;
//生成人员排序随机数
IReadOnlyList
<
int
>
indexRandoms
=
RandomOrg
.
GetIntRandomsAsync
(
persons
.
Count
).
Result
;
Random
updateRandom
=
new
Random
();
if
(
indexRandoms
!=
null
)
{
//计分方式1:根据返回的随机数加金币
//计分方式2:看命
//计分方式3:随机加上一个人的金币,看能否逆袭
//其他方式:可在下方对NewGrade属性进行操作
persons
[
j
].
NewGrade
+=
(
randoms
[
j
]
+
//(Math.Abs(persons[j].GetHashCode() << 1) % persons.Count) +
persons
[
randoms
[
j
]
-
1
].
OldGrade
);
if
(
i
==
3
&&
persons
[
j
].
BaseGrade
>
0
)
for
(
int
j
=
0
;
j
<
indexRandoms
.
Count
;
j
++)
{
//计分方式1:根据返回的随机数加金币
//计分方式2:看命
//计分方式3:随即加上一个人的金币,看能否逆袭
//其他方式:可在下方对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
{
int
index
=
indexRandoms
[
j
];
persons
[
j
].
NewGrade
+=
(
randoms
[
index
]
+
(
Math
.
Abs
(
persons
[
index
].
GetHashCode
()
<<
1
)
%
persons
.
Count
)
+
//
(Math.Abs(persons[index].GetHashCode() << 1) % persons.Count) +
persons
[
randoms
[
index
]
-
1
].
OldGrade
);
if
(
i
==
3
&&
persons
[
index
].
BaseGrade
>
0
)
}
if
(
i
==
3
&&
persons
[
j
].
BaseGrade
>
0
)
{
persons
[
index
].
NewGrade
+=
Person
.
GetRandomBaseGrade
(
persons
[
index
].
BaseGrade
);
persons
[
j
].
NewGrade
+=
Person
.
GetRandomBaseGrade
(
persons
[
j
].
BaseGrade
);
}
}
}
else
{
for
(
int
j
=
0
;
j
<
persons
.
Count
;
j
++)
{
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
{
//计分方式1:根据返回的随机数加金币
//计分方式2:看命
//计分方式3:随即加上一个人的金币,看能否逆袭
//其他方式:可在下方对NewGrade属性进行操作
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
);
}
if
(
i
==
3
&&
persons
[
j
].
BaseGrade
>
0
)
{
...
...
Lottery/Lottery/RandomOrg.cs
View file @
6b62965f
...
...
@@ -48,7 +48,7 @@ namespace Lottery
using
(
HttpClient
httpClient
=
new
HttpClient
())
{
httpClient
.
DefaultRequestHeaders
.
TryAddWithoutValidation
(
"user-agent"
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3936.0 Safari/537.36 Edg/79.0.301.2"
);
var
resp
=
await
httpClient
.
GetAsync
(
$"https://www.random.org/integer-sets/?sets=1&num=
{
length
}
&min=0&max=
{
length
-
1
}
&commas=on&order=random&format=plain&rnd=new"
);
var
resp
=
await
httpClient
.
GetAsync
(
$"https://www.random.org/integer-sets/?sets=1&num=
{
length
}
&min=0&max=
{
length
}
&commas=on&order=random&format=plain&rnd=new"
);
if
(
resp
.
IsSuccessStatusCode
)
{
string
content
=
await
resp
.
Content
.
ReadAsStringAsync
();
...
...
@@ -60,8 +60,7 @@ namespace Lottery
{
}
var
r
=
new
Random
(
length
);
return
Enumerable
.
Range
(
0
,
length
).
Select
(
p
=>
r
.
Next
(
1
,
length
+
1
)).
ToList
();
return
null
;
}
}
}
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