im trying to do a counter function
2 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
More Answers (2)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!