chessfidget - you call that chess?
TRANSCRIPT
ChessFidgetYou call that chess?
1
The itch
• Like to play chess
• Dislike losing so much
• Too much work to get good - (For me it would be a dangerous rabbit hole.)
2
The scratch
• Write software to address personal shortcomings
• ChessFidget: a chess app I (currently) always beat
3
Currently looks like thisIn lieu of a demo, I'll post code and (Mac) binaries
4
Dev goals/guidelines• Design for dopamine, not skill
- E.g. no move history
• Computer mostly plays worse chess than I do - Currently random moves - That will get boring; see above re: dopamine
• META: Exercise in Swift and reasoning about code - NOT an exercise in chess programming or AI
5
😬:Agonizing re: modeling• What are my objects? (Board, Piece, Move, ...)
• In how many places do "business rules" live? - E.g. MoveValidator and MoveGenerator - OTOH, might help with mutual unit-testing
• Sometimes the problem was a Swift difficulty - Extending Grid<T>, T is Piece? vs. T is Bool
• Sometimes the answer was a Swift feature - Type constraints?
6
"Move" as struct+moveTypeenum MoveType { case resignation case plainMove case pawnTwoSquares case captureEnPassant case pawnPromotion(type: PromotionType) case castleKingSide case castleQueenSide } struct Move { let start: Square let end: Square let type: MoveType }
7
Works fineawaitingHumanMoveInvalid move e1-g1: cannotCastleBecauseKingOrRookHasMovedd1-d2 (plainMove) played by White (Human)awaitingComputerMoveb8-d7 (plainMove) played by Black (Computer)awaitingHumanMovee1-c1 (castleQueenSide) played by White (Human)awaitingComputerMoved7-b6 (plainMove) played by Black (Computer)awaitingHumanMove
8
"Move" as class hierarchyprotocol MoveProtocol { func updateBoard(_ board: Board) } /* The classes would be something like: Move: MoveProtocol Resignation MoveWithStart PawnTwoSquares
CastleKingSide CastleQueenSide MoveWithStartAndEnd PlainMove CaptureEnPassant PawnPromotion */
9
😬:Swift overwhelm
• Building my mental model, esp. re: type system
• Finally past the squirmy phase! 😬➞😊 - New info now gets added to mental framework
• Maybe pairing would have helped?
10
Thoughts about learning
• Know thy brain - Came to terms with my jumpy learning - Shlemiel the painter (stay tuned for blog post)
• Be aware when/how reach out to people
11
Other thoughts• Wow do I suck at chess
• Does writing this app mean I'm a bully at heart?
• Am I weird for sensing uncanny illusion of intent? - Feels like it's capturing back "on purpose" - Feels intentional when it checks me - This despite knowing there is *zero* AI - WTF it played Fool's Mate
12
Actual early test (Computer=Black)(manually recreated; wish I'd taken a screenshot)
13
Next (current thinking)• Find a third-party library, add (weak) AI
• Distinguish between stalemate and checkmate
• Add keyboard input - Might help me learn algebraic notation
• Add multi-game play
• Move on to other project ideas
14