Pythonで野球の試合結果をシミュレートしてみた

### 前置き
Qiita Engineer Festa 2024に参加してから、この記事で19個目の記事投稿になる。

そこで、私はパッと思い浮かんだ。野球は、2つのチームが攻撃と守備を交代しながら、各頂点に4つのベースを持つ菱形の区画において、得点を競い合うスポーツである。基本的には、9イニング制で1番から9番まで選手がいて、３アウトで攻守交代になる。

### 以前3年前に作成したプログラムコード
```python
import random, math

max_inning = 9
team1, team2, hit = "", "", 0
inning, score1, score2 = 1, 0, 0
inscore, inscore1, inscore2 = 0, 0, 0
hitper, hitInt, outs = 101, -1, 0
manual, end, batter = False, True, False
players = [0, 0, 0, 0]

def hitsim(team, manual):
   global players, hitper, hit, batter, inscore, outs

   print("What does the " + team + " player hit?")

   if manual:
       valid = True
       while valid:
           hit = input()
           if not hit in ("0", "1", "2", "3", "4"):
               print ("Invalid input. Try again")
           else:
               hit = int(hit)
               break
   else:
       hitper= random.randint(0, 100)

   if hitper<60 or hit==0:
       hit = 0
       print(team + "'s player struck out.")
   elif hitper < 80 or hit==1:
       hit = 1
       print (team + "'s player hit a single.")
   elif hitper < 90 or hit==2:
       hit = 2
       print (team + "'s player hit a double.")
   elif hitper <95 or hit==3:
       hit = 3
       print (team + "'s player hit a triple.")
   else:
       hit = 4
       print (team + "'s player hit a home run!")


   #Arrays.sort(players);
   if hit != 0:
       for i in range(4):
           if players[i] == 0 and (players[(i+1) % 4]!= 0 or i == 3) and not batter:
               batter = True
               players[i] = hit
               for k in range(1, 4):
                   if players[k] !=0 and players[(k+3) % 4] >= players[k]:
                       players[k]= players[(k+3) % 4] + 1
               for k in range (4):
                   if players [k] >= 4:
                       inscore += 1
                       players [k] = 0
   else:
       outs += 1
   hit = -1
   hitper = 101
   batter = False


def runInning():
   global players, hitper, hit, batter, inscore, outs, inning, inscore1, inscore2, score1, score2
   print("Inning" + str(inning) + "\n")
   print("It's the " + team1 + "'s turn to bat.")
   inscore1 = 0
   for i in range(4):
       players[i] = 0
   while (outs < 3):
       hitsim(team1, manual)
   inscore1 = inscore
   inscore = 0
   outs = 0
   print("\nIt's the" + team2 + "'s turn to bat.")
   inscore2 = 0
   for i in range(4):
       players[i] = 0
   while (outs < 3):
       hitsim(team2, manual)
   inscore2 = inscore
   inscore = 0
   outs = 0
   print("\nInning " + str(inning) + " is now over. ")
   if (inscore1 > inscore2):
       print("The " + team1 + "'s won the inning with a score of " + str(inscore1) + " : " + str(inscore2) + ". ")
   elif (inscore2 > inscore1):
       print("The " + team2 + "'s won the inning with a score of " + str(inscore2) + " : " + str(inscore1) + ". ")
   else:
       print("The inning was tied with a score of " + str(inscore2) + " : " + str(inscore1) + ". " )
   score1 += inscore1
   score2 += inscore2
   print("The score is currently " + team2 + ": " + str(score2) + " | " + team1 + ": " + str(score1) + ".\n")
   inning += 1

def main():
   global end, team1, team2, manual, inning, score1, score2
   while end:
       print("Batter up!")
       print("Please input the name of the home team.")
       while team2 == "":
           team2 = input()
           if team2 == "":
               print("Invalid input. Please input a valid name.")
       print ("Please input the name of the away team.")
       while team1 == "" or team1 == team2:
           team1 = input()
           if team1 == "" or team1 == team2:
               print("Invalid input. Please input a valid name.")
       print("1: Manual\n2: Automatic")
       Manual_str = input()

       # check for invalid inputs
       while (not (Manual_str == "1" or Manual_str == "2")):
           print("Invalid input. Please input 1 or 2.")
           Manual_str = input()
       if (Manual_str == "1"):
           manual = True
           ## print out inputs
           print("\nTypes of hits\n0: Strike out\n1: Single\n2: Double\n3: Triple\n4: Home run")
       elif(Manual_str == "2"):
           manual = False
       print("")
       ## run at least 9 innings
       while (inning <= max_inning):
           runInning()
       while (score1 == score2):
           print("The game is tied. We must go to another inning.\n")
           runInning()
       print("Game over")
       if (score1 > score2):
           print("The " + team1 + "'s won with a score of " + str(score1) + " : " + str(score2))
       else:
           print("The " + team2 + "'s won with a score of " + str(score2) + " : " + str(score1))
       print("\n Would you like to simulate another game?\n1) Yes\n2) No")
       str_End = input()
       if (str_End == "1"):
           end = False
           print("")
           ## reset variables
           inning=1
           score1=0
           score2=0
       elif(str_End== "2"):
           end = True
           print("Program terminated.")
       else:
     
      end = True
           print("Invalid input. Program terminated.")

if __name__ == '__main__':
   #hitsim("test", True)

   #manual = True
   #runInning()
   main()
```
### プログラムコードの説明
このコードでできることは、ユーザに2つのチームを選択させて試合結果を出力している。簡単にいうと、野球の試合をシミュレートしている。

### 実際の出力結果
私は、阪神ファンであるため、野球界では伝統の一戦と良く言われている、阪神対巨人の試合をこのプログラムコードを用いて、シミュレートしてみた。

