69 lines
1.1 KiB
Go
69 lines
1.1 KiB
Go
package pkg
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.pengzhan.dev/mjhelper/pkg/tiles"
|
|
)
|
|
|
|
const (
|
|
// 未出场
|
|
tl_notshow = 0
|
|
// 本家状态
|
|
tl_mhand = 1
|
|
tl_mshow = 2
|
|
tl_mdisc = 3
|
|
// 下家状态
|
|
tl_nhand = 4
|
|
tl_nshow = 5
|
|
tl_ndisc = 6
|
|
// 对家状态
|
|
tl_ohand = 7
|
|
tl_oshow = 8
|
|
tl_odisc = 9
|
|
// 上家状态
|
|
tl_phand = 10
|
|
tl_pshow = 11
|
|
tl_pdisc = 12
|
|
)
|
|
|
|
type environment struct {
|
|
board [4][34]int
|
|
}
|
|
|
|
func (e environment) Print() {
|
|
for i := 0; i < len(e.board)+1; i++ {
|
|
for j := 0; j < len(e.board[0]); j++ {
|
|
if i == 0 {
|
|
fmt.Printf("|% 3s", tiles.TileTypes[j])
|
|
} else {
|
|
fmt.Printf("|% 3d", e.board[i-1][j])
|
|
}
|
|
}
|
|
fmt.Printf("|\n")
|
|
}
|
|
}
|
|
|
|
func (e environment) PatternNormalization() [3][34]int {
|
|
var ret [3][34]int
|
|
for i := 0; i < len(e.board[0]); i++ {
|
|
hand := 0
|
|
disc := 0
|
|
noshow := 0
|
|
for j := 0; j < len(e.board); j++ {
|
|
switch e.board[j][i] {
|
|
case tl_mhand, tl_mshow:
|
|
hand += 1
|
|
case tl_mdisc, tl_ndisc, tl_nshow, tl_odisc, tl_oshow, tl_pdisc, tl_pshow:
|
|
disc += 1
|
|
case tl_notshow:
|
|
noshow += 1
|
|
}
|
|
}
|
|
ret[0][i] = hand
|
|
ret[1][i] = disc
|
|
ret[2][i] = noshow
|
|
}
|
|
return ret
|
|
}
|