Closed pksvv closed 2 years ago
Issue w the if else statements
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
# play rock paper scissors
user_choice = tracker.get_slot("choice")
dispatcher.utter_message(text=f'You chose {user_choice}')
comp_choice = self.computer_choice()
dispatcher.utter_message(text=f'The computer chose {comp_choice}')
if user_choice == "rock" and comp_choice == "scissors":
dispatcher.utter_message(text = 'Congrats ! You won.')
elif user_choice == "rock" and comp_choice == "paper":
dispatcher.utter_message(text = 'The computer won this round.')
elif user_choice == "paper" and comp_choice == "rock":
dispatcher.utter_message(text = 'Congrats ! You won.')
elif user_choice == "paper" and comp_choice == "scissors":
dispatcher.utter_message(text = 'The computer won this round.')
elif user_choice == "scissors" and comp_choice == "paper":
dispatcher.utter_message(text = 'Congrats ! You won.')
elif user_choice == "scissors" and comp_choice == "rock":
dispatcher.utter_message(text = 'The computer won this round.')
else:
dispatcher.utter_message(text='It was a tie !!')
# dispatcher.utter_message(text="Hello World!")
return []
Chat Logs
Bot loaded. Type a message and press enter (use '/stop' to exit):
Your input -> hi
Type Rock, Paper, or Scissors to play.
Your input -> rock
You chose rock
The computer chose paper
The computer won this round.
It was a tie !!
Do you want to play again?
Your input -> rock
You chose rock
The computer chose rock
It was a tie !!
Do you want to play again?
Your input -> yes
Type Rock, Paper, or Scissors to play.
Your input -> scissors
You chose scissors
The computer chose rock
The computer won this round.
Do you want to play again?
Your input -> no
Bye
Your input ->
"It was a tie !!" getting repeated
Bot loaded. Type a message and press enter (use '/stop' to exit): Your input -> hi
Type Rock, Paper, or Scissors to play. Your input -> rock
You chose rock The computer chose rock It was a tie !! Your input -> paper
You chose paper The computer chose paper It was a tie !! Your input -> rock
You chose rock The computer chose paper The computer won this round. It was a tie !! Your input -> scissor
You chose scissor The computer chose paper It was a tie !! Your input -> scissors
You chose scissors The computer chose rock The computer won this round. Your input -> rock
You chose rock The computer chose rock It was a tie !! Your input -> paper
You chose paper The computer chose rock Congrats ! You won. It was a tie !!