```python
Batter up!
Please input the name of the home team.
Hanshin Tigers
Please input the name of the away team.
Yomiuri Giants
1: Manual
2: Automatic
2

Inning1

It's the Yomiuri Giants's turn to bat.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a single.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.

It's theHanshin Tigers's turn to bat.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.

Inning 1 is now over. 
The inning was tied with a score of 0 : 0. 
The score is currently Hanshin Tigers: 0 | Yomiuri Giants: 0.

Inning2

It's the Yomiuri Giants's turn to bat.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a double.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.

It's theHanshin Tigers's turn to bat.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a double.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a triple.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.

Inning 2 is now over. 
The Hanshin Tigers's won the inning with a score of 3 : 0. 
The score is currently Hanshin Tigers: 3 | Yomiuri Giants: 0.

Inning3

It's the Yomiuri Giants's turn to bat.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a single.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a double.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.

It's theHanshin Tigers's turn to bat.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a double.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a home run!
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.

Inning 3 is now over. 
The Hanshin Tigers's won the inning with a score of 2 : 0. 
The score is currently Hanshin Tigers: 5 | Yomiuri Giants: 0.

Inning4

It's the Yomiuri Giants's turn to bat.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.

It's theHanshin Tigers's turn to bat.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.

Inning 4 is now over. 
The inning was tied with a score of 0 : 0. 
The score is currently Hanshin Tigers: 5 | Yomiuri Giants: 0.

Inning5

It's the Yomiuri Giants's turn to bat.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a single.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a single.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.

It's theHanshin Tigers's turn to bat.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a triple.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.

Inning 5 is now over. 
The Hanshin Tigers's won the inning with a score of 1 : 0. 
The score is currently Hanshin Tigers: 6 | Yomiuri Giants: 0.

Inning6

It's the Yomiuri Giants's turn to bat.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a home run!
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a triple.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.

It's theHanshin Tigers's turn to bat.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a double.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.

Inning 6 is now over. 
The Hanshin Tigers's won the inning with a score of 3 : 1. 
The score is currently Hanshin Tigers: 9 | Yomiuri Giants: 1.

Inning7

It's the Yomiuri Giants's turn to bat.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a double.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player hit a home run!
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.

It's theHanshin Tigers's turn to bat.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a double.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.

Inning 7 is now over. 
The Yomiuri Giants's won the inning with a score of 2 : 0. 
The score is currently Hanshin Tigers: 9 | Yomiuri Giants: 3.

Inning8

It's the Yomiuri Giants's turn to bat.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.

It's theHanshin Tigers's turn to bat.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.

Inning 8 is now over. 
The inning was tied with a score of 0 : 0. 
The score is currently Hanshin Tigers: 9 | Yomiuri Giants: 3.

Inning9

It's the Yomiuri Giants's turn to bat.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.
What does the Yomiuri Giants player hit?
Yomiuri Giants's player struck out.

It's theHanshin Tigers's turn to bat.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a double.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player hit a single.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.
What does the Hanshin Tigers player hit?
Hanshin Tigers's player struck out.

Inning 9 is now over. 
The Hanshin Tigers's won the inning with a score of 1 : 0. 
The score is currently Hanshin Tigers: 10 | Yomiuri Giants: 3.

Game over
The Hanshin Tigers's won with a score of 10 : 3

 Would you like to simulate another game?
1) Yes
2) No
2
Program terminated.
```
ここでは、阪神タイガースが10-3で勝利した。要するに、ユーザーが、2つのチームを入力さえすれば、野球の試合結果が出力される。

ゲームプレイを面白くするために、ここで、私はユーザーが2つのプロ野球チームを自由に選択させて、スタメンを決め、野球の試合をシミュレートできないか考えた。

