Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pingouins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Clement Lucas
pingouins
Commits
4edef40c
Commit
4edef40c
authored
9 years ago
by
Bariatti Francesco
Browse files
Options
Downloads
Patches
Plain Diff
Misc. error correction
parent
e8ebd880
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/game/morpion.cpp
+10
-9
10 additions, 9 deletions
src/game/morpion.cpp
src/game/morpion.hpp
+1
-0
1 addition, 0 deletions
src/game/morpion.hpp
with
11 additions
and
9 deletions
src/game/morpion.cpp
+
10
−
9
View file @
4edef40c
...
...
@@ -103,11 +103,11 @@ namespace game
bool
morpion
::
has_won
(
uint16_t
bitboard
)
{
if
(
bitboard
==
ROW0_MASK
||
bitboard
==
ROW1_MASK
||
bitboard
==
ROW2_MASK
)
// Check vertical |
if
(
((
bitboard
|
ROW0_MASK
)
==
ALL_ONES
)
||
((
bitboard
|
ROW1_MASK
)
==
ALL_ONES
)
||
((
bitboard
|
ROW2_MASK
)
==
ALL_ONES
))
// Check horizontal ---
return
true
;
if
(
bitboard
==
COL0_MASK
||
bitboard
==
COL1_MASK
||
bitboard
==
COL2_MASK
)
// Check
horizont
al
_
if
(
((
bitboard
|
COL0_MASK
)
==
ALL_ONES
)
||
((
bitboard
|
COL1_MASK
)
==
ALL_ONES
)
||
((
bitboard
|
COL2_MASK
)
==
ALL_ONES
))
// Check
vertic
al
|
return
true
;
if
(
bitboard
==
DIA0_MASK
||
bitboard
==
DIA1_MASK
)
// Chack diagonal \ /
if
(
((
bitboard
|
DIA0_MASK
)
==
ALL_ONES
)
||
((
bitboard
|
DIA1_MASK
)
==
ALL_ONES
))
// Chack diagonal \ /
return
true
;
return
false
;
}
...
...
@@ -116,6 +116,7 @@ namespace game
void
morpion
::
update_moves
()
{
uint16_t
free_bitboard
=
~
(
state
.
cross_bitboard
|
state
.
circle_bitboard
);
state
.
possible_moves
=
0
;
for
(
int
i
=
0
;
i
<=
8
;
i
++
)
{
if
(
free_bitboard
&
1
)
...
...
@@ -129,11 +130,10 @@ namespace game
void
morpion
::
play
(
uint16_t
m
)
{
uint16_t
position
=
(
state
.
possible_moves
>>
4
*
m
)
&
15
;
//15 is the mask to get only one move
if
(
current_player
()
==
CROSS
)
state
.
cross_bitboard
+=
1
<<
position
;
state
.
cross_bitboard
+=
(
1
<<
m
)
;
else
state
.
circle_bitboard
+=
1
<<
position
;
state
.
circle_bitboard
+=
(
1
<<
m
)
;
//State update
state
.
total_moves
++
;
...
...
@@ -179,9 +179,9 @@ namespace game
result
+=
"|"
;
for
(
int
col
=
2
;
col
>=
0
;
col
--
)
{
if
(((
state
.
cross_bitboard
>>
3
*
row
)
>>
col
)
&
1
)
if
(((
state
.
cross_bitboard
>>
(
3
*
row
)
)
>>
col
)
&
1
)
result
+=
player_to_string
(
CROSS
)
+
"|"
;
else
if
(((
state
.
circle_bitboard
>>
3
*
row
)
>>
col
)
&
1
)
else
if
(((
state
.
circle_bitboard
>>
(
3
*
row
)
)
>>
col
)
&
1
)
result
+=
player_to_string
(
CIRCLE
)
+
"|"
;
else
result
+=
" |"
;
...
...
@@ -197,7 +197,8 @@ namespace game
{
uniform_int_distribution
<
uint16_t
>
distribution
(
0
,
8
-
state
.
total_moves
);
uint16_t
move
=
distribution
(
engine
);
play
(
move
);
uint16_t
position
=
(
state
.
possible_moves
>>
4
*
move
)
&
15
;
//15 is the mask to get only one move
play
(
position
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/game/morpion.hpp
+
1
−
0
View file @
4edef40c
...
...
@@ -66,6 +66,7 @@ namespace game
const
uint16_t
COL2_MASK
=
219
;
const
uint16_t
DIA0_MASK
=
238
;
const
uint16_t
DIA1_MASK
=
427
;
const
uint16_t
ALL_ONES
=
511
;
static
std
::
vector
<
std
::
vector
<
uint64_t
>>
cross_hash_values
;
static
std
::
vector
<
std
::
vector
<
uint64_t
>>
circle_hash_values
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment