Artwork

محتوای ارائه شده توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones. تمام محتوای پادکست شامل قسمت‌ها، گرافیک‌ها و توضیحات پادکست مستقیماً توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones یا شریک پلتفرم پادکست آن‌ها آپلود و ارائه می‌شوند. اگر فکر می‌کنید شخصی بدون اجازه شما از اثر دارای حق نسخه‌برداری شما استفاده می‌کند، می‌توانید روندی که در اینجا شرح داده شده است را دنبال کنید.https://fa.player.fm/legal
Player FM - برنامه پادکست
با برنامه Player FM !

Episode 005: Tracking, for the Win

26:19
 
اشتراک گذاری
 

Manage episode 222354524 series 2463849
محتوای ارائه شده توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones. تمام محتوای پادکست شامل قسمت‌ها، گرافیک‌ها و توضیحات پادکست مستقیماً توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones یا شریک پلتفرم پادکست آن‌ها آپلود و ارائه می‌شوند. اگر فکر می‌کنید شخصی بدون اجازه شما از اثر دارای حق نسخه‌برداری شما استفاده می‌کند، می‌توانید روندی که در اینجا شرح داده شده است را دنبال کنید.https://fa.player.fm/legal

Nate tries to figure out who actually won this never-ending game of tic-tac-toe.

  • Tic-tac-toe is "just boring enough, just interesting enough."
  • How do we know who won the game? Inspect the board.
  • If you can track progress toward the win, you check for the win quickly
  • "Tic-tac-toe at scale!"
  • Tracer bullet: go simple, just examine the 8 options for winning
  • "In that case, nil has won...which is nobody."
  • Keep detection logic out of the high-level winner function--should read like a process description of steps.
  • Make new "verbs" like row-winner and column-winner and use those.
  • "You're just adding new verbs to raise Clojure up to the level of your problem. You can speak about your problem using those verbs."
  • Let's make it faster! Need incremental detection to be efficient.
  • Tracking structure with win condition totals
    • keys like: [player case index]
    • value is a counter for that case
    • eg. { [:x :row 0] 1, [:y :row 0] 0, [:x :diag] 2, ...}
  • The win tracker is a "nested model" of the game state
  • Put the tracker it its own namespace app.game.tracker
  • Use [:x 1 0] as the play
  • Nested updates: (update game-state :tracking tracker/update [:x 1 0])
  • How do we handle diagonals? Not all moves will increment those totals.
  • Make helpers for diag? and rdiag? to use in cond-> (see code below)
  • High-level functions describe the process. Low-level functions describe the steps.
  • "You can see the animal, not the intestines."
  • "If you see a word that's a higher level concept, it allows you to stay at that higher level and be able to view the algorithm instead of viewing the implementation. That's the point of lifting up all these little functions."
  • Bonus: the tracker tells us all the ways a player won.

Clojure in this episode:

  • nil punning streak: 3 episodes
  • get-in
  • update, update-in
  • or short circuits, = does not
  • ->, cond->, some->
  • frequencies
  • lists as "tuples" and "triples"

Code sample from this episode:

(ns app.game.tracker) (defn update [tracking [player row column]] (cond-> tracking true (record row column player) (diag? row column) (record-diag player) (rdiag? row column) (record-rdiag player))) 
  continue reading

118 قسمت

Artwork
iconاشتراک گذاری
 
Manage episode 222354524 series 2463849
محتوای ارائه شده توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones. تمام محتوای پادکست شامل قسمت‌ها، گرافیک‌ها و توضیحات پادکست مستقیماً توسط Christoph Neumann and Nate Jones, Christoph Neumann, and Nate Jones یا شریک پلتفرم پادکست آن‌ها آپلود و ارائه می‌شوند. اگر فکر می‌کنید شخصی بدون اجازه شما از اثر دارای حق نسخه‌برداری شما استفاده می‌کند، می‌توانید روندی که در اینجا شرح داده شده است را دنبال کنید.https://fa.player.fm/legal

Nate tries to figure out who actually won this never-ending game of tic-tac-toe.

  • Tic-tac-toe is "just boring enough, just interesting enough."
  • How do we know who won the game? Inspect the board.
  • If you can track progress toward the win, you check for the win quickly
  • "Tic-tac-toe at scale!"
  • Tracer bullet: go simple, just examine the 8 options for winning
  • "In that case, nil has won...which is nobody."
  • Keep detection logic out of the high-level winner function--should read like a process description of steps.
  • Make new "verbs" like row-winner and column-winner and use those.
  • "You're just adding new verbs to raise Clojure up to the level of your problem. You can speak about your problem using those verbs."
  • Let's make it faster! Need incremental detection to be efficient.
  • Tracking structure with win condition totals
    • keys like: [player case index]
    • value is a counter for that case
    • eg. { [:x :row 0] 1, [:y :row 0] 0, [:x :diag] 2, ...}
  • The win tracker is a "nested model" of the game state
  • Put the tracker it its own namespace app.game.tracker
  • Use [:x 1 0] as the play
  • Nested updates: (update game-state :tracking tracker/update [:x 1 0])
  • How do we handle diagonals? Not all moves will increment those totals.
  • Make helpers for diag? and rdiag? to use in cond-> (see code below)
  • High-level functions describe the process. Low-level functions describe the steps.
  • "You can see the animal, not the intestines."
  • "If you see a word that's a higher level concept, it allows you to stay at that higher level and be able to view the algorithm instead of viewing the implementation. That's the point of lifting up all these little functions."
  • Bonus: the tracker tells us all the ways a player won.

Clojure in this episode:

  • nil punning streak: 3 episodes
  • get-in
  • update, update-in
  • or short circuits, = does not
  • ->, cond->, some->
  • frequencies
  • lists as "tuples" and "triples"

Code sample from this episode:

(ns app.game.tracker) (defn update [tracking [player row column]] (cond-> tracking true (record row column player) (diag? row column) (record-diag player) (rdiag? row column) (record-rdiag player))) 
  continue reading

118 قسمت

همه قسمت ها

×
 
Loading …

به Player FM خوش آمدید!

Player FM در سراسر وب را برای یافتن پادکست های با کیفیت اسکن می کند تا همین الان لذت ببرید. این بهترین برنامه ی پادکست است که در اندروید، آیفون و وب کار می کند. ثبت نام کنید تا اشتراک های شما در بین دستگاه های مختلف همگام سازی شود.

 

راهنمای مرجع سریع

در حین کاوش به این نمایش گوش دهید
پخش