### 改良したプログラムコード
``` python
import random

max_inning = 9
team1, team2, hit = "", "", 0
inning, score1, score2 = 1, 0, 0
inscore, inscore1, inscore2 = 0, 0, 0
hitper, hitInt, outs = 101, -1, 0
manual, end, batter = False, True, False
players = [0, 0, 0, 0]

team1_lineup = []
team2_lineup = []

def hitsim(team, manual, player_name):
    global players, hitper, hit, batter, inscore, outs

    print(f"What does {team}'s player {player_name} hit?")

    if manual:
        valid = True
        while valid:
            hit = input()
            if not hit in ("0", "1", "2", "3", "4"):
                print("Invalid input. Try again")
            else:
                hit = int(hit)
                break
    else:
        hitper = random.randint(0, 100)

    if hitper < 60 or hit == 0:
        hit = 0
        print(f"{team}'s player {player_name} struck out.")
    elif hitper < 80 or hit == 1:
        hit = 1
        print(f"{team}'s player {player_name} hit a single.")
    elif hitper < 90 or hit == 2:
        hit = 2
        print(f"{team}'s player {player_name} hit a double.")
    elif hitper < 95 or hit == 3:
        hit = 3
        print(f"{team}'s player {player_name} hit a triple.")
    else:
        hit = 4
        print(f"{team}'s player {player_name} hit a home run!")

    if hit != 0:
        for i in range(4):
            if players[i] == 0 and (players[(i+1) % 4] != 0 or i == 3) and not batter:
                batter = True
                players[i] = hit
                for k in range(1, 4):
                    if players[k] != 0 and players[(k+3) % 4] >= players[k]:
                        players[k] = players[(k+3) % 4] + 1
                for k in range(4):
                    if players[k] >= 4:
                        inscore += 1
                        players[k] = 0
    else:
        outs += 1
    hit = -1
    hitper = 101
    batter = False

def runInning():
    global players, hitper, hit, batter, inscore, outs, inning, inscore1, inscore2, score1, score2
    print("Inning " + str(inning) + "\n")
    print("It's the " + team1 + "'s turn to bat.")
    inscore1 = 0
    for i in range(4):
        players[i] = 0
    outs = 0
    for player_name in team1_lineup:
        if outs < 3:
            hitsim(team1, manual, player_name)
        else:
            break
    inscore1 = inscore
    inscore = 0
    outs = 0
    print("\nIt's the " + team2 + "'s turn to bat.")
    inscore2 = 0
    for i in range(4):
        players[i] = 0
    outs = 0
    for player_name in team2_lineup:
        if outs < 3:
            hitsim(team2, manual, player_name)
        else:
            break
    inscore2 = inscore
    inscore = 0
    outs = 0
    print("\nInning " + str(inning) + " is now over. ")
    if inscore1 > inscore2:
        print("The " + team1 + " won the inning with a score of " + str(inscore1) + " : " + str(inscore2) + ". ")
    elif inscore2 > inscore1:
        print("The " + team2 + " won the inning with a score of " + str(inscore2) + " : " + str(inscore1) + ". ")
    else:
        print("The inning was tied with a score of " + str(inscore2) + " : " + str(inscore1) + ". ")
    score1 += inscore1
    score2 += inscore2
    print("The score is currently " + team2 + ": " + str(score2) + " | " + team1 + ": " + str(score1) + ".\n")
    inning += 1

def main():
    global end, team1, team2, manual, inning, score1, score2, team1_lineup, team2_lineup
    while end:
        print("Batter up!")
        print("Please input the name of the home team.")
        while team2 == "":
            team2 = input()
            if team2 == "":
                print("Invalid input. Please input a valid name.")
        print("Please input the name of the away team.")
        while team1 == "" or team1 == team2:
            team1 = input()
            if team1 == "" or team1 == team2:
                print("Invalid input. Please input a valid name.")

        print("Enter the starting lineup for " + team1 + " (9 players):")
        team1_lineup = [input(f"Player {i+1} name: ") for i in range(9)]

        print("Enter the starting lineup for " + team2 + " (9 players):")
        team2_lineup = [input(f"Player {i+1} name: ") for i in range(9)]

        print("1: Manual\n2: Automatic")
        Manual_str = input()

        while not (Manual_str == "1" or Manual_str == "2"):
            print("Invalid input. Please input 1 or 2.")
            Manual_str = input()
        if Manual_str == "1":
            manual = True
            print("\nTypes of hits\n0: Strike out\n1: Single\n2: Double\n3: Triple\n4: Home run")
        elif Manual_str == "2":
            manual = False
        print("")

        while inning <= max_inning:
            runInning()
        while score1 == score2:
            print("The game is tied. We must go to another inning.\n")
            runInning()
        print("Game over")
        if score1 > score2:
            print("The " + team1 + " won with a score of " + str(score1) + " : " + str(score2))
        else:
            print("The " + team2 + " won with a score of " + str(score2) + " : " + str(score1))
        print("\nWould you like to simulate another game?\n1) Yes\n2) No")
        str_End = input()
        if str_End == "1":
            end = True
            inning = 1
            score1 = 0
            score2 = 0
            team1 = ""
            team2 = ""
            team1_lineup = []
            team2_lineup = []
        elif str_End == "2":
            end = False
            print("Program terminated.")
        else:
            end = False
            print("Invalid input. Program terminated.")

if __name__ == '__main__':
    main()
```
ここでは、指名打者制を用いて、侍ジャパンのWBC2023アメリカ戦決勝戦のスタメン対
阪神タイガースで試合を行った。

