Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
對戰三平棋
Search
MarkFly
March 20, 2018
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
對戰三平棋
SIMPEI小遊戲實作分享 @ iOS Taipei
MarkFly
March 20, 2018
More Decks by MarkFly
See All by MarkFly
關於 Mobile Developer 用 Flutter 去寫 Web 這檔事
mark33699
0
29
關於我在 visionOS 上 寫影片貼圖 app 這檔事
mark33699
0
290
iOS、Android、Flutter超級比一比
mark33699
1
1k
如何使用Swift遙控你的樂高
mark33699
0
68
直播簡單講
mark33699
1
110
多執行緒編程
mark33699
0
64
演算法到底是在演哪一齣
mark33699
0
80
Other Decks in Programming
See All in Programming
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
330
Jetpack Compose メカニズム
skydoves
0
470
The Rails Doctrine Decade
koic
2
360
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.8k
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
390
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
4.4k
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
160
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
190
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
3.1k
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
160
Heart of Swift Concurrency
koher
0
960
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
360
Featured
See All Featured
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
The Invisible Side of Design
smashingmag
301
52k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
How to make the Groovebox
asonas
2
2.5k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
260
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
The Curse of the Amulet
leimatthew05
3
15k
Balancing Empowerment & Direction
lara
6
1.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Chasing Engaging Ingredients in Design
codingconduct
0
340
Transcript
對戰三平棋 ⼩遊戲實作分享 iOS@Taipei 2018/3/20
謝騰⾶ 前接案公司iOS⼯程師 前鼎新電腦ERP顧問 Line: ledway917 歡迎各種合作
https://www.youtube.com/watch?v=iGzv1t9rV0c
None
遊戲規則 • ⼈數: 2⼈ • 率先連成三⼦者獲勝 • 每⼈各4顆棋⼦ • 棋盤分成上下兩個世界
遊戲流程 1. 第⼀顆棋只能放在上界中間四個位置 2. 雙⽅輪流放⼦ 3. 雙⽅輪流走⼦(只能走到異界的相臨位置) 4. 若過程中我⽅在同⼀世界夾住對⽅棋⼦ 則我⽅可將該棋⼦移⾄任何位置
BUT • 連成四⼦不算 • 四⼦移走⼀顆也不算 • 吹走對⼿棋⼦連三還是不算 • ⾃⼰走到⼈家中間去被夾住................................不算
None
在圖片上疊⼀個透明的view view上⾯拉格⼦的imageView imageView⽤autoresize去配合圖片 棋盤是⼀張圖 如何在適應各種螢幕尺⼨的前提下 讓棋⼦可以對準裡⾯的格⼦
對棋⼦imageView加入⼿勢UIPanGestureRecognizer 拿到座標就去修改棋⼦imageView的center 如何讓棋⼦移動
遍歷所有的位置 去算該位置是否夠靠近(這邊要做誤差修正) 太遠則清空提⽰ 如何讓移動時格⼦出現提⽰
• 第⼀回合 • 寫死5,6,9,10 • 放⼦、吹⼦ • All You Can
Place 各階段如何判斷可不可下 showMoveHint
1. 先判斷天堂或地獄 2. 地獄:有公式 3. 天堂:四個⾓跟中間也有公式 4. 邊棋只好HardCode 5. PS.右圖x跟y顛倒了.......(懶得改圖了Orz)
比較難搞的是走⼦階段
1. 同⾊同界的棋⼦數⼤於3 1. 同界周圍(x或y相減絕對值為1)是否有同⾊棋(第⼆顆棋) 1. 有第三顆棋(註1) 1. 地獄 1. 贏了
2. 天堂 1. 沒有第四顆棋(註2) 1. 贏了 如何判斷是否連線 checkLink(currentChess:Chess)
思路:根據1號棋跟2號棋的相對位置推算3號棋的位置 1. 可能在中間、可能在旁邊 2. 從八個⽅向去發散 如何判斷有無第三顆棋 assign3rdChessXandY
思路:窮舉10條可能的路線, 是否都有同⾊的棋⼦ 1. 由現有棋盤上的棋⼦坐標算出序號(by公式) 2. [(0,1),(4,1),(8,1),(12,1),(0,4),(1,4),(2,4),(3,4),(0,5),(3,3)] //(從哪個開頭,遞增多少) 3. 展出每條路線的序號跟第⼀點比對 如何判斷有無第四顆棋
isLineFourChess
思路:跟找連線判斷類似 如何判斷是否夾⼦ checkBetween(currentChess:Chess) -> Chess?
對戰流程 1. 設定:開房間的⼈為主場, 主場⼀律紅棋 2. 若WaitingRoom裡無房就開房,反之加入 3. 有⼈加入有把房間移到MappedRoom(先刪後加) 4. 等⼈加入時,
取消或斷線要把WaitingRoom的資料刪除 5. 隨機決定誰先 6. 主場建立新比賽
Firebase function 1. Database.database().reference(withPath: ".info/connected") 2. onDisconnectRemoveValue 3. onDisconnectSetValue 4.
observeSingleEvent 1. childAdded 2. childRemoved 3. childChanged 4. childMoved 5. value 5. observe 6. removeAllObservers 7. childByAutoId 8. child 9. setValue 10. removeValue
監聽對象 1. 換⼿ 2. 對⼿走⼦ 3. 對⼿夾⼦ 4. 對⼿贏了 5.
對⼿投降 6. 續戰邀約 7. 建立新比賽
再來⼀碗
https://www.asovision.com/simpei/ 了解更多…
感謝聆聽 圖片來源http://en.aobo-shop.com/114-simpei-japanese.html