Connect4-Python | Connect 4 programmed in python using pygame | Learning library
kandi X-RAY | Connect4-Python Summary
kandi X-RAY | Connect4-Python Summary
Connect 4 programmed in python using pygame
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Minimax the minimax
- Score piece
- Returns true if the player is winning move
- Computes the score of a given piece
- Return a list of valid locations
- Get the next open row in the board
- Drop piece from a piece
- Check if a location is a valid location
- Checks if the board is a terminal node
- Pick a piece from the board
- Draw a board
- Find the next open row in the board
- Create a board
- Pretty print the board
Connect4-Python Key Features
Connect4-Python Examples and Code Snippets
Community Discussions
Trending Discussions on Connect4-Python
QUESTION
I tried to make a MiniMax AI using a tutorial,
The AI doesn't work and just goes on the bottom row and build up each time, reporting a column index of 0, 1, 2, 3, 4, 5, 6
and then for the next row and so on. The only thing I managed to find a lot different in the code output compared to mine and the tutorials working version was the depth of the minimax algorithm as it goes along. Where this was the depth of the working one as it recurred, and this was the depth of my one (it was longer than this but my console didn't keep all of it). I've tried a lot of things to get it working including reworking the board system to multiple lists inside a list and many other things like deleting some parts of the code and reworking scores but it doesn't seem to change.
My minimax function is:
...ANSWER
Answered 2020-May-05 at 17:35The board is passed passed to your minimax function as a parameter node, but inside the function you use board.
Reference program: def minimax(board, depth, alpha, beta, maximizingPlayer):
Your program: def minimax(node, depth, alpha, beta, maximizingPlayer):
Your recursive minimax function is therefore not working as expected.
Edit: To fix this replace board inside minimax with node (don't change node in the function definition to board)
Edit 2: Also check the function scorePos - you have a hardcoded computerDisc instead of using the function argument.
Edit 3: Additionally, other helper functions like isBoardFull() and isSpaceFree() should operate on the board copy, not the global variable.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Connect4-Python
You can use Connect4-Python like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page