-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.go
84 lines (68 loc) · 1.69 KB
/
action.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// package action gives tools to represent actions with a board position and an heuristic value
package main
import (
"fmt"
)
type Action struct {
/* The row where the marker is placed. */
row int
/* The column where the marker is placed. */
col int
/* The estimated value of the move. */
value int
/* True if the player has to pass, i.e., if there is no legal move. */
pass bool
}
// create a new structure Action
func NewAction(r, c int) *Action {
return new(Action).Init(r, c)
}
// Initialise the Action structure
func (a *Action) Init(r, c int) *Action {
a.row = r
a.col = c
a.pass = false
return a
}
/* Sets the estimated value of the move. */
func (a *Action) SetValue(v int) {
a.value = v
}
/* Returns the estimated value of the move. */
func (a *Action) GetValue() int {
return a.value
}
/* Sets the column where the marker is to be placed. */
func (a *Action) SetColumn(c int) {
a.col = c
}
/* Returns the column where the marker is to be placed. */
func (a *Action) GetColumn() int {
return a.col
}
/* Sets the row where the marker is to be placed. */
func (a *Action) SetRow(r int) {
a.row = r
}
/* Returns the row where the marker is to be placed. */
func (a *Action) GetRow() int {
return a.row
}
// Sets the boolean that indicates whether this is a pass move. This should only
// be true if there are no legal moves.
func (a *Action) SetPassMove(b bool) {
a.pass = b
}
// Returns true if this is a pass move, indicating that the player has no legal
// moves. Otherwise returns false.
func (a *Action) IsPassMove() bool {
return a.pass
}
// Print the action
func (a *Action) Print() {
if a.pass {
fmt.Println("pass")
} else {
fmt.Printf("(%d,%d)\n", a.row, a.col)
}
}