Giter Site home page Giter Site logo

connect-4's Introduction

Connect-4

To create a Connect 4 game with basic AI move choosing using the random() function. Choose yellow or red discs, and then take turns dropping coloured discs into a seven-column grid. When you get four discs in a row in two players, you win. When the computer selects what move to make next, it evaluates all of its available positions, but to simplify things, it utilises a random() function to select the column. To enhance this version, the minmax algorithm can be applied to ensure that the system wins with the best odds.

Algorithm:

  1. Start
  2. Request the selection of the second player. Either a computer or a person.
  3. If the computer is chosen, it chooses a random place from 1 to 7 to drop the coin.
  4. If Human is chosen, choose a position from 1 to 7 to drop the coin.
  5. The check(int, int) function determines whether there is a horizontal, vertical, right diagonal, or left diagonal match.
  6. If check(int, int) returns 1, the player in question wins.
  7. Otherwise, the match is repeated until the check(int, int) function returns 1.
  8. If all columns are filled, the match is a tie.
  9. Finally, the winning player is shown.
  10. End

Sample Output:

image

connect-4's People

Contributors

ashwath0102 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.