[SOLVED] 代写 game prolog 159.202-2019 Semester 2

30 $

File Name: 代写_game_prolog_159.202-2019_Semester_2.zip
File Size: 395.64 KB

SKU: 4686409964 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


159.202-2019 Semester 2
Massey University
Assignment 3
Deadline:
Hand in by 5:00 p.m. on Monday 9th of September
Evaluation:
10 marks – which is 3% of your final grade
Late Submission:
1 mark off per day late
Work:
This assignment must be done individually.
Purpose:
Developing an interactive program in Prolog.
Connect-Four Game
Write a game in Prolog that allows two players to play Connect-Four. This game should take input from two players (in turn) and allow them to place a nought or a cross (depending on the player) on the board. The board should have seven columns and six rows.
Each time a player makes a move the game should check that both the input and the move is valid. After each successful move the game should check whether a player has won (a player has managed to place four connected noughts or crosses in either the same row, column or diagonal) or if the board is full and the game is a draw. If either condition is met it should print out an appropriate message to the players.
Some example code is provided to help you get started. This code represents the board as a list of seven columns. Each of these columns is a list of six variables – a variable represents an empty cell. Currently the code only allows one player (player x) to take turns and only tries to set the bottom row of the board.
You will need to add functionality to this game to complete it. Specifically, you will need to add messages to prompt the player(s) when it is their turn and then validate their input. Validation should include both checking that the column is valid and also not already full. When the player takes a turn, you should determine the first empty place in the column set this position in the board. You must also write the necessary predicates to determine whether a player has won the game (or the board is full and the game is a draw). Finally, you should modify the print predicates to print the board in a nicer format (as seen below).
Possible output is shown below:
?- connect4.
Player x enter move: a.
a is not a valid column (must be a number in the range [1-7]).
Player x enter move: 11.
11 is not a valid column (must be a number in the range [1-7]).
Player x enter move: 1.
|||||||| |||||||| |||||||| |||||||| |||||||| |x| | | | | | | —————
Player o enter move: 2.
|||||||| |||||||| |||||||| |||||||| |||||||| |x|o| | | | | | —————
Player x enter move: 2.
|||||||| |||||||| |||||||| |||||||| | |x| | | | | | |x|o| | | | | | —————
(continued)
1

159.202-2019 Semester 2
Massey University
. . .
Player o enter move: 4.
|||||||| |||||||| |||||||| | | |x|o| | | | | |x|x|o| | | | |x|o|o|o|x| | | —————
Player x enter move: 4.
|||||||| |||||||| | | | |x| | | | | | |x|o| | | | | |x|x|o| | | | |x|o|o|o|x| | | —————
Player x Wins!
true .
You must put the following comments at the top of your program code and provide the appropriate information.
% Assignment number, 159.202, 2019 S2
% Family Name, Given Name, Student ID,
% Explain what the program is doing . . .
Hand-in: Submit your script electronically through stream
If you have any questions about this assignment, please ask the lecturer.
2

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 game prolog 159.202-2019 Semester 2
30 $