Question: In Python This assignment will task students with solving a problem in a partially observable environment in order to beat an opponent in a game
In Python
This assignment will task students with solving a problem in a partially observable environment in order to beat an opponent in a game of rock-paper-scissors (RPS).
Students have to write an RPS client that is able to exploit an adversary that always plays from a known sequence, though the agent does not know where in the sequence the adversary will start playing. This problem can be solved in the same way that other search problems with observations are solved using belief states.
The two major goals for this practical are thus
1) implementing a search algorithm that works in a partially observable environment, in order to beat sequence_random.py
2) writing a short technical report describing the ndings.
An agent has to be implemented that can beat sequence_random.py. This should be achievedbyupdatingtheagentsbeliefstatesasmoreinformationabouttheadversarybecomes available. The agent will be able to determine the sequence that sequence_random.py will be playing from by reading the sequence from a le at the start of every match. Once the position in the sequence that the adversary is playing from is known, the agent should be able to win all ensuing rounds. The code snippet in Listing 1 will allow one to read the sequence at the start of each match.

code given:
sequence_random.py
import random if input == "": sequence = ["R","P","S","P","S","R","S","P","R","S","P","S","P","R","S","P","S","R","P","R","S","P","S","R","S","R","S","P","R","S","R","S","P","R","P","S","R","P","S","R","S","R","S","P","R","P","R","S","P","R","S","P","S","P","S","P","S","P","R","S","R","S","R","P","R","S","P","R","P","S","P","S","P","S","P","S","R","S","R","S","P","S","P","S","P","R","S","P","S","P","R","S","R","S","P","R","S","R","P","S","R","S","R","P","S","R","S","P","S","P","R","S","P","S","R","P","S","R","P","S","R","P","R","S","P","R","P","R","P","R","S","R","P","S","R","P","S","R","P","S","P","S","R","S","P","R","S","P","R","P","S","R","P","R","P","S","P","R","P","S","R","S","R","S","R","P","R","P","S","R","P","R","S","P","S","P","R","P","S","R","P","R","P","S","R","S","P","R","P","S","R","S","R","P","R","P","S","R","S","P","S","R","P","R","S","P","S","R","S","P","R","S","P","R","S","R","P","S","R","S","P","R","P","S","P","R","S","R","S","R","P","R","P","S","P","R","S","P","R","S","R","P","R","S","P","S","P","S","R","S","P","S","P","S","P","R","S","R","S","R","P","R","S","P","R","S","R","P","S","R","P","S","R","P","R","P","R","S","R","P","R","P","R","S","R","S","P","R","P","S","R","P","S","P","S","P","R","S","P","R","P","S","R","P","R","S","R","P","S","P","R","P","S","R","S","R","P","R","S","P","S","R","S","R","P","R","P","S","R","P","R","P","S","R","S","P","R","P","S","P","R","S","R","P","R","S","R","S","R","P","S","P","S","R","P","R","S","P","S","P","S","R","P","S","R","P","R","P","S","R","P","R","S","P","S","P","S","P","S","P","S","P","S","P","R","S","P","S","R","S","R","S","P","S","P","R","P","S","R","P","S","P","R","P","S","R","S","R","P","S","R","P","R","P","S","P","S","R","S","R","S","R","P","R","P","R","S","P","R","S","R","P","S","R","S","P","R","S","R","P","S","P","S","R","S","P","S","P","S","P","S","P","R","S","R","S","R","S","R","P","S","R","S","P","S","P","R","P","S","P","S","P","R","P","R","P","S","P","S","R","P","S","P","R","P","S","R","S","P","S","R","P","R","P","R","P","S","P","R","S","R","P","S","P","R","P","R","P","S","P","R","P","R","S","R","S","R","P","R","S","P","S","R","S","R","S","R","S","P","S","R","P","S","R","P","R","P","R","P","R","P","S","P","R","P","S","R","P","R","S","R","P","R","S","R","P","R","P","S","P","R","S","P","S","R","P","S","R","P","R","S","R","P","S","R","P","R","S","P","R","P","S","P","S","R","S","R","S","P","R","S","R","S","R","S","R","P","S","P","R","P","R","P","S","P","S","R","S","R","P","S","R","S","R","P","R","S","P","S","P","R","S","R","S","P","R","P","S","R","S","R","S","R","S","R","P","R","P","S","R","S","R","P","S","R","S","R","P","S","R","S","R","S","P","S","P","R","P","S","P","S","P","S","R","S","R","P","R","P","R","P","S","R","P","S","P","R","S","R","S","R","S","R","P","R","S","P","R","P","R","P","R","P","S","R","S","P","S","P","R","S","R","P","S","P","S","P","S","P","S","R","S","R","P","R","P","R","S","R","S","P","S","R","S","R","P","R","S","P","R","P","R","P","R","P","R","S","R","P","S","P","R","S","R","P","S","R","S","R","P","S","R","S","P","R","P","R","P","S","R","S","R","P","R","S","P","R","P","R","P","S","P","R","P","S","R","S","R","P","R","S","P","R","P","R","S","R","S","R","P","S","P","S","P","S","R","S","R","S","R","S","P","S","R","S","R","S","P","R","S","R","P","S","P","R","S","R","P","R","S","P","R","S","P","S","P","S","R","S","P","S","R","S","P","S","R","S","P","R","P","R","P","S","P","R","S","R","P","S","R","S","P","S","P","R","P","R","S","P","R","P","S","P","R","S","R","P","S","P","R","P","S","R","P","R","S","R","P","S","R","S","R","P","R","P","R","S","P","R","P","R","S","P","S","R","P","S","R","P","R","P","S","P","S","R","P","S","P","R","P","S","R","S","P","R","P","S","P","S","R","P","S","R","S","P","R","S","R","P","R","P","R","P","S","R","P","R","P","R","S","P","S","P","S","R","S","R","S","R","P","R","S","R","S","P","S","R","S","R","S","R","S","P","R","S","R","S","P","S","P","S","R","S","P","R","S","R","S","P","S","R","S","R","S","P","S","R","P","R","P","S","P","R","S","P","S","P","R","S","R"] position = random.randint(0, 999) else: position += 1 if position > 999: position = 0 # Play the selected object. output = sequence[position]
Listing l: A code snippet for reading a sequence from sequence.pkl l import cPickle 3if input" 4 sequencecPickle . load (open ( sequence.pkl')) Listing l: A code snippet for reading a sequence from sequence.pkl l import cPickle 3if input" 4 sequencecPickle . load (open ( sequence.pkl'))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
