Skip to content

Commit

Permalink
Merge pull request #31 from 70616e6461/main
Browse files Browse the repository at this point in the history
Fixed error in GnubgID position indexing
  • Loading branch information
kevung authored Feb 15, 2025
2 parents 8709470 + 6c82527 commit fa1fe91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions gnubgid/gnubgid/gnubgid.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type GnubgID struct {
ID string // example: "4HPwATDgc/ABMA:VgkGAAAAAAAA"
PositionID string // example: "4HPwATDgc/ABMA"
MatchID string // example: "VgkGAAAAAAAA"
Position1 [25]int // An array of nb of checkers on each point.
Position2 [25]int // 0: bear-off checkers, 1: pt 1, …, 24: pt 24, 25: on bar
Position1 [26]int // An array of nb of checkers on each point.
Position2 [26]int // 0: bear-off checkers, 1: pt 1, …, 24: pt 24, 25: on bar
MatchKey MatchKey
}

Expand Down Expand Up @@ -302,10 +302,10 @@ func getPositionID(g *GnubgID) error {

// Fill in Position1 and Position2 from the bitstream array
for i := 0; i < 25; i++ {
g.Position1[i] = key[i]
g.Position1[i+1] = key[i]
}
for i := 25; i < 50; i++ {
g.Position2[i-25] = key[i]
g.Position2[i-25+1] = key[i]
}

// Fill in off checkers
Expand Down
24 changes: 12 additions & 12 deletions gnubgid/gnubgid/gnubgid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func Test_validateGnubgID(t *testing.T) {
ID: "4HPwATDgc/ABMA:cAkAAAAAAAAA",
PositionID: "4HPwATDgc/ABMA==",
MatchID: "cAkAAAAAAAAA",
Position1: [25]int{0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position2: [25]int{0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position1: [26]int{0, 0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position2: [26]int{0, 0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
MatchKey: MatchKey{1, 3, 1, 0, 1, 1, 0, 0, [2]int{0, 0}, 0, [2]int{0, 0}},
}
gnubgid1 := gbgid
Expand Down Expand Up @@ -148,8 +148,8 @@ func Test_getMatchID(t *testing.T) {
ID: "4HPwATDgc/ABMA:cAkAAAAAAAAA",
PositionID: "4HPwATDgc/ABMA==",
MatchID: "cAkAAAAAAAAA",
Position1: [25]int{0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position2: [25]int{0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position1: [26]int{0, 0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position2: [26]int{0, 0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
MatchKey: MatchKey{1, 3, 1, 0, 1, 1, 0, 0, [2]int{0, 0}, 0, [2]int{0, 0}},
}
gnubgid1 := gbgid
Expand Down Expand Up @@ -194,8 +194,8 @@ func Test_getPositionID(t *testing.T) {
ID: "4HPwATDgc/ABMA:cAkAAAAAAAAA",
PositionID: "4HPwATDgc/ABMA==",
MatchID: "cAkAAAAAAAAA",
Position1: [25]int{0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position2: [25]int{0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position1: [26]int{0, 0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position2: [26]int{0, 0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
MatchKey: MatchKey{1, 3, 1, 0, 1, 1, 0, 0, [2]int{0, 0}, 0, [2]int{0, 0}},
}
gnubgid1 := gbgid
Expand Down Expand Up @@ -255,8 +255,8 @@ func TestReadGnubgID(t *testing.T) {
ID: "4HPwATDgc/ABMA:cAkAAAAAAAAA",
PositionID: "4HPwATDgc/ABMA==",
MatchID: "cAkAAAAAAAAA",
Position1: [25]int{0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position2: [25]int{0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position1: [26]int{0, 0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
Position2: [26]int{0, 0, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0},
MatchKey: MatchKey{1, 3, 1, 0, 1, 1, 0, 0, [2]int{0, 0}, 0, [2]int{0, 0}},
},
wantErr: false,
Expand All @@ -270,8 +270,8 @@ func TestReadGnubgID(t *testing.T) {
ID: "2+4OAADb7g4AAA",
PositionID: "2+4OAADb7g4AAA==",
MatchID: "",
Position1: [25]int{2, 2, 2, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Position2: [25]int{2, 2, 2, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Position1: [26]int{0, 2, 2, 2, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Position2: [26]int{0, 2, 2, 2, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
MatchKey: MatchKey{1, 0, 0, 0, 0, 0, 0, 0, [2]int{0, 0}, 0, [2]int{0, 0}},
},
wantErr: false,
Expand All @@ -285,8 +285,8 @@ func TestReadGnubgID(t *testing.T) {
ID: "cAlrAAAAAAAE",
PositionID: "",
MatchID: "cAlrAAAAAAAE",
Position1: [25]int{15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Position2: [25]int{15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Position1: [26]int{15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Position2: [26]int{15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
MatchKey: MatchKey{1, 3, 1, 0, 1, 1, 0, 0, [2]int{6, 2}, 3, [2]int{0, 0}},
},
wantErr: false,
Expand Down

0 comments on commit fa1fe91

Please sign in to comment.