I'm curious if it's possible for me to change the functions from different files in Python.
What psrock.py file does is that it receives two datas from each file that will go against each other in rock paper scissors and deciding which player have won. Of course, psrock.py file contains other functions, too, but I just inserted one function since other ones don't really matter for my question.
I'm trying to edit the function that's in psrock.py file so that team3's (there are team1, team2, team3 and they play rock paper scissors against one another. (i.e. team1 and team 2 go against each other then team 1 and 3 after. vice versa)) result will always be rock and the opponent's result will be scissors so that team3 can win no matter what.
However, I am struggling and don't know what to do.. :( I barely started learning Python and it's pretty challenging task for me to do. I would love it if you can help me out a little bit ;)
# This is a function from psrock.py file
import team3
def round(player1, player2, history1='', history2=''):
# Get player 1's move.
move1 = player1(my_history=history1, their_history=history2)
# Get player 2's move.
move2 = player2(my_history=history2, their_history=history1)
if valid(move1) and valid(move2):
if move1 == move2:
score1, score2 = 0, 0
elif move1+move2 in ['rs', 'sp', 'pr']:
score1, score2 = 1, -1
else:
score1, score2 = -1, 1
else: #one of the moves was invalid
if valid(move1): # only move2 was invalid
move2 = 'x'
score1, score2 = 1, -1
elif valid(move2): # only move1 was invalid
move1 = 'x'
score1, score2 = -1, 1
else: # Both moves invalid
move1, move2 = 'x', 'x'
score1, score2 = -1, -1
return move1, move2, score1, score2
...And I'm trying to edit this function from another file named team3...
# Team 3 File
# -*- coding: utf-8 -*-
import psrock
def round(player1, player2, history1='', history2=''):
move1 = player1(my_history=history1, their_history=history2)
if player1 == team3:
move1 = 'r'
move2 = 's'
elif player2 == team3:
move1 = 's'
move2 = 'r'
The Files:
- Download the File
- Extract the zip file
- Open all of the files in the same tab
- Play the psrock_play.py file
https://drive.google.com/file/d/0BxNi5bq6Cvnea0c4aVVIWUxZRUE/view?usp=sharing