Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

HW5 english version?

1
1716380 (990 points)
14 24 28
in Es1 by (990 points)
i am a foreign student and i have some problems to understand the hw5 i tried the google translate but it was not so useful keep gives me some unmatched sentences. please if you have the English version of hw5 or you can tell me the purpose of es1 and 2 .

thanks for your help
687 views
closed

2 Answers

Best answer
split (8700 points)
21 59 79
by (8.7k points)
selected by
i'll try to help you just for es1 for now, cause i have not looked yet at es2, so i dont want to say something wrong about it.

sorry for my english, i hope you understand anyway what i say, at least to begin es1 :)

you """""simply""""" have to write an A.I. that solves the game of mastermind (here the general rules https://en.wikipedia.org/wiki/Mastermind_(board_game))

the "simulatore.py" file in the homework05 folder will call your "decodificatore" function, that must to return a guess (a list of int numbers). the argument passed to decodificatore will be a list that has in 0 position the lenght of the code to solve, and then tuples with 2 args, 0 arg is a precedent attempt you send to the simulatore.py, 1 arg is the "answer" of the matermind, or, better, a tuple of 2 args, they rappresent the back and the white pegs, the key pegs, like in wiki rules. the difference with real game is that you never know which number is black or white peg, they will appear in random order.
you must to use these informations to create a new guess and then return it with decodificatore and so on...

you have 150 chances to guess the highest number of codes, when you guess one, simulatore.py will give you a new code to guess, until you "burn" your 150 chnces or til 30 secs are passed from the start of the first guess.
i hope this short description will be useful, comment if something is not clear.
for es2 wait some one else, but in the midtime you can start with es1.
good luck
1
1716380 (990 points)
14 24 28
by (990 points)
thanks again for your answer. there is one thing that i do not understand. prf. said in the program01.py ''Ad esempio per il codice 34670915 e il tentativo 93375948 le risposte (2,3) e (3,2) sono entrambe possibili.'' according to this example we have 2 numbers and they are correct and in the correct position and we have 3 numbers they are correct but in the wrong order , that means tuple(2,3) is correct but tuple(3,2) how is that possible for this example?
a
alecapecchi (3860 points)
5 14 21
by (3.9k points)
because every time you are given back 2 numbers: one is the total of the ones in the right position, the other the total of the ones in the wrong position. However you are not told which of this numbers is first and which last. Moreover this order can change in every different answer, so if you give twice the same combination you may get the numbers swapped.
Zannabbianca (1180 points)
3 10 17
by (1.2k points)
reshown by

program01:

The objective of the exercise is to develop a game strategy for the game "Mastermind".

In Mastermind, a player (the 'decoder'), has to guess a secret code. The secret code has N distinct decimal digits (NO REPETITIONS, only 10 possible symbols for each position).
The decoder tries to guess the code by submitting various attemps. Strategically in your guess you can use repeated digits, despite knowing that in the code there are no repetitions.
As a help, you will recieve a response for each guess, and you will be provided with a couple of numbers a,b:

- 'a' being the number of digits of your guess that are in the right position
- 'b' being the number of digits of your guess that are present in the code but in the wrong position

For example, in the case of the code being 34670915 and the guess being 93375948, the answer will be the couple (2,3).
The 2 represents the digits 7 and 9 of the code in the 4th and 6th position, while the 3 represents the digits 3,4,5 which are present in the code but never in the right position.

In this version of mastermind, N (the lenght of the code) can be 6, 7 or 8, and in the couple given as a response of each guess, 'a' and 'b' may be reversed so that you can't know for sure what 'a' and 'b' represent.
For example, if the code was 34670915 and the guess was 93375948, the anwsers (2,3) and (3,2) are both possible.

A configuration of the game is represented as a list of lists (L).
The first element of 'L' is a digit N representing the length of the code.
Any of the other elements of L represent a guess submitted by the decoder and its relative response.
More precisely, L[i] with i>0, if present, will contain a tuple made of two elements:
- The list whose lenght is N digits with the guess submitted by the decoder in a previous step
- The tuple of numbers (a,b) recieved as a response.

The program you have to realize contains the following function:

decodificatore(configurazione)

which is the AI that plays the game. The function must recieve as an input the actual configuration of the game and it has to produce a guess (list of characters from 0 to 9).
 

I hope I got everything right, please correct me if I made mistakes, I hope I have time to translate the other one!

1
1716380 (990 points)
14 24 28
by (990 points)
can you please explain this "For example, if the code was 34670915 and the guess was 93375948, the answer (2,3) and (3,2) are both possible." how come?
Luca T. (5410 points)
3 20 38
by (5.4k points)
They are both possible because we are not allowed to know which are in the correct position and which not, so everytime there is a 50% chance for the answer to be (x, y) and 50% to be (y, x)