im trying to do a counter function

조회 수: 10 (최근 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 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