Write a script le to simulate 100 plays of a

Write a script le to simulate 100 plays of a game in which you ip two coins. You win the game if you get two heads, lose if you get two tails, and ip again if you get one head and one tail. Create three user -defined functions to use in the script. Function ip simulates the ip of one coin, with the state s of the random number generator as the input argument, and the new state s and the result of the ip (0 for a tail and 1 for a head) as the outputs. Function ips simulates the ipping of two coins and calls ip. The input of ips is the state s, and the outputs are the new state s and the result (0 for two tails, 1 for a head and a tail, and 2 for two heads). Function match simulates a turn at the game. Its input is the state s, and its outputs are the result (1 for win, 0 for lose) and the new state s. The script should reset the random number generator to its initial state, compute the state s, and pass this state to the user-defined functions.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

GradeEssays.com
We are GradeEssays.com, the best college essay writing service. We offer educational and research assistance to assist our customers in managing their academic work. At GradeEssays.com, we promise quality and 100% original essays written from scratch.
Contact Us

Enjoy 24/7 customer support for any queries or concerns you have.

Phone: +1 213 3772458

Email: support@gradeessays.com

© 2024 - GradeEssays.com. All rights reserved.

WE HAVE A GIFT FOR YOU!

15% OFF 🎁

Get 15% OFF on your order with us

Scroll to Top