Cody

# Problem 327. TRON challenge

Solution 3620393

Submitted on 11 Nov 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
urlwrite('https://sites.google.com/a/alfnie.com/alfnie/software/SetSolutionScore.p?attredirects=0&amp;d=1','SetSolutionScore.p'); SetSolutionScore(100); doDraw=false; %set to true for display params=struct('n',50,'str','NESW','D',[-1,50,1,-50],'wins',[0,0,0]); rand('state',0); for nboards=1:100, % initialize board params.board=zeros(params.n); params.board([1,end],:)=-3; params.board(:,[1,end])=-3; [i,j]=find(params.board|1); [nill,pos1]=max((i==2|j==2)+~params.board(:)+rand(params.n*params.n,1)); params.board(pos1)=1; [nill,pos2]=max((i==2|j==2)+~params.board(:)+rand(params.n*params.n,1)); params.board(pos2)=2; while 1 % blue's next movement params.state=rand('state'); assignin('caller','params',params); d1=tron(params.board); params=evalin('caller','params'); rand('state',params.state); % red's next movement i=find(params.board==2); [nill,j]=max(~params.board(i+params.D)+.5*(params.board(i-params.D)==-2)); d2=params.str(j); % evaluate movements d1=findstr(params.str,d1); d2=findstr(params.str,d2); assert(~isempty(d1)); params.board(pos1)=-1; params.board(pos2)=-2; pos1=pos1+params.D(d1); pos2=pos2+params.D(d2); if pos1==pos2||(params.board(pos1)&&params.board(pos2)), %tie params.wins(2)=params.wins(2)+1; if doDraw, disp('tie'); end break; elseif params.board(pos1), %loose if doDraw, disp('loose'); end params.wins(3)=params.wins(3)+1; break; elseif params.board(pos2), %win if doDraw, disp('win'); end params.wins(1)=params.wins(1)+1; break; end params.board(pos1)=1; params.board(pos2)=2; if doDraw image(4+params.board); axis equal off; colormap([1,1,1;.5,0,0;0,0,.5;0,0,0;0,0,1;1,0,0]); set(gcf,'color','k'); drawnow; end end if doDraw, pause; end end disp(sprintf('%d wins; %d ties; %d looses',params.wins)); % Score = 100+#Looses-#Wins SetSolutionScore(100+params.wins*[-1;0;1]); assert(params.wins(1)>=90,sprintf('%d wins; %d ties; %d looses',params.wins));

Error using urlreadwrite (line 98) Error downloading URL. Your network connection may be down or your proxy settings improperly configured. Error in urlwrite (line 52) [f,status] = urlreadwrite(mfilename,catchErrors,url,filename,varargin{:}); Error in Test1 (line 1) urlwrite('https://sites.google.com/a/alfnie.com/alfnie/software/SetSolutionScore.p?attredirects=0&amp;d=1','SetSolutionScore.p');

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!