Implement an agent that plays the max-connect game

Assignment Help Programming Languages
Reference no: EM131408876

Programming Assignment - Game Playing Algorithms

Task

The task in this programming assignment is to implement an agent that plays the Max-Connect4 game using search. Figure 1 shows the first few moves of a game. The game is played on a 6x7 grid, with six rows and seven columns. There are two players, player A (red) and player B (green). The two players take turns placing pieces on the board: the red player can only place red pieces, and the green player can only place green pieces.

It is best to think of the board as standing upright. We will assign a number to every row and column, as follows: columns are numbered from left to right, with numbers 1, 2, ..., 7. Rows are numbered from bottom to top, with numbers 1, 2, ..., 6. When a player makes a move, the move is completely determined by specifying the COLUMN where the piece will be placed. If all six positions in that column are occupied, then the move is invalid, and the program should reject it and force the player to make a valid move. In a valid move, once the column is specified, the piece is placed on that column and "falls down", until it reaches the lowest unoccupied position in that column.

The game is over when all positions are occupied. Obviously, every complete game consists of 42 moves, and each player makes 21 moves. The score, at the end of the game is determined as follows: consider each quadruple of four consecutive positions on board, either in the horizontal, vertical, or each of the two diagonal directions (from bottom left to top right and from bottom right to top left). The red player gets a point for each such quadruple where all four positions are occupied by red pieces. Similarly, the green player gets a point for each such quadruple where all four positions are occupied by green pieces. The player with the most points wins the game.

Your program will run in two modes: an interactive mode, that is best suited for the program playing against a human player, and a one-move mode, where the program reads the current state of the game from an input file, makes a single move, and writes the resulting state to an output file. The one-move mode can be used to make programs play against each other. Note that THE PROGRAM MAY BE EITHER THE RED OR THE GREEN PLAYER, THAT WILL BE SPECIFIED BY THE STATE, AS SAVED IN THE INPUT FILE.

As part of this assignment, you will also need to measure and report the time that your program takes, as a function of the number of moves it explores. All time measurements should report CPU time, not total time elapsed. CPU time does not depend on other users of the system, and thus is a meaningful measurement of the efficiency of the implementation.

1758_Figure.png

Interactive Mode

In the interactive mode, the game should run from the command line with the following arguments (assuming a Java implementation, with obvious changes for C++ or other implementations):

java maxconnect4 interactive [input_file] [computer-next/human-next] [depth]

After reading the input file, the program gets into the following loop:

1. If computer-next, goto 2, else goto 5.

2. Print the current board state and score. If the board is full, exit.

3. Choose and make the next move.

4. Save the current board state in a file called computer.txt (in same format as input file).

5. Print the current board state and score. If the board is full, exit.

6. Ask the human user to make a move (make sure that the move is valid, otherwise repeat request to the user).

7. Save the current board state in a file called human.txt (in same format as input file).

8. Goto 2.

One-Move Mode -

The purpose of the one-move mode is to make it easy for programs to compete against each other, and communicate their moves to each other using text files. The one-move mode is invoked as follows:

java maxconnect4 one-move [input_file] [output_file] [depth]

Attachment:- Assignment.rar

Reference no: EM131408876

Questions Cloud

How do you plan on ensuring stakeholder satisfaction : Imagine your company is being used to subcontract the management of a project. However, you find that you must first convince the contracting company that your company is worthy of the position. Design a plan that centers on TQM and the contractin..
Calculate the capacitance and the power dissipated : Calculate the capacitance and the power dissipated in the dielectric when a sinusoidal voltage of amplitude 50 V and frequency 1 MHz is applied to the capacitor
Calculate the size of an ion : In a metal oxide the oxygen ions are in a hexagonally close-packed array.
Experimental controls and replication help : How do multiple lines of evidence, experimental controls and replication help strengthen scientific inference (really just be able to recognize an example)?
Implement an agent that plays the max-connect game : The task in this programming assignment is to implement an agent that plays the Max-Connect4 game using search. Figure 1 shows the first few moves of a game. The game is played on a 6x7 grid, with six rows and seven columns
What are the primary activities that make up hiring process : What are the three primary activities that make up the hiring process?How do federal employment regulations constrain the hiring process? What are examples?
How rise of juvenile justice contributed to welfare of child : How has the rise of juvenile justice contributed to the welfare of children? Make sure to substantiate your reasons with cited facts.
Scriptural statement about life sanctity and god : This could be tremendously valuable discussion, especially for the younger members of the course. this is an opportunity for ministry. To prepare for this discussion, do research using 4 reference sources:
Is justice the first virtue of the criminal justice system : Is justice the first virtue of the criminal justice system? Why or why not? Have your ideas about the concept of justice changed since the beginning of this course? Why? Make sure to substantiate your reasons with cited facts.

Reviews

len1408876

3/1/2017 1:51:57 AM

The submission should also contain a file called readme.txt, which should specify precisely: Name and UTA ID of the student. What programming language is used. How the code is structured. How to run the code, including very specific compilation instructions, if compilation is needed. Instructions such as "compile using g++" are NOT considered specific. Do you want to participate in the tournament. Code that does not run on omega machines gets AT MOST 75 points.

len1408876

3/1/2017 1:51:49 AM

Implementations in C, C++, Java, and Python will be accepted. If you would like to use another language, make sure it will compile on omega and clear it with the instructor beforehand. Points will be taken off for failure to comply with this requirement. The assignment should be submitted via Blackboard. The directory should contain source code. Including binaries that work on omega (for Java and C++) is optional.

Write a Review

Programming Languages Questions & Answers

  Create class using static variable to store annual interest

Create class SavingAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance indicating the amount.

  Write a code to find the mean-median and mode

Use computer program to write a code (choose any language)to find the mean, median, mode ,variance and standard deviation.

  Use the watchdog in its default position

Use the watchdog in its default position (must be petted in less than 32 ms). Generate a 275 Hz, 50% duty cycle on P9.7. Use a timer with the SMCLK.

  Implement bfs and dfs in c language

Implement BFS and DFS in c language .Explain it also with comments

  This program is a simple shopping list

This program is a simple shopping list that could also be used for TODOs or similar purposes. The program maintains a list of items in a file, and each item has:

  Trace the program

We are going to trace the following program, i.e. simulate in your head how it would execute on a computer. To help you, a trace table is provided for you to fill. Unlike exam E1, our focus here is not only on keeping track of the values of each v..

  Design a program allow the user to select air

Design a program that displays a menu allowing the user to select air, water, or steel. After the user has made a selection, he or she should be asked to enter the number of seconds the sound will travel in the selected medium

  Find largest number in array

Find the largest number in the array and output the result. use a subprogram to input the numbers, a function to use the largest number.

  Write a program that will operate the alarm simulation

Write a program that will operate the Alarm Simulation, using the following inputs and outputs and whatever Timers and Flags are required.

  Create a local variable that inherits the structure

Create a local variable that inherits the structure of the i_car table (using %ROWTYPE attribute). Place each row returned into this variable.

  Write a program to output accumulated values for each month

Write a program to output accumulated values for each month, given a set amount saved each month, until the accumulated amount reaches a set goal amount.

  Write a function interpolate_1d(data,targ)

Write a function interpolate_1D(data,targ) where data is a list of tuples representing x and y data and targ is the target value of y. The function should return the interpolated value of x.

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