Monday, January 30, 2023
HomeMatlabWeblog | Mastermind Recreation With App Designer

# Weblog | Mastermind Recreation With App Designer

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Matter : Play Mastermind sport with MATLAB App Designer
% Firm: MATLAB Helper
% Web site: https://MATLABHelper.com
% Date : 02-06-2022

classdef mastermind
properties (Entry = public)
(Uneditable code)
finish
% This app has been designed for enjoying the Mastermind sport because the
% code-breaker. The colors used are Crimson-1, Blue-2, Inexperienced-3, Yellow-4,
% Pink-5,Orange-6
properties (Entry = personal)
% Iteration variables
i;
j;
finish

properties (Entry = public)
% Recreation variable and board picture variable
play = struct();
var;
finish

strategies (Entry = personal)

finish

strategies (Entry = public)
% perform to replace the board with present guess
perform outcomes = UpdateBoard(app,colorNum)
app.ChangecurrentrowButton.Seen = “on”;
if app.j <= app.play.numCols && app.i <= app.play.numRows
swap colorNum
case 1
(Code ….)
app.play.currentColorNum = colorNum;
(Code ….)
finish

perform startupFcn(app)
% Initialise the sport variables and cargo the mat file picture
(code….)

….

%generate the random resolution (pattern with out substitute)
(code….)

% Show the empty Board
imshow([app.var.Board{1,:};app.var.Board{2,:};app.var.Board{3,:};app.var.Board{4,:};app.var.Board{5,:};app.var.Board{6,:};app.var.Board{7,:};app.var.Board{8,:};app.var.Board{9,:};…
app.var.Board{10,:}],’Mother or father’,app.UIAxes)
finish

perform RedButton1Pushed(app,occasion)
UpdateBoard(app,1)
finish
perform BlueButton2Pushed(app,occasion)
UpdateBoard(app,2)
finish
perform GreenButton3Pushed(app,occasion)
UpdateBoard(app,3)
finish
(code….)…….

perform ResultButtonPushed(app,occasion)

% Code for ‘Fill whole row’ immediate
if sum(app.play.rowColors==0)
(code….)…….
else
% Code to search out the variety of right colors and variety of right locations
(code….)…….
% Code for winner
if nCorrectPlaces == app.play.numCols
(code….)…….

else
% Code to replace the present guess’s black and white clue pegs

(code….)…….

% Code for loser
if app.play.currentRow == app.play.numRows
return;
finish

% Code to replace the present state of the sport
app.play.currentRow = app.play.currentRow + 1;
(code….)…….

finish
finish

perform ResetButtonPushed(app,occasion)
% Code to reset sport and reload the Board
(Code…)
finish

perform ChangecurrentrowButtonPushed(app,occasion)
% Code to reset colors on the present row
(Code…)
finish

RELATED ARTICLES