Notice
Recent Posts
Recent Comments
Link
- Arawn's Dev Blog
- Outsider's Dev Story
- Toby's Epril
- Benelog
- NHN 개발자 블로그
- SK 플래닛 기술 블로그
- OLC CENTER
- 소프트웨어 경영/공학 블로그
- 모바일 컨버전스
- KOSR - Korea Operating System …
- 넥스트리 블로그
- 리버스코어 ReverseCore
- SLiPP
- 개발자를 위하여... (Nextree 임병인 수석)
- "트위터 부트스트랩: 디자이너도 놀라워할 매끈하고 직관…
- Learning English - The English…
- real-english.com
- 'DataScience/Deep Learning' 카테…
- Deep Learning Summer School, M…
- Deep Learning Courses
민서네집
[Python][PyCon 2016] 가위바위보 소스 본문
코딩배틀 가위바위보 in 파이콘 2016 APAC
http://tech.kakao.com/pycon2016apac/
https://www.facebook.com/seokjoon.yun.9/posts/1115414945195627
https://www.facebook.com/seokjoon.yun.9/posts/1115845348485920
윤석준 님 소스
import random
from collections import defaultdict
def get_index(probabilities):
max = sum(probabilities)
acc = 0
rand = random.random() * max
for idx, percent in enumerate(probabilities):
acc += percent
if rand < acc:
return idx
return len(probabilities)
GBB = ['gawi', 'bawi', 'bo']
def show_me_the_hand(records):
index = 0
if len(records) == 0:
index = get_index([1,1,1])
else:
enemyChoice = defaultdict(int)
#enemyScore = defaultdict(int)
for hand, score in records:
enemyChoice[hand] += 1
#enemyScore[hand] += 1
reference = [enemyChoice['bo'], enemyChoice['gawi'],enemyChoice['bawi'] ]
index = get_index(reference)
return GBB[index]
if __name__ == '__main__':
records = []
print(show_me_the_hand(records))
print(show_me_the_hand([('gawi',1), ('bo',1)]))
player.py'Python' 카테고리의 다른 글
| Windows 10 Ubuntu Bash Shell 에서 TensorFlow 설치하기 (2) | 2016.08.15 |
|---|---|
| Jupyter notebook에서 Root 디렉터리 들어가기 (0) | 2016.08.15 |
| Jupyter 에러 (Notebook does not appear to be JSON) (1) | 2016.08.07 |
| PyCharm 단축키 (0) | 2016.08.07 |
| Python Help (pdf, chm) (0) | 2016.08.07 |
Comments