안녕하세요. 첫 글은 가위바위보 승률 측정 프로그램입니다.
전 직장 문화중에 점심 먹고 가위바위보로 커피 내기하는 문화가 있었는데요~
당연히 확률은 1/3이지만 프로그래머로서 한번 만들어서 테스트하고 싶어서 심심풀이로 만들었습니다.
import java.util.Random;
public class RPSGame {
public static void main(String[] args) {
Random random = new Random();
int rock = 0;
int paper = 0;
int scissors = 0;
int repeat = 100000000;
for (int i = 0; i < repeat; i++) {
int computerChoice = random.nextInt(3) + 1;
int userChoice = random.nextInt(3) + 1;
if (computerChoice == 1) {
if (userChoice == 2) {
paper++;
} else if (userChoice == 3) {
rock++;
}
} else if (computerChoice == 2) {
if (userChoice == 1) {
scissors++;
} else if (userChoice == 3) {
paper++;
}
} else {
if (userChoice == 1) {
rock++;
} else if (userChoice == 2) {
scissors++;
}
}
}
System.out.println("Rock: " + (rock * 100.0 / repeat) + "%");
System.out.println("Paper: " + (paper * 100.0 / repeat) + "%");
System.out.println("Scissors: " + (scissors * 100.0 / repeat) + "%");
}
}
마지막으로 우리 DAN 선생님이 알려주신 가위바위보 주제에 관한 가장 영향력 있는 상위 5개 논문 목록 입니다!
- "The Mathematics of Rock-Paper-Scissors" by John Nash
- "Strategic Behavior in Rock-Paper-Scissors Games" by Ariel Rubinstein
- "The Evolution of Cooperation in Rock-Paper-Scissors Games" by Martin A. Nowak
- "The Psychology of Rock-Paper-Scissors: An Analysis of Decision-Making Strategies" by Smith & Jones
- "Behavioral Economics of Rock-Paper-Scissors: An Experiment" by Kim & Lee
개인적으로 주먹 승률이 꽤 높게 나와서 앞으로는 가위바위보 하면 주먹 낼 예정입니다~!
'As a developer > To kill time' 카테고리의 다른 글
프롬프트 엔지니어란? (적합한 사람 및 전망) (0) | 2023.03.18 |
---|---|
Chat GPT와 new bing 비교해보기 (0) | 2023.03.18 |
🚀개발자도 알아야 하는 마이크로서비스 아키텍처(MSA) (0) | 2023.03.04 |
[JAVA] 성능 최적화를 위한 이야기 (0) | 2023.02.22 |
ChatGPT의 탈옥방법 DAN + AI가 알려준 한국 주식 미래 (0) | 2023.02.18 |