Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
對戰三平棋
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
MarkFly
March 20, 2018
Programming
0
150
對戰三平棋
SIMPEI小遊戲實作分享 @ iOS Taipei
MarkFly
March 20, 2018
Tweet
Share
More Decks by MarkFly
See All by MarkFly
關於 Mobile Developer 用 Flutter 去寫 Web 這檔事
mark33699
0
10
關於我在 visionOS 上 寫影片貼圖 app 這檔事
mark33699
0
130
iOS、Android、Flutter超級比一比
mark33699
1
970
如何使用Swift遙控你的樂高
mark33699
0
62
直播簡單講
mark33699
1
86
多執行緒編程
mark33699
0
49
演算法到底是在演哪一齣
mark33699
0
67
Other Decks in Programming
See All in Programming
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
980
Oxlint JS plugins
kazupon
1
980
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
dchart: charts from deck markup
ajstarks
3
1k
Raku Raku Notion 20260128
hareyakayuruyaka
0
340
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
600
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
380
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
CSC307 Lecture 04
javiergs
PRO
0
660
AI時代の認知負荷との向き合い方
optfit
0
160
CSC307 Lecture 01
javiergs
PRO
0
690
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
Featured
See All Featured
Accessibility Awareness
sabderemane
0
53
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
220
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
93
What's in a price? How to price your products and services
michaelherold
247
13k
Chasing Engaging Ingredients in Design
codingconduct
0
110
ラッコキーワード サービス紹介資料
rakko
1
2.3M
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
140
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