Agh its so hard to keep up with the diagonals...this would have been SO MUCH EASIER if scratch had matrices. But no, they had to keep it simple for children. Jeez, I'm really peeved at the limitations of Scratch...
Just thinking about how an AI for this might work...I think one rule for sure would have to be look for 3 in a row with open ends and plug one of the ends if found.
Excellent interface! The AI could be a bit sharper though...I was able to win by simply dropping 4 in a row along the bottom. Interestingly enough, it didn't play the same way next time. But I still was able to beat it with that method a number of times :)
Thanks for commenting Jens. About the AI: sorry again for the simplicity, but I'll find a way to fix it. I actually just figured it out from your comment.
It's good, but there's a glitch in which the computer can add pieces above the grid - I lost because the computer added a yellow piece above the grid to connect the four pieces. :(
Unfortunately, the AI does that. I think the problem is checking if it can put it there or not...the way I coded it seemed right but it isn't...thanks for posting!
omg awsome!! *high five* but the cp beat me with only 2 checkers. cuz one was all the way at the top, and then it put another on top of it beyong where it should be able to, and it won
Download the 3 sprites and 7 scripts of "Connect-4" and open it in Scratch
Project Notes
Connect 4 Scratched!!!
Press space for different backgrounds.
All/Most of the bugs should be fixed! Great news for me.
You play red. Click with the mouse to drop your checker into the playing field (the white dots) make sure it is in the field or it won't be a valid move. You also can't drop a checker in there is one at the top.
Yellow is a computer.
Connect 4 to win!
Download it to see how everything works. It is fully commented to help you understand (though it did take quite a bit of math to figure out).
Scratch REALLY needs matrices (2-D arrays) because it is REALLY hard to do this without them.
Comments
You need to be logged in to post comments
Add a Comment
make the computer harder, but still good game
fun.
Cool!
this is simple:)
i won when i didn't.
you could make it better love it still lol this is sweet.
Can you add better AI :) ?
I like this game !
i win!
I won!
Awesome! I won! :)
lol i won but i didnt get 4 in a row xD
that is wicked
dude, just saying, you should seriously use flash.
@TimeFreeze, the actual file, so you can play the flash game online and many people can see it. I think you already replied but I thought I'd ask.
(view all replies)Though I'm wondering; where the heck do you post actionscript stuff? Newsground or somewhere like that?
(view all replies)Like archmage?
(view all replies)umm... I got connect 4, but it didn't say I won. Is there a problem with diagonal going up and left (or down and right)?
Agh its so hard to keep up with the diagonals...this would have been SO MUCH EASIER if scratch had matrices. But no, they had to keep it simple for children. Jeez, I'm really peeved at the limitations of Scratch...
Too easy.
Can I use the scripts for my game? I will give credit.
Do whatever man. There are no copyrights for my programming.
(view all replies)the AI is GENIOUS (for a scratch game) it is pretty buggy... and stupid... but at least it can be considered a AI and not just a pile of scripts...
Scratch is the worst for programming AI.
I've won 4times in a row, its a bit too easy.
I love your win checking logic! Starting at the last move position is a great idea and really simplifies things a lot. Marvelous!
Just thinking about how an AI for this might work...I think one rule for sure would have to be look for 3 in a row with open ends and plug one of the ends if found.
Excellent interface! The AI could be a bit sharper though...I was able to win by simply dropping 4 in a row along the bottom. Interestingly enough, it didn't play the same way next time. But I still was able to beat it with that method a number of times :)
The best game i have ever played.
Also, the AI got 3 in a row and won :P
(view all replies)1. Kiss does rock/heavy metal. 2. I'm 15, soon to be sixteen near the end of the month (9/29)
(view all replies)Vinnie Vincent, a former lead guitarist of KISS (I'm a big fan of them).
(view all replies)I coded it incorrectly.
(view all replies)"what is that in your icon?" What are you talking about? My scratch pic?
(view all replies)I like it!
P.S. I won :P
Cool! I actually lost though...but still, cool!
Great! It's harder to win against the yourt AI now, Good job!
why has no one seen this??? Its great! you shold have made front page a while ago :D
Excellent! Nice GUI and fun to play. Feels a bit too easy to win against the machine, though
Now try Jens, I fixed the AI. The problem was it did not start where you (Red) last made a move.
I mean while reading your comment.
Thanks for commenting Jens. About the AI: sorry again for the simplicity, but I'll find a way to fix it. I actually just figured it out from your comment.
I won! 4th move! :) LOLZ
awsome u managed to make a computer i thought you would need another person and its the greatest
also thought the computer isnt very smart
I have a bug here. I didn't connect 4, but I win anyways. The board looks like this: OOOOOOO OOOOOYO OOOOORO OOOOOYO OOOOOYO RRORRYO
O= blank Y= COM R= P1
Oh yeah, that was from top to bottom.
For you supporting me, Oldschooler2, you know you have my full support. Love-it and a Favorite this; Keep sharpening your programming talents.
Thanks; my parents always said "it pays to be kind. You won't get respect unless you give it to others".
The computer connected four diagionally, but I just kept playing and I connected 4 and it said "Red Wins!" Nice Job though.
It's good, but there's a glitch in which the computer can add pieces above the grid - I lost because the computer added a yellow piece above the grid to connect the four pieces. :(
Unfortunately, the AI does that. I think the problem is checking if it can put it there or not...the way I coded it seemed right but it isn't...thanks for posting!
The computer's AI is pretty bad, but I guess it would be impossible to do better. Deserves a front page.
In addition, I have very little idea on how to do a proper AI without making it even more complicated.
The real problem is I wanted to keep it simple for the AI. The coding is already cluttered, I didn't want to make it worse.
NICE!
The computer isn't very hard, but still, I would have a very hard time doing that.
omg awsome!! *high five* but the cp beat me with only 2 checkers. cuz one was all the way at the top, and then it put another on top of it beyong where it should be able to, and it won
Yeah...I'm going to fix that.
nice game
lol. i was just playing that game!!
you can go above the board, but no bugs otherwise
Great job! i won!