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

What can digital circuits do?, Circuits can be designed to implement a spec...

Circuits can be designed to implement a specifictaske.g. a simple circuit could compare two inputvoltages and give a high output if they matched anda low output if they did not mat

Multiple instruction and single data stream (misd), Multiple Instruction an...

Multiple Instruction and Single Data stream (MISD) In this association, multiple processing elements are structured under the control of multiple control units. Each control un

Advantages & disadvantages of wired-and connection TTL gates, What are adva...

What are advantages and disadvantages of TTL gates design with Wired-AND connection ? Ans. Advantages and disadvantages In this IC added logic is performed with

Keys, why impotant keys

why impotant keys

EDC, Conparision of masfet and jfet

Conparision of masfet and jfet

Define the types programmable logic devices?, Define the types Programmable...

Define the types Programmable logic devices? There are mostly three types PLDs. These are vary in the placement of fuses in the AND- OR array. 1. ROM- It has fixed AND array

Illustration of an instruction cycle, Q. Illustration of an instruction cyc...

Q. Illustration of an instruction cycle? Instruction cycle displayed in given figure comprises subsequent stages: First address of the subsequent instruction is calculat

Plot2fnhand, Write a function "plot2fnhand" that will receive 2 function ha...

Write a function "plot2fnhand" that will receive 2 function handles as input arguments, and will show in two Figure Windows plots of these functions, with the function names in the

Digital forensic investigation, (a) Name five important activities invol...

(a) Name five important activities involved in a digital forensic investigation. (b) Briefly describe the three types of data that a forensic examiner has to work with. Whic

Explain working of digital versatile disk, Q. Explain working of Digital Ve...

Q. Explain working of Digital Versatile Disk? With the capacious digital versatile disk (DVD) electronics industry has ultimately found an acceptable replacement for videotape

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