### 実際の出力結果
```python
Batter up!
Please input the name of the home team.
Hanshin Tigers
Please input the name of the away team.
Samurai Japan
Enter the starting lineup for Samurai Japan (9 players):
Player 1 name: Lars Nootbar
Player 2 name: Kensuke Kondoh
Player 3 name: Shohei Ohtani
Player 4 name: Masataka Yoshida
Player 5 name: Munetaka Murakami
Player 6 name: Kazuma Okamoto
Player 7 name: Tetsuto Yamada
Player 8 name: Sosuke Genda
Player 9 name: Yuhei Nakamura
Enter the starting lineup for Hanshin Tigers (9 players):
Player 1 name: Koji Chikamoto
Player 2 name: Takumu Nakano
Player 3 name: Shota Morishita
Player 4 name: Yusuke Ohyama
Player 5 name: Teruaki Sato
Player 6 name: Sheldon Neuse
Player 7 name: Ukyo Maegawa
Player 8 name: Seiya Kinami
Player 9 name: Seishiro Sakamoto
1: Manual
2: Automatic
2

Inning 1

It's the Samurai Japan's turn to bat.
What does Samurai Japan's player Lars Nootbar hit?
Samurai Japan's player Lars Nootbar struck out.
What does Samurai Japan's player Kensuke Kondoh hit?
Samurai Japan's player Kensuke Kondoh struck out.
What does Samurai Japan's player Shohei Ohtani hit?
Samurai Japan's player Shohei Ohtani hit a single.
What does Samurai Japan's player Masataka Yoshida hit?
Samurai Japan's player Masataka Yoshida struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Koji Chikamoto hit?
Hanshin Tigers's player Koji Chikamoto hit a home run!
What does Hanshin Tigers's player Takumu Nakano hit?
Hanshin Tigers's player Takumu Nakano hit a double.
What does Hanshin Tigers's player Shota Morishita hit?
Hanshin Tigers's player Shota Morishita struck out.
What does Hanshin Tigers's player Yusuke Ohyama hit?
Hanshin Tigers's player Yusuke Ohyama struck out.
What does Hanshin Tigers's player Teruaki Sato hit?
Hanshin Tigers's player Teruaki Sato struck out.

Inning 1 is now over. 
The Hanshin Tigers won the inning with a score of 1 : 0. 
The score is currently Hanshin Tigers: 1 | Samurai Japan: 0.

Inning 2

It's the Samurai Japan's turn to bat.
What does Samurai Japan's player Lars Nootbar hit?
Samurai Japan's player Lars Nootbar hit a double.
What does Samurai Japan's player Kensuke Kondoh hit?
Samurai Japan's player Kensuke Kondoh hit a home run!
What does Samurai Japan's player Shohei Ohtani hit?
Samurai Japan's player Shohei Ohtani struck out.
What does Samurai Japan's player Masataka Yoshida hit?
Samurai Japan's player Masataka Yoshida hit a double.
What does Samurai Japan's player Munetaka Murakami hit?
Samurai Japan's player Munetaka Murakami struck out.
What does Samurai Japan's player Kazuma Okamoto hit?
Samurai Japan's player Kazuma Okamoto hit a single.
What does Samurai Japan's player Tetsuto Yamada hit?
Samurai Japan's player Tetsuto Yamada struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Koji Chikamoto hit?
Hanshin Tigers's player Koji Chikamoto hit a single.
What does Hanshin Tigers's player Takumu Nakano hit?
Hanshin Tigers's player Takumu Nakano struck out.
What does Hanshin Tigers's player Shota Morishita hit?
Hanshin Tigers's player Shota Morishita hit a single.
What does Hanshin Tigers's player Yusuke Ohyama hit?
Hanshin Tigers's player Yusuke Ohyama struck out.
What does Hanshin Tigers's player Teruaki Sato hit?
Hanshin Tigers's player Teruaki Sato struck out.

Inning 2 is now over. 
The Samurai Japan won the inning with a score of 2 : 0. 
The score is currently Hanshin Tigers: 1 | Samurai Japan: 2.

Inning 3

It's the Samurai Japan's turn to bat.
What does Samurai Japan's player Lars Nootbar hit?
Samurai Japan's player Lars Nootbar hit a single.
What does Samurai Japan's player Kensuke Kondoh hit?
Samurai Japan's player Kensuke Kondoh hit a double.
What does Samurai Japan's player Shohei Ohtani hit?
Samurai Japan's player Shohei Ohtani struck out.
What does Samurai Japan's player Masataka Yoshida hit?
Samurai Japan's player Masataka Yoshida hit a single.
What does Samurai Japan's player Munetaka Murakami hit?
Samurai Japan's player Munetaka Murakami struck out.
What does Samurai Japan's player Kazuma Okamoto hit?
Samurai Japan's player Kazuma Okamoto hit a single.
What does Samurai Japan's player Tetsuto Yamada hit?
Samurai Japan's player Tetsuto Yamada struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Koji Chikamoto hit?
Hanshin Tigers's player Koji Chikamoto struck out.
What does Hanshin Tigers's player Takumu Nakano hit?
Hanshin Tigers's player Takumu Nakano struck out.
What does Hanshin Tigers's player Shota Morishita hit?
Hanshin Tigers's player Shota Morishita struck out.

Inning 3 is now over. 
The Samurai Japan won the inning with a score of 1 : 0. 
The score is currently Hanshin Tigers: 1 | Samurai Japan: 3.

Inning 4

It's the Samurai Japan's turn to bat.
What does Samurai Japan's player Lars Nootbar hit?
Samurai Japan's player Lars Nootbar struck out.
What does Samurai Japan's player Kensuke Kondoh hit?
Samurai Japan's player Kensuke Kondoh hit a single.
What does Samurai Japan's player Shohei Ohtani hit?
Samurai Japan's player Shohei Ohtani hit a single.
What does Samurai Japan's player Masataka Yoshida hit?
Samurai Japan's player Masataka Yoshida struck out.
What does Samurai Japan's player Munetaka Murakami hit?
Samurai Japan's player Munetaka Murakami struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Koji Chikamoto hit?
Hanshin Tigers's player Koji Chikamoto struck out.
What does Hanshin Tigers's player Takumu Nakano hit?
Hanshin Tigers's player Takumu Nakano struck out.
What does Hanshin Tigers's player Shota Morishita hit?
Hanshin Tigers's player Shota Morishita struck out.

Inning 4 is now over. 
The inning was tied with a score of 0 : 0. 
The score is currently Hanshin Tigers: 1 | Samurai Japan: 3.

Inning 5

It's the Samurai Japan's turn to bat.
What does Samurai Japan's player Lars Nootbar hit?
Samurai Japan's player Lars Nootbar hit a single.
What does Samurai Japan's player Kensuke Kondoh hit?
Samurai Japan's player Kensuke Kondoh struck out.
What does Samurai Japan's player Shohei Ohtani hit?
Samurai Japan's player Shohei Ohtani hit a triple.
What does Samurai Japan's player Masataka Yoshida hit?
Samurai Japan's player Masataka Yoshida hit a single.
What does Samurai Japan's player Munetaka Murakami hit?
Samurai Japan's player Munetaka Murakami struck out.
What does Samurai Japan's player Kazuma Okamoto hit?
Samurai Japan's player Kazuma Okamoto hit a double.
What does Samurai Japan's player Tetsuto Yamada hit?
Samurai Japan's player Tetsuto Yamada struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Koji Chikamoto hit?
Hanshin Tigers's player Koji Chikamoto hit a double.
What does Hanshin Tigers's player Takumu Nakano hit?
Hanshin Tigers's player Takumu Nakano struck out.
What does Hanshin Tigers's player Shota Morishita hit?
Hanshin Tigers's player Shota Morishita struck out.
What does Hanshin Tigers's player Yusuke Ohyama hit?
Hanshin Tigers's player Yusuke Ohyama struck out.

Inning 5 is now over. 
The Samurai Japan won the inning with a score of 2 : 0. 
The score is currently Hanshin Tigers: 1 | Samurai Japan: 5.

Inning 6

It's the Samurai Japan's turn to bat.
What does Samurai Japan's player Lars Nootbar hit?
Samurai Japan's player Lars Nootbar struck out.
What does Samurai Japan's player Kensuke Kondoh hit?
Samurai Japan's player Kensuke Kondoh struck out.
What does Samurai Japan's player Shohei Ohtani hit?
Samurai Japan's player Shohei Ohtani hit a double.
What does Samurai Japan's player Masataka Yoshida hit?
Samurai Japan's player Masataka Yoshida struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Koji Chikamoto hit?
Hanshin Tigers's player Koji Chikamoto struck out.
What does Hanshin Tigers's player Takumu Nakano hit?
Hanshin Tigers's player Takumu Nakano hit a single.
What does Hanshin Tigers's player Shota Morishita hit?
Hanshin Tigers's player Shota Morishita hit a triple.
What does Hanshin Tigers's player Yusuke Ohyama hit?
Hanshin Tigers's player Yusuke Ohyama hit a double.
What does Hanshin Tigers's player Teruaki Sato hit?
Hanshin Tigers's player Teruaki Sato struck out.
What does Hanshin Tigers's player Sheldon Neuse hit?
Hanshin Tigers's player Sheldon Neuse struck out.

Inning 6 is now over. 
The Hanshin Tigers won the inning with a score of 1 : 0. 
The score is currently Hanshin Tigers: 2 | Samurai Japan: 5.

Inning 7

It's the Samurai Japan's turn to bat.
What does Samurai Japan's player Lars Nootbar hit?
Samurai Japan's player Lars Nootbar hit a single.
What does Samurai Japan's player Kensuke Kondoh hit?
Samurai Japan's player Kensuke Kondoh struck out.
What does Samurai Japan's player Shohei Ohtani hit?
Samurai Japan's player Shohei Ohtani struck out.
What does Samurai Japan's player Masataka Yoshida hit?
Samurai Japan's player Masataka Yoshida struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Koji Chikamoto hit?
Hanshin Tigers's player Koji Chikamoto struck out.
What does Hanshin Tigers's player Takumu Nakano hit?
Hanshin Tigers's player Takumu Nakano hit a home run!
What does Hanshin Tigers's player Shota Morishita hit?
Hanshin Tigers's player Shota Morishita struck out.
What does Hanshin Tigers's player Yusuke Ohyama hit?
Hanshin Tigers's player Yusuke Ohyama struck out.

Inning 7 is now over. 
The Hanshin Tigers won the inning with a score of 1 : 0. 
The score is currently Hanshin Tigers: 3 | Samurai Japan: 5.

Inning 8

It's the Samurai Japan's turn to bat.
What does Samurai Japan's player Lars Nootbar hit?
Samurai Japan's player Lars Nootbar hit a single.
What does Samurai Japan's player Kensuke Kondoh hit?
Samurai Japan's player Kensuke Kondoh struck out.
What does Samurai Japan's player Shohei Ohtani hit?
Samurai Japan's player Shohei Ohtani hit a single.
What does Samurai Japan's player Masataka Yoshida hit?
Samurai Japan's player Masataka Yoshida struck out.
What does Samurai Japan's player Munetaka Murakami hit?
Samurai Japan's player Munetaka Murakami struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Koji Chikamoto hit?
Hanshin Tigers's player Koji Chikamoto hit a home run!
What does Hanshin Tigers's player Takumu Nakano hit?
Hanshin Tigers's player Takumu Nakano struck out.
What does Hanshin Tigers's player Shota Morishita hit?
Hanshin Tigers's player Shota Morishita hit a double.
What does Hanshin Tigers's player Yusuke Ohyama hit?
Hanshin Tigers's player Yusuke Ohyama hit a home run!
What does Hanshin Tigers's player Teruaki Sato hit?
Hanshin Tigers's player Teruaki Sato hit a single.
What does Hanshin Tigers's player Sheldon Neuse hit?
Hanshin Tigers's player Sheldon Neuse hit a single.
What does Hanshin Tigers's player Ukyo Maegawa hit?
Hanshin Tigers's player Ukyo Maegawa struck out.
What does Hanshin Tigers's player Seiya Kinami hit?
Hanshin Tigers's player Seiya Kinami hit a double.
What does Hanshin Tigers's player Seishiro Sakamoto hit?
Hanshin Tigers's player Seishiro Sakamoto hit a home run!

Inning 8 is now over. 
The Hanshin Tigers won the inning with a score of 7 : 0. 
The score is currently Hanshin Tigers: 10 | Samurai Japan: 5.

Inning 9

It's the Samurai Japan's turn to bat.
What does Samurai Japan's player Lars Nootbar hit?
Samurai Japan's player Lars Nootbar hit a single.
What does Samurai Japan's player Kensuke Kondoh hit?
Samurai Japan's player Kensuke Kondoh struck out.
What does Samurai Japan's player Shohei Ohtani hit?
Samurai Japan's player Shohei Ohtani hit a home run!
What does Samurai Japan's player Masataka Yoshida hit?
Samurai Japan's player Masataka Yoshida struck out.
What does Samurai Japan's player Munetaka Murakami hit?
Samurai Japan's player Munetaka Murakami struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Koji Chikamoto hit?
Hanshin Tigers's player Koji Chikamoto hit a single.
What does Hanshin Tigers's player Takumu Nakano hit?
Hanshin Tigers's player Takumu Nakano struck out.
What does Hanshin Tigers's player Shota Morishita hit?
Hanshin Tigers's player Shota Morishita hit a double.
What does Hanshin Tigers's player Yusuke Ohyama hit?
Hanshin Tigers's player Yusuke Ohyama struck out.
What does Hanshin Tigers's player Teruaki Sato hit?
Hanshin Tigers's player Teruaki Sato struck out.

Inning 9 is now over. 
The Samurai Japan won the inning with a score of 2 : 0. 
The score is currently Hanshin Tigers: 10 | Samurai Japan: 7.

Game over
The Hanshin Tigers won with a score of 10 : 7

Would you like to simulate another game?
1) Yes
2) No
2
Program terminated.
```
ここでは、阪神タイガースが10-7で侍ジャパンに勝利を収めた。

