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
7bbf54c1
Commit
7bbf54c1
authored
9 years ago
by
Bariatti Francesco
Browse files
Options
Downloads
Patches
Plain Diff
Created trivial functions
parent
fd02d8dd
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/penguin.cpp
+14
-23
14 additions, 23 deletions
src/game/penguin.cpp
src/game/penguin.hpp
+6
-3
6 additions, 3 deletions
src/game/penguin.hpp
with
20 additions
and
26 deletions
src/game/penguin.cpp
+
14
−
23
View file @
7bbf54c1
...
...
@@ -26,47 +26,39 @@ namespace game
bool
penguin
::
end_of_game
()
const
{
return
false
;
//return state.first_player_win || state.second_player_win || state.total_moves == 9;
return
state
.
nb_moves_red
==
0
&&
state
.
nb_moves_blue
==
0
;
}
bool
penguin
::
won
(
std
::
uint8_t
player
)
const
{
return
false
;
//if (player == CROSS) return state.first_player_win;
//return state.second_player_win;
if
(
player
==
RED
)
return
state
.
score_red
>
state
.
score_blue
;
return
state
.
score_blue
>
state
.
score_red
;
}
bool
penguin
::
lost
(
std
::
uint8_t
player
)
const
{
return
false
;
/*if (player == CIRCLE) return state.first_player_win;
return state.second_player_win;*/
if
(
player
==
RED
)
return
state
.
score_red
<
state
.
score_blue
;
return
state
.
score_blue
<
state
.
score_red
;
}
bool
penguin
::
draw
(
std
::
uint8_t
player
)
const
{
return
false
;
/*if (state.first_player_win || state.second_player_win) return false;
return state.total_moves == 9;*/
return
state
.
score_blue
==
state
.
score_red
;
}
uint8_t
penguin
::
current_player
()
const
{
return
0
;
/*return state.total_moves & 1 ? CIRCLE : CROSS; // CROSS even, CIRCLE odd*/
return
state
.
current_player_red
?
RED
:
BLUE
;
}
int
penguin
::
value
(
uint8_t
player
)
const
{
/*if (player == CROSS) {
return state.first_player_win ? 1 : (state.second_player_win ? -1 : 0);
}
else if (player == CIRCLE) {
return state.second_player_win ? 1 : (state.first_player_win ? -1 : 0);
}
return 0;*/
return
0
;
if
(
won
(
player
))
return
1
;
else
if
(
lost
(
player
))
return
-
1
;
else
return
0
;
}
/* Number of moves that you can play */
...
...
@@ -98,8 +90,7 @@ namespace game
string
penguin
::
player_to_string
(
uint8_t
player
)
const
{
//return player == CROSS ? "X" : (player == CIRCLE ? "O" : " ");
return
"TODO"
;
return
player
==
RED
?
"Red"
:
"Blue"
;
}
...
...
This diff is collapsed.
Click to expand it.
src/game/penguin.hpp
+
6
−
3
View file @
7bbf54c1
...
...
@@ -25,13 +25,13 @@ namespace game
uint32_t
p3_blue
=
58
;
uint32_t
p4_blue
=
59
;
bool
red_player_win
=
false
;
bool
blue_player_win
=
false
;
int
score_red
=
0
;
int
score_blue
=
0
;
bool
current_player_red
=
true
;
//True if red must play now
int
nb_moves_red
=
0
;
//Number of moves the red player can play
int
nb_moves_blue
=
0
;
};
class
penguin
:
public
game
<
penguin_state
>
...
...
@@ -63,6 +63,9 @@ namespace game
private
:
penguin_state
state
;
uint8_t
RED
=
0
;
uint8_t
BLUE
=
1
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
penguin
&
pen
);
}
...
...
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