Skip to content

Commit cd1dbc6

Browse files
committed
docs: update README examples to use PushNotationMove for consistency
1 parent dd84264 commit cd1dbc6

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ fmt.Println(moves[0]) // b1a3
232232

233233
#### Parse Notation
234234

235-
Game's MoveStr method accepts string input using the default Algebraic Notation:
235+
PushNotationMove method accepts string input using any supported notation:
236236

237237
```go
238238
game := chess.NewGame()
239-
if err := game.MoveStr("e4"); err != nil {
239+
if err := game.PushNotationMove("e4", chess.AlgebraicNotation{}, nil); err != nil {
240240
// handle error
241241
}
242242
```
@@ -260,16 +260,16 @@ if len(validMoves) > 0 {
260260
}
261261

262262
// Using notation parsing with validation
263-
if err := game.MoveStr("e4"); err != nil {
263+
if err := game.PushNotationMove("e4", chess.AlgebraicNotation{}, nil); err != nil {
264264
fmt.Println("Move failed:", err)
265265
} else {
266266
fmt.Println("e4 move succeeded")
267267
}
268268

269269
// Invalid notation will be caught
270-
if err := game.MoveStr("e5"); err != nil {
270+
if err := game.PushNotationMove("e5", chess.AlgebraicNotation{}, nil); err != nil {
271271
fmt.Println("Move failed:", err)
272-
// Output: Move failed: [notation parsing error]
272+
// Output: Move failed: [invalid move error]
273273
}
274274
```
275275

@@ -301,10 +301,10 @@ Black wins by checkmate (Fool's Mate):
301301

302302
```go
303303
game := chess.NewGame()
304-
game.MoveStr("f3")
305-
game.MoveStr("e6")
306-
game.MoveStr("g4")
307-
game.MoveStr("Qh4")
304+
game.PushNotationMove("f3", chess.AlgebraicNotation{}, nil)
305+
game.PushNotationMove("e6", chess.AlgebraicNotation{}, nil)
306+
game.PushNotationMove("g4", chess.AlgebraicNotation{}, nil)
307+
game.PushNotationMove("Qh4", chess.AlgebraicNotation{}, nil)
308308
fmt.Println(game.Outcome()) // 0-1
309309
fmt.Println(game.Method()) // Checkmate
310310
/*
@@ -328,7 +328,7 @@ Black king has no safe move:
328328
fenStr := "k1K5/8/8/8/8/8/8/1Q6 w - - 0 1"
329329
fen, _ := chess.FEN(fenStr)
330330
game := chess.NewGame(fen)
331-
game.MoveStr("Qb6")
331+
game.PushNotationMove("Qb6", chess.AlgebraicNotation{}, nil)
332332
fmt.Println(game.Outcome()) // 1/2-1/2
333333
fmt.Println(game.Method()) // Stalemate
334334
/*
@@ -350,7 +350,7 @@ Black resigns and white wins:
350350

351351
```go
352352
game := chess.NewGame()
353-
game.MoveStr("f3")
353+
game.PushNotationMove("f3", chess.AlgebraicNotation{}, nil)
354354
game.Resign(chess.Black)
355355
fmt.Println(game.Outcome()) // 1-0
356356
fmt.Println(game.Method()) // Resignation
@@ -375,7 +375,7 @@ fmt.Println(game.Method()) // DrawOffer
375375
game := chess.NewGame()
376376
moves := []string{"Nf3", "Nf6", "Ng1", "Ng8", "Nf3", "Nf6", "Ng1", "Ng8"}
377377
for _, m := range moves {
378-
game.MoveStr(m)
378+
game.PushNotationMove(m, chess.AlgebraicNotation{}, nil)
379379
}
380380
fmt.Println(game.EligibleDraws()) // [DrawOffer ThreefoldRepetition]
381381
```
@@ -393,7 +393,7 @@ moves := []string{
393393
"Nf3", "Nf6", "Ng1", "Ng8",
394394
}
395395
for _, m := range moves {
396-
game.MoveStr(m)
396+
game.PushNotationMove(m, chess.AlgebraicNotation{}, nil)
397397
}
398398
fmt.Println(game.Outcome()) // 1/2-1/2
399399
fmt.Println(game.Method()) // FivefoldRepetition
@@ -418,7 +418,7 @@ According to [FIDE Laws of Chess Rule 9.6b](http://www.fide.com/component/handbo
418418
```go
419419
fen, _ := chess.FEN("2r3k1/1q1nbppp/r3p3/3pP3/pPpP4/P1Q2N2/2RN1PPP/2R4K b - b3 149 23")
420420
game := chess.NewGame(fen)
421-
game.MoveStr("Kf8")
421+
game.PushNotationMove("Kf8", chess.AlgebraicNotation{}, nil)
422422
fmt.Println(game.Outcome()) // 1/2-1/2
423423
fmt.Println(game.Method()) // SeventyFiveMoveRule
424424
```
@@ -478,8 +478,8 @@ Moves and tag pairs added to the PGN output:
478478
```go
479479
game := chess.NewGame()
480480
game.AddTagPair("Event", "F/S Return Match")
481-
game.MoveStr("e4")
482-
game.MoveStr("e5")
481+
game.PushNotationMove("e4", chess.AlgebraicNotation{}, nil)
482+
game.PushNotationMove("e5", chess.AlgebraicNotation{}, nil)
483483
fmt.Println(game)
484484
/*
485485
[Event "F/S Return Match"]
@@ -568,9 +568,9 @@ fmt.Println(pos.String()) // rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq
568568
[Algebraic Notation](https://en.wikipedia.org/wiki/Algebraic_notation_(chess)) (or Standard Algebraic Notation) is the official chess notation used by FIDE. Examples: e2, e5, O-O (short castling), e8=Q (promotion)
569569

570570
```go
571-
game := chess.NewGame(chess.UseNotation(chess.AlgebraicNotation{}))
572-
game.MoveStr("e4")
573-
game.MoveStr("e5")
571+
game := chess.NewGame()
572+
game.PushNotationMove("e4", chess.AlgebraicNotation{}, nil)
573+
game.PushNotationMove("e5", chess.AlgebraicNotation{}, nil)
574574
fmt.Println(game) // 1.e4 e5 *
575575
```
576576

@@ -579,11 +579,11 @@ fmt.Println(game) // 1.e4 e5 *
579579
[Long Algebraic Notation](https://en.wikipedia.org/wiki/Algebraic_notation_(chess)#Long_algebraic_notation) LongAlgebraicNotation is a more beginner friendly alternative to algebraic notation, where the origin of the piece is visible as well as the destination. Examples: Rd1xd8+, Ng8f6.
580580

581581
```go
582-
game := chess.NewGame(chess.UseNotation(chess.LongAlgebraicNotation{}))
583-
game.MoveStr("f2f3")
584-
game.MoveStr("e7e5")
585-
game.MoveStr("g2g4")
586-
game.MoveStr("Qd8h4")
582+
game := chess.NewGame()
583+
game.PushNotationMove("f2f3", chess.LongAlgebraicNotation{}, nil)
584+
game.PushNotationMove("e7e5", chess.LongAlgebraicNotation{}, nil)
585+
game.PushNotationMove("g2g4", chess.LongAlgebraicNotation{}, nil)
586+
game.PushNotationMove("Qd8h4", chess.LongAlgebraicNotation{}, nil)
587587
fmt.Println(game) // 1.f2f3 e7e5 2.g2g4 Qd8h4# 0-1
588588
```
589589

@@ -592,9 +592,9 @@ fmt.Println(game) // 1.f2f3 e7e5 2.g2g4 Qd8h4# 0-1
592592
UCI notation is a more computer friendly alternative to algebraic notation. This notation is the Universal Chess Interface notation. Examples: e2e4, e7e5, e1g1 (white short castling), e7e8q (for promotion)
593593

594594
```go
595-
game := chess.NewGame(chess.UseNotation(chess.UCINotation{}))
596-
game.MoveStr("e2e4")
597-
game.MoveStr("e7e5")
595+
game := chess.NewGame()
596+
game.PushNotationMove("e2e4", chess.UCINotation{}, nil)
597+
game.PushNotationMove("e7e5", chess.UCINotation{}, nil)
598598
fmt.Println(game) // 1.e2e4 e7e5 *
599599
```
600600

opening/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222

2323
func main(){
2424
g := chess.NewGame()
25-
g.MoveStr("e4")
26-
g.MoveStr("e6")
25+
g.PushNotationMove("e4", chess.AlgebraicNotation{}, nil)
26+
g.PushNotationMove("e6", chess.AlgebraicNotation{}, nil)
2727

2828
// print French Defense
2929
book := opening.NewBookECO()

0 commit comments

Comments
 (0)