Questions tagged [connect-four]

Connect Four is a board game with seven columns where players take turns dropping markers into a column to get four in a row (horizontal, vertical or diagonal). Use with a programming language tag of your choice about writing programs to play this game.

26 questions
10
votes
3 answers

How to implement the function that checks for a win in a Python-based connect-four game?

I am writing a connect 4 game in which you can choose the size of the board. The game works flawlessly for most board sizes but gives me problems when the board is taller then it is wide. I keep getting index out of range errors and I'm not sure…
Matthew Hanson
  • 321
  • 5
  • 7
  • 15
2
votes
1 answer

How to make the game buttons show up in a Python-based Connect Four game?

I am currently working on making a Python version of the game Connect Four. It is going to be pretty basic, using Tkinter for the interface. I think I have most of the code laid out and I'm not getting any errors, but it currently isn't creating the…
Jakemmarsh
  • 4,601
  • 12
  • 43
  • 70
2
votes
1 answer

How to track mouse position in connect 4 Turtle GUI?

I'm making a connect 4 game using turtle on python and my homework has a requirement of making mouse tracker which highlights the token place holder when the mouse is in the same column as the token place holder as shown in the picture. But I just…
2
votes
2 answers

Connect4 in Python - Pieces doesn't drop into the board

I'm writing Connect4 in Python. My problem is the function of player_one and player_two don't seem to be working, so the no piece is drop onto the board after player was asked to give input. I also wonder if my code to return the board after player…
Kentta
  • 47
  • 1
  • 7
2
votes
3 answers

Assigning multiple values from a single input statement disregarding whitespace

I'm making a connect-four game where the board size can be decided by the players while ignoring the amount of spaces between the numbers. inp = input("Please input the size of the board youd like with the number of rows before " "the…
808Blues
  • 87
  • 1
  • 4
2
votes
1 answer

connect four matlab

Ok, right now i'm trying to create a connect four game through Matlab coding; now the game is still infant but my problem is that I either can't get the figure to plot in each grid square or I can't get the 'circle' figure to plot at all. Please…
FunnyBro777
  • 23
  • 1
  • 3
1
vote
1 answer

Why are my functions executing out of order at the end of this Connect Four game? It works in some browsers

I'm having two timing issues here, both involving the process in this game once the winning move has been made: https://codepen.io/acchang/pen/XWePpWB Ideally, I should (1) pick the winning space (2) see the winning space filled (3) have the alert…
acchang
  • 59
  • 7
1
vote
1 answer

C++ Connect 4 Minimax + Alpha Beta Pruning AI making poor decisions

This post is kind of a follow-up to my last post. To increase the efficiency of a minimax connect-4 AI algorithm, I decided to use alpha-beta pruning. This definitely helped with the long runtime of the program (which I previously believed to be an…
1
vote
1 answer

Python connect 4 play function

I'm making a connect4 game for a class and im running into an error with my play function that I'm having difficulties figuring out. def play(grid,column,checker): counter = 0 for x in grid[0]: counter += 1 print(counter) …
808Blues
  • 87
  • 1
  • 4
1
vote
2 answers

Function asking for Input in haskell (with print in do block)

im really new to haskell and i'm trying to implement a simple connect4 game, when I try to get the player to input a new move I want to prompt him to do so. This is the relevant code I have: advanceHuman :: Board -> Board advanceHuman b = do …
javi8
  • 33
  • 3
0
votes
0 answers

why does the compiler give me list index out of bounds error?

x = int(input("Row :")) y = int(input("Column:")) z = y+x\*8-9 board = \[\] def ShowBoard(): j = 0 for i in range(64): if i == z: board.append('0') else: board.append('_') for item in…
0
votes
0 answers

Connect 4 add element from User in LIST PYTHON

I have created the matrix, but when the data entered by the user is added the board loses the initial structure I need the board to continue printing in the same format as when the game starts. This is the code: tablero = [] NUM_FILAS = 6 NUM_COLUM…
Staryellow
  • 31
  • 6
0
votes
0 answers

What win check will work for my connect four game?

I am about halfway through making connect four in python, but I don't know how to make a win check function. This is what I have so far: board = [['0', '0', '0', '0', '0', '0'], ['0', '0', '0', '0', '0', '0'], ['0', '0', '0', '0', '0', '0'], ['0',…
0
votes
0 answers

Piece Recognition in Java For A Connect 4 Game Board

I'm currently working on a project and I'm trying to transform a physical 'Connect 4' game board onto a digital java program. Using Open-CV and my webcam, I am able to constantly grab photos of this game board and save them locally on my PC. To get…
0
votes
0 answers

Diagonals in winning conditions in connect four program are not working correctly and I do not know why

My winning conditions for rows and columns works completely fine. However, my diagonals do not. It will say you have won if you get your own number in 4 different rows and not in a direct diagonal as the game is meant to be played. %check if won by…
1
2