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

Representation scheme in artificial intelligence, Representation scheme in ...

Representation scheme in artificial intelligence: It is not hard to see why logic has been popular representation scheme in AI: In this way, It is easy to represent knowl

Find the complement of following functions, Q. Find the complement of follo...

Q. Find the complement of following functions and reduce to minimum literals 1. (A+C+D) (A+C+D') (A+C'+D)(A+D') 2. ABC(ABC' + AB'C + A'BC) 3. AB + AB' + A'C +A'C'

Intel architecture, INTEL ARCHITECTURE - 64 ( IA-64) IA-64 (Intel Archit...

INTEL ARCHITECTURE - 64 ( IA-64) IA-64 (Intel Architecture-64) is a 64-bit processor architecture developed in cooperation by Intel and Hewlett-Packard, executed by processors s

Why does ethernet specify a minimum frame size, Why does Ethernet specify a...

Why does Ethernet specify a minimum frame size. Ethernet frame gives a minimum frame size of 46 bytes. Whereas a data field of zero byte is legal, this causes a problem. While

What are the advantages of carrying out simulations, What are the Advantage...

What are the Advantages of carrying out simulations -  saves cost (instead of doing the real thing) -  Safer (scenarios tried out on the simulation first before used in real

Name the variable types of c, C provides a wide range of variable types. ...

C provides a wide range of variable types. Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

Role of bitmap indexes to solve aggregation problems, Describe about the ro...

Describe about the role of bitmap indexes to solve aggregation problems? Ans) Bitmaps are very useful in begin schema to join large databases to small databases. Answer queries

An algorithm, find cos(x) and sin(x) an pseudocode (while loop

find cos(x) and sin(x) an pseudocode (while loop

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