Application of connect-4 game, Computer Engineering

The game Connect-4 is played on a board that has seven columns. There are six spaces on each column. The board is initially empty. Two players take turns dropping one piece (black or grey in the diagram below, but "X" or O" in our game) in a column. The piece falls into the lowest unoccupied row. A player cannot move in a column if the top-most row of that column already has a piece in it. The first player to get four of their counters in a line (horizontally, vertically, or diagonally) is the winner. 

You have been provided with two files for this problem: minimax.lisp, which contains lisp code for the minimax algorithm, and  connect-4.lisp, which contains a working Lisp implementation of the Connect-4 game. 

As the Connect-4 implementation currently stands, you should  have absolutely no problem beating the program. Try it:  

[1]> (load 'minimax)

;; Loading file C:\CSE2AIF\minimax.lisp ...

;; Loaded file C:\CSE2AIF\minimax.lisp

T

[3]> (load connect-4)

;; Loading file C:\CSE2AIF\connect-4.lisp ...

;; Loaded file C:\CSE2AIF\connect-4.lisp

T

[3]> (play)  

The program plays poorly because it has a poor-quality heuristic. The function static, which evaluates a position from the point of view of a particular player, is currently defined as follows: (defun static (board player) 0)

This means that each board configuration receives exactly the same evaluation; i.e., 0.  Your task for this question is to develop and implement a good heuristic for the Connect-4 game.  The only LISP code that you are required to write is a LISP function static, which accepts a board and player as input arguments, and returns an evaluation of the board state from the point of view of player. You can, of course, write as many helper functions as you like.  

To assist you, the code you have been supplied with contains a parameter *all-c4-lines* which is a list of all of the 69 possible ways to win in Connect-4. Each element of this list is a list of length four, such as

 ((3 5) (4 5) (5 5) (6 5))

Each element of this is the column and row. For example, the above list indicates that there is a line of length four that includes a piece at the 4th column of the 6th row, the 5th  column of the 6th row, the 6th column of the 6th row, and the 7th column of the 6th row.

 Note that rows and column indexing starts at 0.

The Lisp built-in function  aref can be used to find what piece, if any, is at a specified location. For example, to find what piece, if any, occupies column col and row row of the current board state, evaluate the following code 

   (aref board col row)

This will return either nil, x or o.

Posted Date: 2/20/2013 7:59:18 AM | Location : United States







Related Discussions:- Application of connect-4 game, Assignment Help, Ask Question on Application of connect-4 game, Get Answer, Expert's Help, Application of connect-4 game Discussions

Write discussion on Application of connect-4 game
Your posts are moderated
Related Questions
Q. Explain the odd-even transposition algorithm? The algorithm needs one 'for loop' beginning from I=1 to N it implies that N times and for every value of I, one 'for loop' of

want to know about latest work and research papers on internet data synchronization

Firewalls While getting one firewall for the company's Intranet it should be well known that firewalls come in both hardware and software forms, and that even though all firew

Describe in brief about The internet Web sites need to be set up to maximise information supplied to customers and to ensure they are as self-contained and helpful as possible.

a.  Sketch the excitation diagram indicating the last states and next states. b. Build the circuit using a Synchronous Counter with JK FF and NAND gates only. Replicate the circ

What is a shift register? Can a shift register be used as a counter? If yes, explain how?     Ans: Shift Register: A register wherein data gets shifted towards left or right

How and when race conditions happen in process control? How can it be avoided? b. Differentiate among following functions giving related syntax: (i) fork and vfork (ii) w

ISDN handles data pertaining to? ISDN handles data pertaining to all digital services.

Description Variables show values that can be changed within a procedure or function. Local scope variables are placeholders that reside within a function- or a script-body.

Are there any special rules about inlining? Yes, there are some rules about inlining - a.) Any source files which used inline function should contain function's definition.