Compare commits

..

9 commits

Author SHA1 Message Date
ccce457dfd
ci: another token
Some checks are pending
/ release (push) Waiting to run
2025-04-19 00:36:35 +02:00
6cc2457fc5
ci: s/GH_/GITHUB_/ 2025-04-19 00:35:35 +02:00
acc78aec77
ci: another token 2025-04-19 00:33:56 +02:00
68c928bd66
ci: delete release if it exists 2025-04-19 00:31:39 +02:00
61e9274fc1
ci: add token 2025-04-19 00:30:32 +02:00
cbface83ee
fix: python error 2025-04-18 21:40:41 +02:00
340b627df3
ci: update 2025-04-18 21:28:09 +02:00
1361237168
ci: first commit 2025-04-18 21:25:14 +02:00
f807011f79
chess: added knight moves 2025-04-18 20:18:00 +02:00
4 changed files with 30 additions and 17 deletions

18
.github/workflows/release.yaml vendored Normal file
View file

@ -0,0 +1,18 @@
on:
push:
branches: [main]
jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
- run: ./blind_chess.py
- env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
date=$(date +%y-%m-%d)
gh release delete --yes $date || :
gh release create --notes "" $date blind_chess.apkg

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.apkg

View file

@ -1,4 +1,7 @@
#!/usr/bin/env -S uv run --script
#
# Generates the blind_chess.apkg Anki Deck
#
# /// script
# requires-python = ">=3.13"
# dependencies = [
@ -12,14 +15,9 @@ import genanki
import chess
import chess.svg
deck = genanki.Deck(
2059400110,
'Blind Chess'
)
deck = genanki.Deck(2059400110, 'Blind Chess')
model= genanki.Model(
1120858226,
'Chess Model',
model = genanki.Model(1120858226, 'Chess Model',
fields=[
{'name': 'guid'},
{'name': 'Question'},
@ -30,7 +28,7 @@ model= genanki.Model(
{
'name': 'Base Card with SVG board in answer',
'qfmt': '{{Question}}',
'afmt': '{{FrontSide}}<hr id="answer">{{Answer} {{Board}}',
'afmt': '{{FrontSide}}<hr id="answer">{{Answer}} {{Board}}',
},
]
)
@ -38,7 +36,6 @@ model= genanki.Model(
class ChessNote(genanki.Note):
@property
def guid(self):
# slug-square-piece
return genanki.guid_for(self.fields[0])
def square_color(sq_name):
@ -58,25 +55,22 @@ def knight_moves(sq_name):
board.set_piece_at(sq_id, chess.Piece(chess.KNIGHT, chess.WHITE))
attacks = board.attacks(sq_id)
guid = f'{sq_name}-knight-moves' #guid
guid = f'{sq_name}-knight-moves'
question = f'Where can the knight move from square {sq_name}?'
answer = ', '.join(chess.SQUARE_NAMES[sq] for sq in list(attacks))
board_svg = chess.svg.board(board, fill=dict.fromkeys(attacks, "#cc0000cc"))
# return ChessNote(model, [guid, question, answer, board_svg])
return ChessNote(model, [guid,question,answer,board_svg])
return ChessNote(model, [guid, question, answer, board_svg])
def notes():
# square colors
for sq_name in chess.SQUARE_NAMES:
yield square_color(sq_name)
yield knight_moves(sq_name)
notes = list(notes())
# randomize the order of the notes
random.shuffle(notes)
for note in notes:
deck.add_note(note)
genanki.Package(deck).write_to_file('chess.apkg')
print(f'Created deck chess.apkg with {len(deck.notes)} notes')
out = 'blind_chess.apkg'
genanki.Package(deck).write_to_file(out)
print(f'Created deck {out} with {len(deck.notes)} notes')

Binary file not shown.