im trying to do a counter function

2 visualizzazioni (ultimi 30 giorni)
sebastian
sebastian il 6 Dic 2013
Risposto: sebastian il 6 Dic 2013
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

Risposta accettata

sebastian
sebastian il 6 Dic 2013
nevermind i already figure it out

Più risposte (2)

Walter Roberson
Walter Roberson il 6 Dic 2013

sebastian
sebastian il 6 Dic 2013
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

Categorie

Scopri di più su Strategy & Logic in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by