游戏五子棋含Matlab源码 078期

Posted 紫极神光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了游戏五子棋含Matlab源码 078期相关的知识,希望对你有一定的参考价值。

一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【游戏】五子棋【含Matlab源码 078期】

获取代码方式2:
通过紫极神光博客主页开通CSDN会员,凭支付凭证,私信博主,可获得此代码。

获取代码方式3:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:开通CSDN会员,仅只能免费获得1份代码(有效期为开通日起,三天内有效);
订阅紫极神光博客付费专栏,可免费获得2份代码(有效期为订阅日起,三天内有效);

二、部分源代码

function varargout = wuziqi(varargin)



gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @wuziqi_OpeningFcn, ...
                   'gui_OutputFcn',  @wuziqi_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
               
if nargin == 0  % LAUNCH GUI

	fig = openfig(mfilename,'new');

	% Use system color scheme for figure:
	%set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));

	% Generate a structure of handles to pass to callbacks, and store it. 
	handles = guihandles(fig);
	guidata(fig, handles);

	if nargout > 0
		varargout{1} = fig;
	end


end

if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

%%
% --- Executes just before wuziqi is made visible.
function wuziqi_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to wuziqi (see VARARGIN)

% Choose default command line output for wuziqi
handles.output = hObject;


handles.ncol = 32;
handles.nrow = 22;
handles.grids = zeros(handles.ncol, handles.nrow);
handles.step = [];
handles.white = 1;
handles.start = 0;
handles.hint = 0;

axes(handles.axes2);
im = imread('title.jpg');
imshow(im,[]);

axes(handles.axes3);
im = imread('demo.jpg');
imshow(im,[]);

axes(handles.axes1);
hold on
plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','w','markersize',20,'MarkerEdgeColor','k');
line ([0.9,0.9,handles.ncol+0.1,handles.ncol+0.1,0.9],[0.9,handles.nrow+0.1,handles.nrow+0.1,0.9,0.9],'color','k');
for i=1:handles.ncol
line ([i,i],[1, handles.nrow],'color','k');
end

for i=1:handles.nrow
line ([1 handles.ncol],[i,i],'color','k');
end
axis off
%title('Wu Zi Qi');
%guidata (hObject, handles);
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes wuziqi wait for user response (see UIRESUME)
% uiwait(handles.figure1);

%%
function mutual_exclude(off)
set(off,'Value',0)

%%
% --- Outputs from this function are returned to the command line.
function varargout = wuziqi_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


%%
%function figure1_CreateFcn(hObject, eventdata, handles)



%%
% --- Executes on button press in start.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%%% Start
handles.start = 1;
set(handles.radiobutton2,'Enable','off');
set(handles.radiobutton1,'Enable','off');
handles.grids = zeros(handles.ncol, handles.nrow);

handles.step = [];

axes(handles.axes1); 
hold off

if handles.white ==1
    plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','w','markersize',20,'MarkerEdgeColor','k');
else
    plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','k','markersize',20,'MarkerEdgeColor','w');
end

hold on
line ([0.9,0.9,handles.ncol+0.1,handles.ncol+0.1,0.9],[0.9,handles.nrow+0.1,handles.nrow+0.1,0.9,0.9],'color','k');
hold on
for i=1:handles.ncol
line ([i,i],[1, handles.nrow],'color','k');
end

for i=1:handles.nrow
line ([1 handles.ncol],[i,i],'color','k');
end
axis off
guidata(hObject, handles);

%%
% --- Executes on button press in Undo.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

if length(handles.step)>0
   i = abs(handles.step(length(handles.step)));
   [x,y]=ind2sub([handles.ncol,handles.nrow],i);
   handles.grids(x,y) = 0;
   if length(handles.step)>1
       handles.step = handles.step(1:length(handles.step)-1);
   else
       handles.step = [];
   end 
   if handles.white == 1
       handles.white = 0;
   else
       handles.white = 1;
   end
   Draw_Chess(handles);
end

guidata(hObject, handles);


%%
% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
starts=get(gca,'CurrentPoint');
Clck=starts(2,:);
x = round(Clck(1));
y = round(Clck(2));
indicator = 0;

hold on;
if (x>0)&&(x<=handles.ncol)&&(y>0)&&(y<=handles.nrow)&&(handles.start==1)    
    if handles.grids(x,y)==0
        if handles.white ==1
            %plot(x,y,'o','MarkerFaceColor','w','markersize',10,'MarkerEdgeColor','k');
            %plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','k','markersize',20,'MarkerEdgeColor','w');
            handles.white = 0;
            s = 1;
            handles.grids(x,y) = 1;
        else
            %plot(x,y,'o','MarkerFaceColor','k','markersize',10,'MarkerEdgeColor','w');
            %plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','w','markersize',20,'MarkerEdgeColor','k');
            handles.white = 1;
            s = -1;
            handles.grids(x,y) = -1;
        end
        handles.step = [handles.step, s*sub2ind([handles.ncol,handles.nrow],x,y)];
        indicator = Draw_Chess(handles);
    end    
end

if indicator ~=0
    handles.start = 0;
    set(handles.radiobutton2,'Enable','on');
    set(handles.radiobutton1,'Enable','on');
    handles.grids = zeros(handles.ncol, handles.nrow);
    handles.step = [];
end
    
guidata(hObject, handles);

%%
% --- Executes on button press in black first.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2
handles.white=0;
plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','k','markersize',20,'MarkerEdgeColor','w');
off = [handles.radiobutton1];
mutual_exclude(off);
guidata(hObject,handles);


%%
% --- Executes on button press in white first.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1
handles.white=1;
plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','w','markersize',20,'MarkerEdgeColor','k');
off = [handles.radiobutton2];
mutual_exclude(off);
guidata(hObject,handles);


%%
% --- Executes on button press in Clear.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.start = 0;
set(handles.radiobutton2,'Enable','on');
set(handles.radiobutton1,'Enable','on');
handles.grids = zeros(handles.ncol, handles.nrow);

handles.step = [];

axes(handles.axes1); 
hold off

if handles.white ==1
    plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','w','markersize',20,'MarkerEdgeColor','k');
else
    plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','k','markersize',20,'MarkerEdgeColor','w');
end

hold on
line ([0.9,0.9,handles.ncol+0.1,handles.ncol+0.1,0.9],[0.9,handles.nrow+0.1,handles.nrow+0.1,0.9,0.9],'color','k');
%hold on
for i=1:handles.ncol
line ([i,i],[1, handles.nrow],'color','k');
end

for i=1:handles.nrow
line ([1 handles.ncol],[i,i],'color','k');
end
axis off
guidata(hObject,handles);

%%
function indicator = Draw_Chess(handles)

axes(handles.axes1);
hold off

if handles.white ==1
    plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','w','markersize',20,'MarkerEdgeColor','k');
else
    plot(handles.ncol+3.5,handles.nrow,'o','MarkerFaceColor','k','markersize',20,'MarkerEdgeColor','w');
end

hold on
line (游戏拼图游戏含Matlab源码 300期

游戏拼图游戏含Matlab源码 300期

游戏基于matlab GUI贪吃蛇游戏含Matlab源码 1146期

游戏基于matlab GUI抽签含Matlab源码 598期

游戏基于matlab GUI贪吃蛇游戏(难度地图音乐)含Matlab源码 1160期

游戏基于matlab GUI时钟设计含Matlab源码 1102期