Application of connect-4 game, Computer Engineering

Assignment Help:

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.


Related Discussions:- Application of connect-4 game

Explain the meaning of accept socket primitive, Explain the meaning of A...

Explain the meaning of ACCEPT socket primitive. The Accept Primitive: A server which uses connection-oriented transport should call procedure accepts to accept

When should the method invokelater() be used, This method is used to make s...

This method is used to make sure that Swing components are updated by the event-dispatching thread.

How video effects alters a video, Question : (a) What are the main aspe...

Question : (a) What are the main aspects that should be considered when dealing with green screen? (b) Explain clearly how these video effects alters a video using an illust

What all 1's represents in 32bit ip addressing scheme, In 32bit IP Addressi...

In 32bit IP Addressing scheme all 1's represent? All 1's represent limited broadcast in 32 bit IP Addressing scheme.

Importance of spectrum to the mobile sector, (a) The statement "Standards ...

(a) The statement "Standards create markets or markets create standards" has been the subject of considerable debate. Discuss the advantages and disadvantages to having multiple

Network for digital methods in the arts and humanities, Network for Digital...

Network for Digital Methods in the Arts and Humanities: Europe has seen a signifi cant investment in the digitisation of its cultural heritage as part of the worldwide establi

Explain about the mini computers, Explain about the MINI COMPUTER Minic...

Explain about the MINI COMPUTER Minicomputers are much smaller in size than mainframe computers and they are also less expensive.  The cost of these computers can differ from a

How to define a filename in dos, Q. How to define a Filename in DOS? Ea...

Q. How to define a Filename in DOS? Each file is given a name so that it can be referred to later. This name is termed as Filename. The filename in DOS can be up to eight alpha

What is a sparse matrix, What is a sparse matrix? Sparse Matrix A m...

What is a sparse matrix? Sparse Matrix A matrix in which number of zero entries is much higher than the number of non-zero entries is known as sparse matrix. The natural me

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd