im trying to do a counter function

2 ビュー (過去 30 日間)
sebastian
sebastian 2013 年 12 月 6 日
回答済み: sebastian 2013 年 12 月 6 日
hello
im trying to do a tic tac toe game
and im working on the player vs player mode
all the nine buttons have the same callback TTTPBCB but different tags
so this is what i have in mind
i will initialize the game with
move=0 player=-1
so this is how i want it to work
playermove=player^move so it will change between -1 and 1
ButtonClicked=get(gcbo,'Tag');
Choicestr=ButtonClicked(6); % 6 is because each button have a number from 1 to 9 on the 6 entry
Choice=str2double(Choicestr);
so if playermove==-1
set(findobj('Tag',ButtonClicked),'String', 'X','Enable', 'Off')
GameState(Choice)=-1% game state is a zeros(3,3)
elseif PlayerMove==1
set(findobj('Tag',ButtonClicked),'String', 'O','Enable', 'Off')
GameState(Choice)=1
end
so i need to add something that when i press any of the 9 button the moves increase by one
thank you for your help

採用された回答

sebastian
sebastian 2013 年 12 月 6 日
nevermind i already figure it out

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 12 月 6 日

sebastian
sebastian 2013 年 12 月 6 日
i want to let you know that im new in programing so i don't understand most of the language
and im using the fig only mode not the mathlab auto generated code
so if u can be more specific on how to get this done i will appreciate it

カテゴリ

Help Center および File ExchangeStrategy & Logic についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by