Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Reversi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
Reversi
Commits
89c7e57c
Commit
89c7e57c
authored
Aug 16, 2014
by
Michael Catanzaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Disallow undo if only computer has moved"
This reverts commit
d5eda2e4
.
parent
d5eda2e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
25 deletions
+4
-25
src/game.vala
src/game.vala
+3
-8
src/iagno.vala
src/iagno.vala
+1
-3
src/test-iagno.vala
src/test-iagno.vala
+0
-14
No files found.
src/game.vala
View file @
89c7e57c
...
...
@@ -228,20 +228,15 @@ public class Game : Object
return
enemy_count
;
}
public
bool
can_undo
(
int
count
=
1
)
requires
(
count
==
1
||
count
==
2
)
public
bool
can_undo
()
{
/* Can undo one move if a move has been played */
if
(
count
==
1
)
return
undo_index
>
0
;
else
/* Can undo two moves only after the second ply; after the first ply, undo_index == 3 */
return
undo_index
>
3
;
return
undo_index
>
0
;
}
public
void
undo
(
int
count
=
1
)
requires
(
count
==
1
||
count
==
2
)
{
if
(!
can_undo
(
count
))
if
(!
can_undo
())
return
;
for
(
var
i
=
0
;
i
<
count
;
i
++)
...
...
src/iagno.vala
View file @
89c7e57c
...
...
@@ -253,10 +253,8 @@ public class Iagno : Gtk.Application
/* Can't undo when running two computer players */
if
(
light_computer
!=
null
&&
dark_computer
!=
null
)
undo_action
.
set_enabled
(
false
);
else
if
(
light_computer
!=
null
)
undo_action
.
set_enabled
(
game
.
can_undo
(
1
));
else
undo_action
.
set_enabled
(
game
.
can_undo
(
2
));
undo_action
.
set_enabled
(
game
.
can_undo
());
if
(
game
.
current_color
==
Player
.
DARK
)
{
...
...
src/test-iagno.vala
View file @
89c7e57c
...
...
@@ -45,19 +45,6 @@ public class TestIagno : Object
assert
(
game
.
to_string
().
strip
()
==
string
.
joinv
(
"\n"
,
board
).
strip
());
}
private
static
void
test_undo_at_start
()
{
Game
game
=
new
Game
();
assert
(!
game
.
can_undo
(
1
));
assert
(!
game
.
can_undo
(
2
));
game
.
place_tile
(
2
,
3
);
assert
(
game
.
can_undo
(
1
));
assert
(!
game
.
can_undo
(
2
));
game
.
place_tile
(
2
,
2
);
assert
(
game
.
can_undo
(
1
));
assert
(
game
.
can_undo
(
2
));
}
private
static
void
test_current_color_after_pass
()
{
string
[]
board
=
{
"L LLLLLL"
,
...
...
@@ -160,7 +147,6 @@ public class TestIagno : Object
public
static
int
main
(
string
[]
args
)
{
Test
.
init
(
ref
args
);
Test
.
add_func
(
"/Iagno/Pass then Undo"
,
test_undo_after_pass
);
Test
.
add_func
(
"/Iagno/Undo at Start"
,
test_undo_at_start
);
Test
.
add_func
(
"/Iagno/Current Color after Pass"
,
test_current_color_after_pass
);
Test
.
add_func
(
"/Iagno/AI Search 1"
,
test_ai_search_1
);
Test
.
add_func
(
"/Iagno/AI Search 2"
,
test_ai_search_2
);
...
...
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