tic-tac-toe

Java Tic Tac Toe Game, Gui not working [closed]

本小妞迷上赌 提交于 2019-12-13 10:06:51
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . My GUI is not working for my tic tac toe game...I would like to find out what i am doing wrong/what is going wrong and why this is not working the way it

C++ Tic Tac Toe Game [duplicate]

梦想与她 提交于 2019-12-13 08:49:01
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: C++ Tic Tac Toe Game I tried my best and this is what I have so far, please help me out. This is my code that I need to complete. Implement displayBoard to display Tic Tac Toe board. Prompt User for a box on the board to select, i.e. a number between 1 and 9 with 1 being the upper left corner. use cin.get(box) to get the box number and isdigit to verify it is a number; 1 | 2 | 3 4 | 5 | 6 7 | 8 | 9 If the box is

Changing Variables within a Function in Tkinter

白昼怎懂夜的黑 提交于 2019-12-13 08:28:55
问题 I want the X and O animations to switch back and forth upon mouse clicks. The problem is in the function XorO. I don't really understand why, but it will only create Xs when I click it. I think it may have to do with how I wrote the turn variable. Here is what I have. from tkinter import * tk = Tk() width = 600 third = width / 3 canvas = Canvas(width=width, height=width) tk.title = ("Tic Tac Toe") line1 = canvas.create_line(200, 0, 200, 600) line2 = canvas.create_line(400, 0, 400, 600) line3

Java TicTacToe game winCondition?

大憨熊 提交于 2019-12-13 07:27:58
问题 How would I make a win condition to my tic-tac-toe game? I need to also make it so when the player is done, that it will ask them if they want to play again. If you figure out a way, can you please tell me why that is so. Here is my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; @SuppressWarnings("serial") public class game extends JFrame{ JFrame gameWindow = new JFrame("Tic-Tac-Toe"); private JButton buttons[] = new JButton[9]; private String mark = ""; private int

How to check for win in custom sized tic-tac-toe diagonals

余生颓废 提交于 2019-12-13 02:47:10
问题 I'm making a simple tic tac toe game, where user can specify the size of the grid (amount of columns and rows). I need to create a function, that could check for a win in all the diagonals in the grid. For the grid, I'm using a 2-dimensional list, that looks like this (3x3 example): grid = [['x', '-', 'o'], ['o', 'x', '-'], ['-', '-', 'x']] grid[row][col] This should be a winning situation I have already created a check for the vertical and horizontal win, but I can't quite figure out, how to

tkinter tic tac toe program

﹥>﹥吖頭↗ 提交于 2019-12-13 02:03:45
问题 I was experimenting with tkinter and thought of implementing a simple tic-tac-toe game. here is what i came up with import tkinter as tk class Gui(tk.Frame): def __init__(self, master): super().__init__(master) self.parent = master self.parent.title("tic tac toe") logo = tk.PhotoImage(file="X.png") for i in range(3): for j in range(3): w = tk.Label(self,image=logo) w.grid(row=i, column=j) self.pack() if __name__ == '__main__': root = tk.Tk() logo = tk.PhotoImage(file="X.png") f = Gui(root)

Tic Tac Toe Checking winner

柔情痞子 提交于 2019-12-12 15:05:37
问题 Im having problems with the win code. Ive been trying for a really long time and i have no idea what the problem is. Ive tried debugging but i got nothing from that.(Sorry for the Swedish comments) import java.util.Scanner; public class Tictactoe { static char[][] MakeMove (char[][] spelplan, char spelare, int rad, int kolumn){ spelplan[rad][kolumn]=spelare; System.out.println(spelplan[rad][kolumn]); return spelplan; } static boolean CheckMove (char[][] spelplan, int x, int y){ if (spelplan[x

Tic tac toe java mouseListener

浪尽此生 提交于 2019-12-12 05:56:27
问题 So I've been working on a Tic Tac Toe App using MVC. I'm having difficulties implementing the mouse Listener in the views page. I need each panel of the board to be clickable. Can someone help me? public class TicTacToeView extends JFrame{ private JButton oButton, xButton; public JPanel board; public ArrayList<Shape> shapes; public TicTacToeView(){ shapes = new ArrayList<Shape>(); JPanel topPanel=new JPanel(); topPanel.setLayout(new FlowLayout()); add(topPanel, BorderLayout.NORTH); add(board

How to call a minimax method(with alpha beta pruning) properly

南笙酒味 提交于 2019-12-12 03:38:50
问题 This is my minimax method which implements alpha beta pruning and memoization: public int[] newminimax499(int a, int b){ int bestPos=-1; int alpha= a; int beta= b; int currentScore; //boardShow(); String stateString = ""; for (int i=0; i<state.length; i++) stateString += state[i]; int[] oldAnswer = oldAnswers.get(stateString); if (oldAnswer != null) return oldAnswer; if(isGameOver2()!='N'){ int[] answer = {score(), bestPos}; oldAnswers.put (stateString, answer); return answer; } else{ for(int

Tic Tac Toe with a win and taken check - Matlab

拥有回忆 提交于 2019-12-12 02:49:46
问题 I'm making a tic tac toe game and I'm bombarded with various errors everytime I try to debug. I'm not sure where the problem is. The main error is either Index exceeds matrix dimensions or Subscript indices must either be real positive integers or logicals in line 8 of my 'checktaken' function. Below is my code, where tttGame is the main function, boardplot does the plotting, and checkwintest/check taken see if a position is taken or if there is a win. I have asked many people for help and