日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

用matlab算24点小游戏,24点游戏的Matlab程序

發(fā)布時(shí)間:2023/12/4 循环神经网络 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用matlab算24点小游戏,24点游戏的Matlab程序 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

function GUI_games24

S.fh = figure('units','pixels',...

'position',[500 500 800 200],...

'menubar','none',...

'name','24點(diǎn)游戲',...

'numbertitle','off',...

'resize','off');

S.ti = uicontrol('style','text',...

'units','pix',...

'position',[300 150 180 30],...

'string','24點(diǎn)的計(jì)算程序','fontsize',15);

S.ra= uicontrol('style','pushbutton',...

'units','pix',...

'position',[10 100 180 30],...

'string','隨機(jī)生成',...

'callback',{@ra_call});

S.ed1 = uicontrol('style','edit',...

'units','pix',...

'position',[10 60 180 30],...

'string',' ');

S.ed2 = uicontrol('style','edit',...

'units','pix',...

'position',[200 60 180 30],...

'string',' ');

S.ed3 = uicontrol('style','edit',...

'units','pix',...

'position',[400 60 180 30],...

'string',' ');

S.ed4 = uicontrol('style','edit',...

'units','pix',...

'position',[600 60 180 30],...

'string',' ');

S.pb = uicontrol('style','pushbutton',...

'units','pix',...

'position',[10 20 180 30],...

'string','求解計(jì)算',...

'callback',{@pb_call});

S.re = uicontrol('style','text',...

'units','pix',...

'position',[200 20 350 30],...

'string','結(jié)果顯示','fontsize',15);

S.reset = uicontrol('style','pushbutton',...

'units','pix',...

'position',[600 20 180 30],...

'string','reset',...

'callback',{@re_call});

function pb_call(varargin)

% Callback for the pushbutton.

R1 = str2double(get(S.ed1,'string'));

R2 = str2double(get(S.ed2,'string'));

R3 = str2double(get(S.ed3,'string'));

R4 = str2double(get(S.ed4,'string'));

x=[R1,R2,R3,R4];

if any(x>13)

set(S.re,'string','請(qǐng)按reset按鈕,輸入1-13之間的整數(shù)');

return

end

expression=disspp(x);

if length(expression{1})<4

set(S.re,'string','fail!!');

else

cc=cell(1,length(expression{1}));

for i=1:length(expression{1})

if expression{1}(i)>30

cc{i}=char(expression{1}(i));

else

cc{i}=num2str(expression{1}(i));

end

end

set(S.re,'string',cell2mat(cc));

end

end

function re_call(varargin)

% Callback for the pushbutton.

set(S.ed1,'string','');

set(S.ed2,'string','');

set(S.ed3,'string','');

set(S.ed4,'string','');

set(S.re,'string','');

end

function ra_call(varargin)

% Callback for the pushbutton.

rap=randint(1,4,[1,13]);

set(S.ed1,'string',int2str(rap(1)));

set(S.ed2,'string',int2str(rap(2)));

set(S.ed3,'string',int2str(rap(3)));

set(S.ed4,'string',int2str(rap(4)));

end

end

function expression=disspp(x)

% 此程序解決經(jīng)典的24點(diǎn)游戲

% disspp(x)

% example:x=[3 3 8 8]

% disspp(x)

% 算法在網(wǎng)上有的,也可以編c++,java,asp,jap,html&etc,有興趣者可以試試

% copyright:\流水

% 編寫于5月27日晨

if nargin==0

x=[6 6 6 6];

end

global number expression

number=x;

for i=1:4

expression{i}=number(i);

end

number=x;

bol=search(4);

if bol==1

disp('Sucess.')

else

disp('fail');

end

function bool=search(n)

global number expression

PRECISION=1e-6;

% COUNT_OF_NUMBER=4;

NUMBER_TO_BE_CAL=24;

if n==1

if abs(number(1)-NUMBER_TO_BE_CAL)

for i=1:length(expression{1})

if expression{1}(i)>30

a{i}=char(expression{1}(i));

else

a{i}=num2str(expression{1}(i));

end

end

a=cell2mat(a);

disp(a);

bool=1;

return

else

bool=0;

return

end

end

for i=1:n

for j=i+1:n

a=number(i);

b=number(j);

number(j)=number(n);

expa=expression{i};

expb=expression{j};

expression{j}=expression{n};

expression{i}=[40,expa,43,expb,41];

global expression

number(i)=a+b;

if search(n-1)

global expression

bool=1;

return

end

expression{i}=[40,expa,45,expb,41];

number(i)=a-b;

if search(n-1)

global expression

bool=1;

return

end

expression{i}=[40,expb,45,expa,41];

number(i)=b-a;

if search(n-1)

global expression

bool=1;

return

end

expression{i}=[40,expa,42,expb,41];

number(i)=a*b;

if search(n-1)

global expression

bool=1;

return

end

if b~=0

expression{i}=[40,expa,47,expb,41];

number(i)=a/b;

if search(n-1)

global expression

bool=1;

return

end

end

if a~=0

expression{i}=[40,expb,47,expa,41];

number(i)=b/a;

if search(n-1)

global expression

bool=1;

return

end

end

number(i)=a;

number(j)=b;

expression{i}=expa;

expression{j}=expb;

end

end

bool=0;

總結(jié)

以上是生活随笔為你收集整理的用matlab算24点小游戏,24点游戏的Matlab程序的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。