Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
ygopro-core
Commits
8799b7a1
Commit
8799b7a1
authored
Dec 12, 2023
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update mt19937, signature of create_duel() API
parent
65d50ca5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
mtrandom.h
mtrandom.h
+11
-10
ocgapi.cpp
ocgapi.cpp
+1
-1
ocgapi.h
ocgapi.h
+1
-1
No files found.
mtrandom.h
View file @
8799b7a1
...
...
@@ -8,6 +8,7 @@
#ifndef MTRANDOM_H_
#define MTRANDOM_H_
#include <cstdint>
#include <random>
class
mt19937
{
...
...
@@ -15,30 +16,30 @@ public:
const
unsigned
int
rand_max
;
mt19937
()
:
rng
(),
rand_max
(
(
rng
.
max
)
())
{}
explicit
mt19937
(
u
nsigned
in
t
seed
)
:
rng
(
seed
),
rand_max
(
(
rng
.
max
)
())
{}
rng
(),
rand_max
(
rng
.
max
())
{}
explicit
mt19937
(
u
int_fast32_
t
seed
)
:
rng
(
seed
),
rand_max
(
rng
.
max
())
{}
// mersenne_twister_engine
void
reset
(
u
nsigned
in
t
seed
)
{
void
reset
(
u
int_fast32_
t
seed
)
{
rng
.
seed
(
seed
);
}
u
nsigned
in
t
rand
()
{
u
int_fast32_
t
rand
()
{
return
rng
();
}
// uniform_int_distribution
int
get_random_integer
(
int
l
,
int
h
)
{
u
nsigned
int
range
=
(
unsigned
in
t
)(
h
-
l
+
1
);
u
nsigned
int
secureMax
=
rand_max
-
rand_max
%
range
;
u
nsigned
in
t
x
;
u
int_fast32_t
range
=
(
uint_fast32_
t
)(
h
-
l
+
1
);
u
int_fast32_t
secureMax
=
rng
.
max
()
-
rng
.
max
()
%
range
;
u
int_fast32_
t
x
;
do
{
x
=
rng
();
}
while
(
x
>=
secureMax
);
return
(
int
)(
l
+
x
%
range
);
return
l
+
(
int
)(
x
%
range
);
}
int
get_random_integer_old
(
int
l
,
int
h
)
{
int
result
=
(
int
)((
double
)
rng
()
/
r
and_max
*
((
double
)
h
-
l
+
1
))
+
l
;
int
result
=
(
int
)((
double
)
rng
()
/
r
ng
.
max
()
*
((
double
)
h
-
l
+
1
))
+
l
;
if
(
result
>
h
)
result
=
h
;
return
result
;
...
...
ocgapi.cpp
View file @
8799b7a1
...
...
@@ -57,7 +57,7 @@ uint32 default_card_reader(uint32 code, card_data* data) {
uint32
default_message_handler
(
void
*
pduel
,
uint32
message_type
)
{
return
0
;
}
extern
"C"
DECL_DLLEXPORT
intptr_t
create_duel
(
uint
32
seed
)
{
extern
"C"
DECL_DLLEXPORT
intptr_t
create_duel
(
uint
_fast32_t
seed
)
{
duel
*
pduel
=
new
duel
();
duel_set
.
insert
(
pduel
);
pduel
->
random
.
reset
(
seed
);
...
...
ocgapi.h
View file @
8799b7a1
...
...
@@ -35,7 +35,7 @@ byte* read_script(const char* script_name, int* len);
uint32
read_card
(
uint32
code
,
card_data
*
data
);
uint32
handle_message
(
void
*
pduel
,
uint32
message_type
);
extern
"C"
DECL_DLLEXPORT
intptr_t
create_duel
(
uint
32
seed
);
extern
"C"
DECL_DLLEXPORT
intptr_t
create_duel
(
uint
_fast32_t
seed
);
extern
"C"
DECL_DLLEXPORT
void
start_duel
(
intptr_t
pduel
,
int32
options
);
extern
"C"
DECL_DLLEXPORT
void
end_duel
(
intptr_t
pduel
);
extern
"C"
DECL_DLLEXPORT
void
set_player_info
(
intptr_t
pduel
,
int32
playerid
,
int32
lp
,
int32
startcount
,
int32
drawcount
);
...
...
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