Tic-tac-toe in MatLab - help needed

Eowyn of Rohan

Beta member
Messages
1
Location
Serbia
Hi guys!

I've started learning programming with MatLab. Being cocky is not good when you have lack of skill - what I know now. I decided to make project - tic-tac-toe game for 2 players in GUI. I've been struggling a lot. I have an idea what to do, but I don't know how exactly should I write that programme.

I've created GUI with board made of buttons (3x3). Every button has callback with loop (if) relating to number of player (1 is O, 2 is X) and in each case it shows O or X on the button.

The problem is with main game-play. I've written function like this:
Code:
function [player, winner] = game (player, winner)
    NewBoard; % creating GUI board described above
    winner = 0;
    while winner == 0 % as long as there's no winner
        player = 1; % O starts
        uiwait(handles.figure1); % programme will wait for a reponse from player
        winner; % this is the function which checks whether there's winner - checking horizontally, vertically and diagonally, output of that function is variable "winner" (for O it will be equal 1 and for X ==2)
        player = 2; % X plays
        uiwait(handles.figure1);
        winner; 
   end
end

Is there someone who could help me? :(
 
Back
Top Bottom