Share your repls and programming experiences

← Back to all posts
Connect Four
Trapdoorspyder

Nice Connect Four game I made in python. I've added a lot of little quality of life features that not everybody might notice, but make the game a much more enjoyable experience to play and win. Feel free to give feedback!

To play:
Red and Blue will alternate turns automatically. The loser of the previous game will go always go first in the next.
To make a play, all you have to do is type in the number of the row you want to play in and press enter.

Enjoy!

Note: If you encounter any errors, please put down in the comments the board state from when it happened and what the most recent play was. Thanks!

Voters
TristenAengus
firedragondnd
JarishaanThirus
Jakman
BobTheTomatoPie
ohyea
asdjfhjasdhfelh
KeenanBusch
CoolJames1610
andrewzhang838
Comments
hotnewtop
BlobWasPwned

𝙘𝙤𝙤𝙡

Warhawk947
BlobWasPwned

@Warhawk947

Warhawk947

@MatReiner 𝙘𝙤𝙤𝙡

MyloBishop

Cool! It would be cool if you could add an AI for the game!

Trapdoorspyder

Working on it...

CodingCactus

i don't know if this is a problem with repl.it or your code, but when i type a number, then press backspace, it deletes the prompt??

Trapdoorspyder

I've noticed that happening, but I'm not sure if there is really anything wrong with the code. It's just a basic input command.

CodingCactus
Trapdoorspyder

I might do that. I did manage to fix it though, instead of printing text and sticking the input on the end of it, which is how it was before, I'm just doing the whole thing as an input. It does result in a bit more code, but that's fine.

CodingCactus

@Trapdoorspyder surely a one line input (choice = input("blah")) would be less code than

Trapdoorspyder

I was doing it that way because unlike your example, I actually had an if statement before, so it looked more like this:

if(this):
print("blah")
else:
print("meh")
choice = input()

Also, how did you get the text to go in a box like that?

CodingCactus

@Trapdoorspyder put three backticks above it

CodingCactus

@Trapdoorspyder even in there, a one line input would be better:

CodingGoose

I used to play this Game so much when I was little. This game is So Cool. I love the winning screen too

[deleted]

@Trapdoorspyder

COOL!

but how did you do the board, like the double vertical line thing?

CodingCactus

@blackjkl it's an ascii character

[deleted]

@CodingCactus
I know but how to you type it?

CodingCactus

@blackjkl either:
alt + [some 3 digit number on kepad]
or
copy paste

Trapdoorspyder

I copy/pasted from this website:
https://fsymbols.com/keyboard/windows/alt-codes/list/
You can also find them at the bottom of the code for the connect four game.

MyloBishop

Did you program in every possible win? Thats a very inefficient way of doing it.

Trapdoorspyder

Kind of. I have a for loop for each direction checking all the ones in that direction. Not great, but not horrible.

tyolmedo

𝙘𝙤𝙤𝙡

KeenanBusch

Nice game dude

Hihi21

nice

R_Gaspar

Nice Game. Now I want to replicate it in Java. Try this game out. I would like to see your Python version for this, if you're looking for a small challenge. Your choice to do either, but to whatever you choose to do, enjoy it!
https://repl.it/@R_Gaspar/Tic-Tac-Toe

Trapdoorspyder

@R_Gaspar I just might do that once I'm done with the bot for this game that I'm working on.

R_Gaspar

@Trapdoorspyder A bot? That's interesting... Let me know how it turns out. Never tried AI or "AI" on a game before. I think the Tic-Tac-Toe could use a bot.

VMTU

𝙘𝙤𝙤𝙡

TheFatBananaMan

𝙘𝙤𝙤𝙡

[deleted]

I lUV iTTT 💕 I wish I can make a code like u did T^T

mwilki7

you should use emojis for the pieces
🔴🔵

Trapdoorspyder

Unfortunately, the emojis end up off center, so they won't work. It was a good idea though!

BlobWasPwned

-ty two

[deleted]

Cool Game!!

thenullified

:)

BlueComet

_Nice job_

could you make a bot

Trapdoorspyder

I've been thinking about adding an AI for solo play in the future, but it will take a bit of time. I do intend to do it though, at least at some point.

BraylanBB121

I got an error message, it says line 96 if(b6[].....)
IndexError: List index out of range.

Trapdoorspyder

Yup. Just fixed that one. I knew it existed, but couldn't figure out what was causing it. I figured out what was wrong and now it's all good! (hopefully)
Essentially, it was trying to detect wins and tried to look off of the board.

BraylanBB121

Ok. Thank you. @Trapdoorspyder

BraylanBB121

I love it! The ONLY thing I would suggest (very small suggestion) is that make the background color of whoever wins, make it that color.

Trapdoorspyder

I'm not sure if that's possible with Python, but if it is, I will most certainly do it.

BraylanBB121

You can do it very easily with the module 'colorama' @Trapdoorspyder

Trapdoorspyder

Thanks! In the meantime until I implement that, I have spruced up the 'You win' message a little bit.

BraylanBB121

The most recent play was Blue: 1st row, 4th column.

BraylanBB121

The new winning text looks great! @Trapdoorspyder

Trapdoorspyder

Glad you appreciate it!

python9160

@BraylanBB121 or you could use ansi escape codes like
'\u001b[31m' for red and '\u001b[31m' for blue

Bookie0

Very cool I like it!

ChezCoder

nice! Would be awesome if you made it multiplayer. I can only play it with myself :(

Trapdoorspyder

Unfortunately, I don't know how to do that currently, but I will attempt to implement that sometime. Thanks for the feedback!

ChezCoder

@Trapdoorspyder I will be willing to help

Trapdoorspyder

Thanks!

HenryCommandeur

I can't use it for some reason. Too bad I bet it was great. :v(

Trapdoorspyder

@HenryCommandeur That's unfortunate. What kind of device are you on?

CodingCactus

very nice!!