Jump to content




Connect Four

game computer wireless

  • You cannot reply to this topic
15 replies to this topic

#1 Luiginico

  • Members
  • 12 posts
  • LocationItaly

Posted 20 March 2013 - 11:23 AM

Hi, it's me again, this time I made a little Connect Four.

To download use: Pastebin get u4FPcbqD c4

Features
  • Multiplayer
  • Uses the new modems API
  • Simple GUI
  • Auto-Win Detection
  • 100% Advanced computer compatible

To Do
  • Singleplayer mode (Still don't know how to code the AI)
  • Colours
  • Tutorial screen

Screenshots:
Spoiler

The code can be found here: http://pastebin.com/u4FPcbqD

Edited by Luiginico, 20 March 2013 - 11:30 AM.


#2 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 20 March 2013 - 11:27 AM

So this is like tic tac toe?
Seems nice!
Now you should add some kind of single player with an AI..
Since that would be awesome too..

#3 Luiginico

  • Members
  • 12 posts
  • LocationItaly

Posted 20 March 2013 - 11:34 AM

View PostHellkid98, on 20 March 2013 - 11:27 AM, said:

So this is like tic tac toe?
Seems nice!
Now you should add some kind of single player with an AI..
Since that would be awesome too..
Yes, it's like a tic tac toe with gravity.
I could make a singleplayer, but I have no idea how to make the AI

#4 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 20 March 2013 - 11:38 AM

View PostLuiginico, on 20 March 2013 - 11:34 AM, said:

View PostHellkid98, on 20 March 2013 - 11:27 AM, said:

So this is like tic tac toe?
Seems nice!
Now you should add some kind of single player with an AI..
Since that would be awesome too..
Yes, it's like a tic tac toe with gravity.
I could make a singleplayer, but I have no idea how to make the AI
Well it's not impossible but it's really difficult though..
Anyway, Great program!

#5 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 20 March 2013 - 11:42 AM

Want me to make a colour version of this with clicking?

#6 Luiginico

  • Members
  • 12 posts
  • LocationItaly

Posted 21 March 2013 - 07:40 AM

View PostShnupbups100, on 20 March 2013 - 11:42 AM, said:

Want me to make a colour version of this with clicking?
The code is up there for everybody, if you want to, go ahead :)

#7 RustikGaming

  • Members
  • 19 posts

Posted 24 March 2013 - 05:17 AM

Edit: nevermind just a derp by me

#8 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 24 March 2013 - 05:25 AM

View PostRustikGaming, on 24 March 2013 - 05:17 AM, said:

just an fyi the code for this program is broken with the new functionality of rednet channels and modems
Uhhh it is using the modems and channels...

EDIT: nvm, just saw your edit...

#9 QuantumGrav

  • Members
  • 36 posts
  • LocationUnited States

Posted 25 March 2013 - 06:56 PM

Really like this program, Good Job!

I'm working on some form of game playing intelligence on other games, so here's my two cents on how you could program the computer to play.

A basic strategy could pick a random number between 1 and the number of columns (8), then play in that column. It wouldn't play brilliantly, but it would play.

Slightly more advanced could be detecting if the player has three pieces in a row, then block it. You've got the board as a table, so check every square surrounding a player's piece in that table. If another player's piece is next to the original, continue on that axis, and, again, see if another of the player's pieces is there. If so, play in the column to block it. That is quite a bit harder to program, but entirely possible.

Another even more advanced strategy would assign values to certain configurations of pieces. For example, the computer would value having 4 of its pieces in a row as basically infinite. Having three in a row would have a positive value and so on and so forth. It would also analyze the opponent's configurations, and assign those negative values. Add those two numbers together and you have a quantifiable number for every position. The larger that number is, the better the position is for the computer. The computer would iterate through several or every possible scenario for two or so turns, analyze them all, and then pick the one with the largest number. That would be remarkably difficult, but again, entirely possible.

Sorry for being so wordy. Simply based on easiness, if your going to implement an AI, I would use the basic one. There also may be other, simpler ways to create an AI with some intelligence that I haven't thought of.

Again, I really like your program! Hope that helps somewhat!

#10 martin509

  • Members
  • 53 posts

Posted 26 March 2013 - 08:21 AM

One question: Why use channels? It's two-player, so it's not like you need them. I run a tekkit server with my friends and really want to play this game, but tekkit has to be a light-year behind and use CC 1.3 or so.

#11 Ristyo

  • Members
  • 31 posts
  • LocationIn my computer house located in a random village, programming.

Posted 27 March 2013 - 03:01 AM

There is a redstone computer map that plays connect four, and now there is the same without redstone

#12 Luiginico

  • Members
  • 12 posts
  • LocationItaly

Posted 22 June 2013 - 08:36 AM

Wow, so many replyes, considering this is the simpler of my 3 games

View Postmartin509, on 26 March 2013 - 08:21 AM, said:

One question: Why use channels? It's two-player, so it's not like you need them. I run a tekkit server with my friends and really want to play this game, but tekkit has to be a light-year behind and use CC 1.3 or so.
I never liked how rednet worked, a simple broadcast could destroy your entyre program, and, using channels you can play multiple istances of this game w/o problems

View PostQuantumGrav, on 25 March 2013 - 06:56 PM, said:

Really like this program, Good Job!
[...]
Again, I really like your program! Hope that helps somewhat!
Thanks :)

View PostQuantumGrav, on 25 March 2013 - 06:56 PM, said:

[...]
A basic strategy could pick a random number between 1 and the number of columns (8), then play in that column. It wouldn't play brilliantly, but it would play.
[...]
(The coloumns are 7), yeah, that was my original idea, but, it's like playng against a cat, but still an idea

View PostQuantumGrav, on 25 March 2013 - 06:56 PM, said:

[...]
Slightly more advanced could be detecting if the player has three pieces in a row, then block it. You've got the board as a table, so check every square surrounding a player's piece in that table. If another player's piece is next to the original, continue on that axis, and, again, see if another of the player's pieces is there. If so, play in the column to block it. That is quite a bit harder to program, but entirely possible.
[...]
I'm already using this method to detect if a player managed to win, so it wouldn't be hard to do

View PostQuantumGrav, on 25 March 2013 - 06:56 PM, said:

[...]
Another even more advanced strategy would assign values to certain configurations of pieces. For example, the computer would value having 4 of its pieces in a row as basically infinite. Having three in a row would have a positive value and so on and so forth. It would also analyze the opponent's configurations, and assign those negative values. Add those two numbers together and you have a quantifiable number for every position. The larger that number is, the better the position is for the computer. The computer would iterate through several or every possible scenario for two or so turns, analyze them all, and then pick the one with the largest number. That would be remarkably difficult, but again, entirely possible.
[...]
This, is gonna be hard, but, maybe, w/ some time I can come up w/ something, I will try.

#13 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 22 June 2013 - 08:48 AM

I've found this ANN. you can use it for singleplayer (it's a learning artificial Neural Network) :D/>/>

#14 Luiginico

  • Members
  • 12 posts
  • LocationItaly

Posted 22 June 2013 - 09:02 AM

View PostFreack100, on 22 June 2013 - 08:48 AM, said:

I've found this ANN. you can use it for singleplayer (it's a learning artificial Neural Network) :D/>/>
I don't tink that a ANN is necessary, I think I can get the job done w/ some ifs

#15 jwilman185

  • Members
  • 3 posts

Posted 22 June 2013 - 09:03 PM

I tried this but failed :( but well done :)

#16 Nick0157

  • Validating
  • 6 posts

Posted 25 June 2013 - 01:54 PM

Nice game! I'll have to add it to my computer with all my other games!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users