Giter Club home page Giter Club logo

connect4's Introduction

connect4

I wrote this program for my CSC 240 class at Mesa Community College. it has been modified slightly to work in Racket; no other changes have been made except for the intro comments.

This program will define several functions to work with a matrix and allow a user to play a game of connect four.

The requirements stated that all functions must begin with the programmer's initials; that is why they all begin with 'abs'. Also, the first two sections of functions were required to have the same name and purpose, although implementation was up to us. We were allowed only one variable (besides parameters), and that is the game board (absGame). We were only allowed to import one library, a random number generator.

We were also required to have a unique intro message so that we could distinguish our program from other students' programs. The goal was to have the best AI, and win the class Connect Four Tournament. My program won.

Note: this program uses animation, and the pause between the frames is determined by the call to absKillTime, in the function absShowGame2. To adjust the speed of the animation, change the number in the call. The call is at line 742

When running the program, play proceeds as follows:

>(what you type)
--> output

The following is how a human plays against the program

>(absStartGame)
--> > Is the force strong with this one?
--> #t
>(absShowGame)
--> lots of spaces, then a game board
>(absMarkMove 4) ;4 can be any number 1-7, as the chosen
                  column for your move
--> 4  ;absMarkMove and absMakeMove will return the 
       ;column number that was played so that two
       ;programs could be played against each other
>(absShowGame)
--> lots of spaces, then an animated game board
>(absMakeMove)
--> whatever column the AI chose
>(absShowGame)
--> lots of spaces, then an animated game board
the following three commands will loop as follows until
the conclusion of the game.
>(absMarkMove <column>)
>(absShowGame)
>(absMakeMove)
>(absShowGame)

there are some win checking functions, as follows: - (absWinP ) will test the current game board to see if the last move resulted in a win - (absWillWinP ) will test the current game board to see if the given move will result in a win

During the tournament, play was as follows, with the class checking for wins by eye. Whoever had the better looking game board had their display function used.

>(aaaStartGame)
>(bbbStartGame)
>(aaaShowGame)
>(bbbShowGame)
<voting for the better looking board; I'll say that aaa had the
    better board>
>(bbbMarkMove (aaaMakeMove)) ;aaa makes a move, and bbb needs to record
                             ;the fact that the other player moved
>(aaaShowGame)               ;show the result of the last move
>(aaaMarkMove (bbbMakeMove)) ;inverse of the last play
>(aaaShowGame)               ;show the result of the last move

the last four functions loop until one of the AI's wins

connect4's People

Contributors

asinck avatar

Stargazers

Bertrand Hornsby-Odoi JR 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.