{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Kuang - Assuming that I win the volley if above statement...

This preview shows page 1. Sign up to view the full content.

% IE 5553 Homework 3 % Sorawit Chatpaitoon % Problem # 3 clc; clear all; Number_of_game_I_win = 0; for i = 1:1:100 % New Game, reset both players' scores Me = 0; Opponent = 0; x = 1; y = 1; if x == 1 % I continue to serve if I win the volley x = binornd(1,0.6); if x == 1 % Add 1 to my score if I win the volley Me = Me + 1; if Me == 21 break % Terminate game as I win end else y = 1; while y == 1 % Opponent continues to serve if he win the volley y = binornd(1,0.5);
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % Assuming that I win the volley if above statement return 0 if y == 1 % Add 1 to opponent's score if he win the volley Opponent = Opponent + 1; if Opponent == 21 break % Terminate game as Opponent win end else x = 1; % I won the volley hence become server end end end end end i; Me; Opponent; if Me == 21 Number_of_game_I_win = Number_of_game_I_win + 1; end end Total_game_I_win = Number_of_game_I_win Probability = Total_game_I_win/100 P...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online