余談にはなるが、今夜の阪神戦の試合結果も予測しておく。
```python
import random

max_inning = 9
team1, team2 = "", ""
inning, score1, score2 = 1, 0, 0
manual, end = False, True

team1_lineup = []
team2_lineup = []

def hitsim(team, manual, player_name):
    global inscore, outs
    hit = 0

    print(f"What does {team}'s player {player_name} hit?")

    if manual:
        valid = True
        while valid:
            hit = input()
            if not hit in ("0", "1", "2", "3", "4"):
                print("Invalid input. Try again")
            else:
                hit = int(hit)
                break
    else:
        hitper = random.randint(0, 100)
        if hitper < 60:
            hit = 0
        elif hitper < 80:
            hit = 1
        elif hitper < 90:
            hit = 2
        elif hitper < 95:
            hit = 3
        else:
            hit = 4

    if hit == 0:
        print(f"{team}'s player {player_name} struck out.")
        outs += 1
    elif hit == 1:
        print(f"{team}'s player {player_name} hit a single.")
        inscore += 1  # シンプルなシミュレーションのため、シングルヒットで1得点とする
    elif hit == 2:
        print(f"{team}'s player {player_name} hit a double.")
        inscore += 2  # シンプルなシミュレーションのため、ダブルヒットで2得点とする
    elif hit == 3:
        print(f"{team}'s player {player_name} hit a triple.")
        inscore += 3  # シンプルなシミュレーションのため、トリプルヒットで3得点とする
    elif hit == 4:
        print(f"{team}'s player {player_name} hit a home run!")
        inscore += 4  # シンプルなシミュレーションのため、ホームランで4得点とする

def play_half_inning(team, lineup):
    global inscore, outs
    outs = 0
    inscore = 0
    for player_name in lineup:
        if outs < 3:
            hitsim(team, manual, player_name)
        else:
            break
    return inscore

def runInning():
    global inning, score1, score2

    print(f"Inning {inning}\n")

    # Away team bats first
    print(f"It's the {team1}'s turn to bat.")
    team1_inning_score = play_half_inning(team1, team1_lineup)

    # Home team bats second
    print(f"\nIt's the {team2}'s turn to bat.")
    team2_inning_score = play_half_inning(team2, team2_lineup)

    print(f"\nInning {inning} is now over.")
    if team1_inning_score > team2_inning_score:
        print(f"The {team1} won the inning with a score of {team1_inning_score} : {team2_inning_score}.")
    elif team2_inning_score > team1_inning_score:
        print(f"The {team2} won the inning with a score of {team2_inning_score} : {team1_inning_score}.")
    else:
        print(f"The inning was tied with a score of {team1_inning_score} : {team2_inning_score}.")

    score1 += team1_inning_score
    score2 += team2_inning_score
    print(f"The score is currently {team2}: {score2} | {team1}: {score1}.\n")
    inning += 1

def main():
    global end, team1, team2, manual, inning, score1, score2, team1_lineup, team2_lineup
    while end:
        print("Batter up!")
        print("Please input the name of the home team.")
        while team2 == "":
            team2 = input()
            if team2 == "":
                print("Invalid input. Please input a valid name.")
        print("Please input the name of the away team.")
        while team1 == "" or team1 == team2:
            team1 = input()
            if team1 == "" or team1 == team2:
                print("Invalid input. Please input a valid name.")

        print(f"Enter the starting lineup for {team1} (9 players):")
        team1_lineup = [input(f"Player {i+1} name: ") for i in range(9)]

        print(f"Enter the starting lineup for {team2} (9 players):")
        team2_lineup = [input(f"Player {i+1} name: ") for i in range(9)]

        print("1: Manual\n2: Automatic")
        Manual_str = input()

        while not (Manual_str == "1" or Manual_str == "2"):
            print("Invalid input. Please input 1 or 2.")
            Manual_str = input()
        if Manual_str == "1":
            manual = True
            print("\nTypes of hits\n0: Strike out\n1: Single\n2: Double\n3: Triple\n4: Home run")
        elif Manual_str == "2":
            manual = False
        print("")

        while inning <= max_inning:
            runInning()
        while score1 == score2:
            print("The game is tied. We must go to another inning.\n")
            runInning()
        print("Game over")
        if score1 > score2:
            print(f"The {team1} won with a score of {score1} : {score2}")
        else:
            print(f"The {team2} won with a score of {score2} : {score1}")
        print("\nWould you like to simulate another game?\n1) Yes\n2) No")
        str_End = input()
        if str_End == "1":
            end = True
            inning = 1
            score1 = 0
            score2 = 0
            team1 = ""
            team2 = ""
            team1_lineup = []
            team2_lineup = []
        elif str_End == "2":
            end = False
            print("Program terminated.")
        else:
            end = False
            print("Invalid input. Program terminated.")

if __name__ == '__main__':
    main()
```
### 出力結果
```python
Batter up!
Please input the name of the home team.
Hanshin Tigers
Please input the name of the away team.
Yokohama DeNA Baystars
Enter the starting lineup for Yokohama DeNA Baystars (9 players):
Player 1 name: Kuwahara  
Player 2 name: Watarai
Player 3 name: Austin
Player 4 name: Maki
Player 5 name: Miyazaki
Player 6 name: Tsutsugoh
Player 7 name: Yamamoto
Player 8 name: Mori
Player 9 name: Jackson
Enter the starting lineup for Hanshin Tigers (9 players):
Player 1 name: Chikamoto
Player 2 name: Nakano
Player 3 name: Morishita
Player 4 name: Ohyama
Player 5 name: Maegawa
Player 6 name: Sato
Player 7 name: Umeno
Player 8 name: Obata
Player 9 name: Nishi
1: Manual
2: Automatic
2

Inning 1

It's the Yokohama DeNA Baystars's turn to bat.
What does Yokohama DeNA Baystars's player   桑Kuwahara hit?
Yokohama DeNA Baystars's player     桑Kuwahara struck out.
What does Yokohama DeNA Baystars's player Watarai hit?
Yokohama DeNA Baystars's player Watarai struck out.
What does Yokohama DeNA Baystars's player Austin hit?
Yokohama DeNA Baystars's player Austin struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Chikamoto hit?
Hanshin Tigers's player Chikamoto hit a triple.
What does Hanshin Tigers's player Nakano hit?
Hanshin Tigers's player Nakano struck out.
What does Hanshin Tigers's player Morishita hit?
Hanshin Tigers's player Morishita hit a single.
What does Hanshin Tigers's player Ohyama hit?
Hanshin Tigers's player Ohyama struck out.
What does Hanshin Tigers's player Maegawa hit?
Hanshin Tigers's player Maegawa struck out.

Inning 1 is now over.
The Hanshin Tigers won the inning with a score of 4 : 0.
The score is currently Hanshin Tigers: 4 | Yokohama DeNA Baystars: 0.

Inning 2

It's the Yokohama DeNA Baystars's turn to bat.
What does Yokohama DeNA Baystars's player   桑Kuwahara hit?
Yokohama DeNA Baystars's player     桑Kuwahara struck out.
What does Yokohama DeNA Baystars's player Watarai hit?
Yokohama DeNA Baystars's player Watarai hit a single.
What does Yokohama DeNA Baystars's player Austin hit?
Yokohama DeNA Baystars's player Austin struck out.
What does Yokohama DeNA Baystars's player Maki hit?
Yokohama DeNA Baystars's player Maki struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Chikamoto hit?
Hanshin Tigers's player Chikamoto hit a single.
What does Hanshin Tigers's player Nakano hit?
Hanshin Tigers's player Nakano struck out.
What does Hanshin Tigers's player Morishita hit?
Hanshin Tigers's player Morishita struck out.
What does Hanshin Tigers's player Ohyama hit?
Hanshin Tigers's player Ohyama struck out.

Inning 2 is now over.
The inning was tied with a score of 1 : 1.
The score is currently Hanshin Tigers: 5 | Yokohama DeNA Baystars: 1.

Inning 3

It's the Yokohama DeNA Baystars's turn to bat.
What does Yokohama DeNA Baystars's player   桑Kuwahara hit?
Yokohama DeNA Baystars's player     桑Kuwahara hit a single.
What does Yokohama DeNA Baystars's player Watarai hit?
Yokohama DeNA Baystars's player Watarai struck out.
What does Yokohama DeNA Baystars's player Austin hit?
Yokohama DeNA Baystars's player Austin struck out.
What does Yokohama DeNA Baystars's player Maki hit?
Yokohama DeNA Baystars's player Maki struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Chikamoto hit?
Hanshin Tigers's player Chikamoto struck out.
What does Hanshin Tigers's player Nakano hit?
Hanshin Tigers's player Nakano struck out.
What does Hanshin Tigers's player Morishita hit?
Hanshin Tigers's player Morishita struck out.

Inning 3 is now over.
The Yokohama DeNA Baystars won the inning with a score of 1 : 0.
The score is currently Hanshin Tigers: 5 | Yokohama DeNA Baystars: 2.

Inning 4

It's the Yokohama DeNA Baystars's turn to bat.
What does Yokohama DeNA Baystars's player   桑Kuwahara hit?
Yokohama DeNA Baystars's player     桑Kuwahara struck out.
What does Yokohama DeNA Baystars's player Watarai hit?
Yokohama DeNA Baystars's player Watarai struck out.
What does Yokohama DeNA Baystars's player Austin hit?
Yokohama DeNA Baystars's player Austin struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Chikamoto hit?
Hanshin Tigers's player Chikamoto struck out.
What does Hanshin Tigers's player Nakano hit?
Hanshin Tigers's player Nakano struck out.
What does Hanshin Tigers's player Morishita hit?
Hanshin Tigers's player Morishita hit a triple.
What does Hanshin Tigers's player Ohyama hit?
Hanshin Tigers's player Ohyama hit a single.
What does Hanshin Tigers's player Maegawa hit?
Hanshin Tigers's player Maegawa struck out.

Inning 4 is now over.
The Hanshin Tigers won the inning with a score of 4 : 0.
The score is currently Hanshin Tigers: 9 | Yokohama DeNA Baystars: 2.

Inning 5

It's the Yokohama DeNA Baystars's turn to bat.
What does Yokohama DeNA Baystars's player   桑Kuwahara hit?
Yokohama DeNA Baystars's player     桑Kuwahara struck out.
What does Yokohama DeNA Baystars's player Watarai hit?
Yokohama DeNA Baystars's player Watarai struck out.
What does Yokohama DeNA Baystars's player Austin hit?
Yokohama DeNA Baystars's player Austin struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Chikamoto hit?
Hanshin Tigers's player Chikamoto struck out.
What does Hanshin Tigers's player Nakano hit?
Hanshin Tigers's player Nakano struck out.
What does Hanshin Tigers's player Morishita hit?
Hanshin Tigers's player Morishita struck out.

Inning 5 is now over.
The inning was tied with a score of 0 : 0.
The score is currently Hanshin Tigers: 9 | Yokohama DeNA Baystars: 2.

Inning 6

It's the Yokohama DeNA Baystars's turn to bat.
What does Yokohama DeNA Baystars's player   桑Kuwahara hit?
Yokohama DeNA Baystars's player     桑Kuwahara struck out.
What does Yokohama DeNA Baystars's player Watarai hit?
Yokohama DeNA Baystars's player Watarai struck out.
What does Yokohama DeNA Baystars's player Austin hit?
Yokohama DeNA Baystars's player Austin struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Chikamoto hit?
Hanshin Tigers's player Chikamoto struck out.
What does Hanshin Tigers's player Nakano hit?
Hanshin Tigers's player Nakano hit a triple.
What does Hanshin Tigers's player Morishita hit?
Hanshin Tigers's player Morishita struck out.
What does Hanshin Tigers's player Ohyama hit?
Hanshin Tigers's player Ohyama struck out.

Inning 6 is now over.
The Hanshin Tigers won the inning with a score of 3 : 0.
The score is currently Hanshin Tigers: 12 | Yokohama DeNA Baystars: 2.

Inning 7

It's the Yokohama DeNA Baystars's turn to bat.
What does Yokohama DeNA Baystars's player   桑Kuwahara hit?
Yokohama DeNA Baystars's player     桑Kuwahara hit a triple.
What does Yokohama DeNA Baystars's player Watarai hit?
Yokohama DeNA Baystars's player Watarai struck out.
What does Yokohama DeNA Baystars's player Austin hit?
Yokohama DeNA Baystars's player Austin hit a single.
What does Yokohama DeNA Baystars's player Maki hit?
Yokohama DeNA Baystars's player Maki hit a double.
What does Yokohama DeNA Baystars's player Miyazaki hit?
Yokohama DeNA Baystars's player Miyazaki struck out.
What does Yokohama DeNA Baystars's player Tsutsugoh hit?
Yokohama DeNA Baystars's player Tsutsugoh hit a single.
What does Yokohama DeNA Baystars's player Yamamoto hit?
Yokohama DeNA Baystars's player Yamamoto struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Chikamoto hit?
Hanshin Tigers's player Chikamoto struck out.
What does Hanshin Tigers's player Nakano hit?
Hanshin Tigers's player Nakano struck out.
What does Hanshin Tigers's player Morishita hit?
Hanshin Tigers's player Morishita struck out.

Inning 7 is now over.
The Yokohama DeNA Baystars won the inning with a score of 7 : 0.
The score is currently Hanshin Tigers: 12 | Yokohama DeNA Baystars: 9.

Inning 8

It's the Yokohama DeNA Baystars's turn to bat.
What does Yokohama DeNA Baystars's player   桑Kuwahara hit?
Yokohama DeNA Baystars's player     桑Kuwahara hit a single.
What does Yokohama DeNA Baystars's player Watarai hit?
Yokohama DeNA Baystars's player Watarai hit a single.
What does Yokohama DeNA Baystars's player Austin hit?
Yokohama DeNA Baystars's player Austin struck out.
What does Yokohama DeNA Baystars's player Maki hit?
Yokohama DeNA Baystars's player Maki struck out.
What does Yokohama DeNA Baystars's player Miyazaki hit?
Yokohama DeNA Baystars's player Miyazaki hit a double.
What does Yokohama DeNA Baystars's player Tsutsugoh hit?
Yokohama DeNA Baystars's player Tsutsugoh hit a single.
What does Yokohama DeNA Baystars's player Yamamoto hit?
Yokohama DeNA Baystars's player Yamamoto hit a single.
What does Yokohama DeNA Baystars's player Mori hit?
Yokohama DeNA Baystars's player Mori hit a single.
What does Yokohama DeNA Baystars's player Jackson hit?
Yokohama DeNA Baystars's player Jackson hit a home run!

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Chikamoto hit?
Hanshin Tigers's player Chikamoto hit a home run!
What does Hanshin Tigers's player Nakano hit?
Hanshin Tigers's player Nakano struck out.
What does Hanshin Tigers's player Morishita hit?
Hanshin Tigers's player Morishita struck out.
What does Hanshin Tigers's player Ohyama hit?
Hanshin Tigers's player Ohyama hit a triple.
What does Hanshin Tigers's player Maegawa hit?
Hanshin Tigers's player Maegawa struck out.

Inning 8 is now over.
The Yokohama DeNA Baystars won the inning with a score of 11 : 7.
The score is currently Hanshin Tigers: 19 | Yokohama DeNA Baystars: 20.

Inning 9

It's the Yokohama DeNA Baystars's turn to bat.
What does Yokohama DeNA Baystars's player   桑Kuwahara hit?
Yokohama DeNA Baystars's player     桑Kuwahara struck out.
What does Yokohama DeNA Baystars's player Watarai hit?
Yokohama DeNA Baystars's player Watarai struck out.
What does Yokohama DeNA Baystars's player Austin hit?
Yokohama DeNA Baystars's player Austin struck out.

It's the Hanshin Tigers's turn to bat.
What does Hanshin Tigers's player Chikamoto hit?
Hanshin Tigers's player Chikamoto hit a single.
What does Hanshin Tigers's player Nakano hit?
Hanshin Tigers's player Nakano struck out.
What does Hanshin Tigers's player Morishita hit?
Hanshin Tigers's player Morishita hit a single.
What does Hanshin Tigers's player Ohyama hit?
Hanshin Tigers's player Ohyama hit a double.
What does Hanshin Tigers's player Maegawa hit?
Hanshin Tigers's player Maegawa hit a single.
What does Hanshin Tigers's player Sato hit?
Hanshin Tigers's player Sato struck out.
What does Hanshin Tigers's player Umeno hit?
Hanshin Tigers's player Umeno struck out.

Inning 9 is now over.
The Hanshin Tigers won the inning with a score of 5 : 0.
The score is currently Hanshin Tigers: 24 | Yokohama DeNA Baystars: 20.

Game over
The Hanshin Tigers won with a score of 24 : 20

Would you like to simulate another game?
1) Yes
2) No
2
Program terminated.
```
ここでは、阪神が24-20でサヨナラ勝ちした。
実際、昨夜阪神は、1-0でサヨナラ勝ちした。
昨夜のように今日も明日いい試合を期待するが、阪神には勝って欲しい。

皆さんも時間がある時にこのプログラムコードを参考にして、応援しているプロ野球チームの試合結果を楽しく予測してみてはいかがでしょうか。