On February 16, 2023, I became the first human being to play a complete game of shogi against ChatGPT.  I listed all legal moves on each of ChatGPT's turns using the python-shogi library and let them choose their move.

* Lishogi https://lishogi.org/pma1myEC
* Shogi Playground https://kifu.co/Zw7L

How I played against ChatGPT
----------------------------

My MacOS had the `python3` command installed.  I installed python-shogi and generated moves in the Python shell:

    % pip3 install python-shogi
    % python3

First, I loaded the library and generated the 30 possible first moves in random order:

    >>> import shogi; from random import shuffle; board = shogi.Board()
    >>> moves = list(map(str, board.legal_moves)); shuffle(moves); print(*moves, sep=", ")
    9g9f, 7i7h, 2h7h, 5i4h, 3g3f, 7g7f, 6i5h, 2g2f, 3i3h, 8g8f, 4i4h, 7i6h, 2h6h, 5g5f, 5i5h, 6g6f, 3i4h, 4i5h, 1i1h, 2h4h, 2h3h, 2h5h, 9i9h, 4i3h, 2h1h, 6i6h, 4g4f, 5i6h, 1g1f, 6i7h

Then I prompted ChatGPT with the following:

    Let's play shogi.  For each of your turns, I will list all the legal moves you can play in random order, in Universal Shogi Interface (USI) format.  Choose one of them.  Say only the move you want to play.  Don't say anything else.  No handicap, even game.  You are black (sente, the player who moves first).

    Your possible moves are: 9g9f, 7i7h, 2h7h, 5i4h, 3g3f, 7g7f, 6i5h, 2g2f, 3i3h, 8g8f, 4i4h, 7i6h, 2h6h, 5g5f, 5i5h, 6g6f, 3i4h, 4i5h, 1i1h, 2h4h, 2h3h, 2h5h, 9i9h, 4i3h, 2h1h, 6i6h, 4g4f, 5i6h, 1g1f, 6i7h

ChatGPT replied:

    2g2f

After some thought, I decided to respond with 3c3d.  I entered their move and mine into python-shogi, displayed the resulting position, and generated the next possible moves for ChatGPT in random order:

    >>> board.push_usi("2g2f"); board.push_usi("3c3d"); print(board); moves = list(map(str, board.legal_moves)); shuffle(moves); print(*moves, sep=", ")
    Move.from_usi('2g2f')
    Move.from_usi('3c3d')
     l  n  s  g  k  g  s  n  l
     .  r  .  .  .  .  .  b  .
     p  p  p  p  p  p  .  p  p
     .  .  .  .  .  .  p  .  .
     .  .  .  .  .  .  .  .  .
     .  .  .  .  .  .  .  P  .
     P  P  P  P  P  P  P  .  P
     .  B  .  .  .  .  .  R  .
     L  N  S  G  K  G  S  N  L
    5i5h, 2h2g, 3i3h, 7i6h, 2h7h, 8g8f, 2h6h, 6i6h, 2h5h, 1g1f, 3i4h, 7g7f, 5i6h, 6i7h, 9g9f, 2h1h, 2h3h, 4i5h, 2f2e, 3g3f, 6g6f, 6i5h, 9i9h, 4i4h, 4i3h, 5g5f, 4g4f, 5i4h, 2h4h, 1i1h, 7i7h

Then I replied to ChatGPT:

    My move is: 3c3d

    Your possible moves are: 5i5h, 2h2g, 3i3h, 7i6h, 2h7h, 8g8f, 2h6h, 6i6h, 2h5h, 1g1f, 3i4h, 7g7f, 5i6h, 6i7h, 9g9f, 2h1h, 2h3h, 4i5h, 2f2e, 3g3f, 6g6f, 6i5h, 9i9h, 4i4h, 4i3h, 5g5f, 4g4f, 5i4h, 2h4h, 1i1h, 7i7h

I repeated this process and ultimately said to ChatGPT every time:

    It's your turn.  Don't list moves.  That's what I do.  Say only the move you want to play.  Don't say anything else.  Choose one of them.

I created a shared link to the chat https://chat.openai.com/share/f406a004-ca2c-449d-b2ca-869f722dd458 (also uploaded to Pastebin https://pastebin.com/7qirN6mp). [^1]

The game
--------

I uploaded the game to Lishogi etc. as linked at the beginning.  Below can be read by GNU XShogi.

    # xshogi game file
    #

    1. 2g2f 3c3d 2. 7i6h 4c4d 3. 5i5h 8b4b 4. 4i4h 5a6b 5. 6i7h 6b7b
    6. 5h6i 7b8b 7. 6h7i 7a7b 8. 4h4i 3a3b 9. 2h5h 4a5b 10. 4i3h 3b4c
    11. 9g9f 9c9d 12. 9f9e 9d9e 13. 8g8f 4d4e 14. 3i4h 4c4d 15. 5g5f 4d3e
    16. 7g7f 4e4f 17. 8h2b 4b2b 18. B*6e 4f4g+ 19. 7h7g 4g5h 20. 6i5h 6c6d
    21. 6e7d 7c7d 22. P*9g 3e4f 23. 7g8g P*4g 24. 3h4g 4f4g 25. 5h5g 4g4h
    26. 5g6h B*5i 27. 6h6i B*4g 28. 6i7h R*5h 29. 7h6i 5h6h+

To install XShogi on MacOS Monterey, install Homebrew and run `brew install xshogi`.  However, when I ran `xshogi`, I got "Error: Can't open display: ".  I had to install XQuartz with `brew install --cask xquartz`, launch it from Launchpad, go to Applications > Customize, press Add Item, add the `xshogi` command with the name "XShogi" (or whatever), and go to Applications > XShogi to launch it.

[^1]: The log uploaded to Pastebin was generated by running the following JavaScript code in the Brave (i.e., Chromium) console on the chat page.  As of ChatGPT Feb 13 version, it renders the conversation in div elements with the `whitespace-pre-wrap` class.  (This may not work in the future.)

        copy([document.title, ...$$(".whitespace-pre-wrap").map((x, i) => `${i % 2 ? "ChatGPT" : "yuuki"}:\n${x.innerText}`)].join("\n\n---\n\n"))