Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please (Need urgent help) Solve this matlab problem for me? In this project you

ID: 3720644 • Letter: P

Question

Please (Need urgent help) Solve this matlab problem for me?

In this project you will create a program (script) that simulates a game of Darts. The program should display what each player hit with their darts each round and the current score until the game is completed

Types of dart games are available here: https://www.darting.com/RapidCat/Catalog/PageTemplate.cfm?template=/RapidCat/Common/ViewPage.cfm&PageId=1195&CompanyId=1121

You will get two 512x512 matrices that represent a dart board. The first includes the value for each wedge around the board, the value in the matrix is the wedge value (or zero if you are off the board). For instance, if you select a number in the upper middle of the board (i.e. location 100,256) the resulting value will be 20. The second matrix indicates where the rings are for single, double or triple. In this case, each location has a value of 1 for single rings, 2 for double ring, 3 for a triple ring, and zero if you are off the board. Your code must display (i.e. triple – 14) where each dart hits (this can be done with text, it does not require a visual representation) for each round. Then display the current score for all players.

Explanation / Answer

function [Values,Valid,Wires,Outside]=dartboard(scale,out,Rw)

% example:

% % Dartboard with high resolution, 10mm frame, 2mm wires

% Points = dartboard(0.1,10,2);

% image(Points); colormap hot;

if nargin==0

    scale=1; % resolution mm per pixel

end

if nargin<=1

    out=1; % frame mm

end

if nargin<=2

    Rw=0.6; % wire diameter mm

end

vallist=[20 1 18 4 13 6 10 15 2 17 3 19 7 16 8 11 14 9 12 5];

% DIMENSIONS in mm

out=out/scale;% outside frame

Rf=8/scale;% width of rings

RT1=107/scale;

RT2=RT1-Rf;% tripple ring

RD1=170/scale;

RD2=RD1-Rf; % double ring

RB=31.8/2/scale; % bull

RE=12.7/2/scale; % bulls eye

Rw=Rw/scale; % wire diameter

N=(2*RD1+2*out)+1;

Nmid=round(N/2);

[x,y]=meshgrid((1:N)-Nmid,(1:N)-Nmid);

R=sqrt(x.^2+y.^2);

ag=atan2(x,y)/2/pi*360+180;

agm=mod(ag-9,18);

ag2=ag-9;ag2(ag2<0)=ag2(ag2<0)+360;

idx=20-floor((ag2)/18);

da=asin(Rw/2./R)/2/pi*360;

MF=~((agm<da)|(agm>(18-da))); % valid radials

ME=(R<=(RE-Rw/2)); % eye

MB=(R>=(RE+Rw/2))&(R<=(RB-Rw/2)); %bull

MS1=((R>=(RB+Rw/2))&(R<=(RT2-Rw/2)))&MF; % single

MT =((R>=(RT2+Rw/2))&(R<=(RT1-Rw/2)))&MF; % tripple

MS2=((R>=(RT1+Rw/2))&(R<=(RD2-Rw/2)))&MF; % single

MD = ((R >= (RD2 + Rw/2)) & (R <= (RD1 - Rw/2))) & MF; % double

Valid   = ME | MB | MS1 | MT | MS2 | MD; % all valid

Wires = (R <= (RD1 + Rw/2)) & ~Valid; % all wires

Values = ME * 50 +...

      MB *25 +...

      (((MS1 | MS2) * 1 + ...

         MT * 3 + ...

         MD * 2) .* vallist(idx)); % values

Outside = (R > (RD1 + Rw/2)); % all outside

assert(sum(Valid(:))+sum(Wires(:))+sum(Outside(:)) == N*N,'overlapping maps')

%%

% figure;image(Values),colormap hot

% figure;image(Valid),colormap lines

% figure;image(Wires),colormap lines

% figure;image(Outside),colormap lines