Successfully reported this slideshow.

ChessFidget - You call that chess?



1 of 14
1 of 14

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

ChessFidget - You call that chess?

  1. 1. ChessFidget You call that chess? 1
  2. 2. 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
  3. 3. The scratch • Write software to address personal shortcomings • ChessFidget: a chess app I (currently) always beat 3
  4. 4. Currently looks like this In lieu of a demo, I'll post code and (Mac) binaries 4
  5. 5. 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
  6. 6. 😬: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
  7. 7. "Move" as struct+moveType enum 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
  8. 8. Works fine awaitingHumanMove Invalid move e1-g1: cannotCastleBecauseKingOrRookHasMoved d1-d2 (plainMove) played by White (Human) awaitingComputerMove b8-d7 (plainMove) played by Black (Computer) awaitingHumanMove e1-c1 (castleQueenSide) played by White (Human) awaitingComputerMove d7-b6 (plainMove) played by Black (Computer) awaitingHumanMove 8
  9. 9. "Move" as class hierarchy protocol MoveProtocol { func updateBoard(_ board: Board) } /* The classes would be something like: Move: MoveProtocol Resignation MoveWithStart PawnTwoSquares CastleKingSide CastleQueenSide MoveWithStartAndEnd PlainMove CaptureEnPassant PawnPromotion */ 9
  10. 10. 😬: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
  11. 11. 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
  12. 12. 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
  13. 13. Actual early test (Computer=Black) (manually recreated; wish I'd taken a screenshot) 13
  14. 14. 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