Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- board = ['-','-','-';'-','-','-';'-','-','-'];
- running = 1;
- round = 0;
- mtlb_fprintf('Welcome to tictacto bitches!');
- while(running == 1)
- //figure whos turn it is
- if(pmodulo(round,2) == 0)
- mtlb_fprintf('~= Xs Turn =~');
- turn = 'X';
- else
- mtlb_fprintf('~= Os Turn =~');
- turn = 'O';
- end
- col = input('Column:');
- row = input('Row: ');
- // check if space if valid, if so then set acc|ding to turn
- if (0)
- mtlb_fprintf('!> Enter a number dumbass');
- else
- if ((col >= 0) & (col <= 3) & (row >= 0) & (row <= 3))
- if(board(row,col) == '-')
- round = round + 1;
- board(row,col) = turn;
- else
- mtlb_fprintf(' That space is taken jerkoff');
- end
- else
- mtlb_fprintf(' This is tictactoe idiot, try a space that exists');
- end
- end
- mtlb_fprintf('');
- disp(board);
- mtlb_fprintf('');
- //VICT|Y CONDITIONS
- //row 1
- if((board(1,1) == board(1,2)) & (board(1,2) == board(1,3)))
- if (board(1,1) ~= '-')
- winner = board(1,1);
- mtlb_fprintf('%s wins... congratualtions on beating yourself without porn', winner);
- running = 0;
- end
- end
- // row 2
- if((board(2,1) == board(2,2)) & (board(2,2) == board(2,3)))
- if (board(2,1) ~= '-')
- winner = board(2,1);
- mtlb_fprintf('%s wins... congratualtions on beating yourself without porn', winner);
- running = 0;
- end
- end
- // row 3
- if((board(3,1) == board(3,2)) & (board(3,2) == board(3,3)))
- if(board(3,1) ~= '-')
- winner = board(3,1);
- mtlb_fprintf('%s wins... congratualtions on beating yourself without porn', winner);
- running = 0;
- end
- end
- // column 1
- if((board(1,1) == board(2,1)) & (board(2,1) == board(3,1)))
- if (board(1,1) ~= '-')
- winner = board(1,1);
- mtlb_fprintf('%s wins... congratualtions on beating yourself without porn', winner);
- running = 0;
- end
- end
- // column 2
- if((board(1,2) == board(2,2)) & (board(2,2) == board(3,2)))
- if (board(1,2) ~= '-')
- winner = board(1,2);
- mtlb_fprintf('%s wins... congratualtions on beating yourself without porn', winner);
- running = 0;
- end
- end
- // column 3
- if((board(1,3) == board(2,3)) & (board(2,3) == board(3,3)))
- if (board(1,3) ~= '-')
- winner = board(1,3);
- mtlb_fprintf('%s wins... congratualtions on beating yourself without porn', winner);
- running = 0;
- end
- end
- // backward cross
- if((board(1,1) == board(2,2)) & (board(2,2) == board(3,3)))
- if (board(1,1) ~= '-')
- winner = board(1,1);
- mtlb_fprintf('%s wins... congratualtions on beating yourself without porn', winner);
- running = 0;
- end
- end
- // foward cross
- if((board(3,1) == board(2,2)) & (board(2,2) == board(1,3)))
- if (board(3,1) ~= '-')
- winner = board(3,1);
- mtlb_fprintf('%s wins... congratualtions on beating yourself without porn', winner);
- running = 0;
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement