File size: 1,710 Bytes
3c88a0f
 
 
 
1
2
3
4
5
{"type": "session", "harness": "opencode", "id": "chess-0015", "name": "tactics"}
{"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}}
{"type": "message", "message": {"role": "user", "content": "What are the basic chess tactics (fork, pin, skewer, discovered attack, deflection, back-rank mate)? Define each and show a correct python-chess material evaluation. Include code examples."}}
{"type": "message", "message": {"role": "assistant", "content": "**1. Fork:** one piece attacks two+ pieces at once (e.g. Nf6+ forks king and queen).\n**2. Pin:** piece cannot move without exposing a more valuable piece (e.g. Bg5 pins Nf6 to queen).\n**3. Skewer:** reverse pin - valuable piece attacked first, must move, exposing behind.\n**4. Discovered attack:** moving one piece reveals an attack from another.\n**5. Deflection:** force a defender away from its duty.\n**6. Back-rank mate:** king trapped on 1st/8th rank by own pawns, mated by rook/queen.\n\n```python\nimport chess\n\ndef evaluate_material(board: chess.Board) -> int:\n    values = {chess.PAWN: 1, chess.KNIGHT: 3, chess.BISHOP: 3,\n              chess.ROOK: 5, chess.QUEEN: 9}\n    score = 0\n    for piece in board.piece_map().values():\n        v = values.get(piece.piece_type, 0)\n        score += v if piece.color == chess.WHITE else -v\n    return score\n```"}}