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


[3]> (load connect-4)

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

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


[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
Texture Texture is how artists show what an object would feel like to touch. This can have a dramatic effect on how an image is perceived. Imagine for instance an image that h

Explain Space Switching. Space Switches: Connections can be made in between outgoing and incoming PCM highways by a cross point matrix of the form demonstrated in figure. How

Give difference between top down parsing and bottom up parsing. Top down parsing: Specified an input string, top down parsing tries to derive a string identical to this by s

Is it possible to pass data to and from include programs explicitly? No.  If it is needed to pass data to and from modules it is needed to use subroutines or function modules.

how to implement the multiple stack

What is language of a model?   Language of a model is the collection of formulae that use only the relational symbols the model assign and that use every relation symbol with t

Q. Explain Logical shifts with example? Logical shifts LOGICAL SHIFT LEFT and LOGICAL SHIFT RIGHT insert zeros to end bit position and other bits of a word are shifted left or

Performance and Issues in Pipelining Throughput:  Throughput of a pipeline can be defined as the number of results that have been getting per unit time. It can be denoted as:

Motherboard is called as motherboard because in the world all borned creature is directly attached to her mother & after it all the relations makes due to her mother so in the simi

What is the difference between a constant and variable? Explain with example.  A C constant is usually just the written version of a number. For example 1, 0, 5.73, 12.5e9. We