im trying to do a counter function

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Strategy & Logic 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by