View the step-by-step solution to:

## miniChessDriver.py ## version 0.1 ## September 5, 2018 ## Here's the crude, unpolished first version of a user ## interface for your miniChess...

Hi, I have problem on this ECS 010 problem.... This project drive me crazy XD Here is the assignment and requirements. I need to use python 3 to one and please make it as simple as possible. Please don't use higher level stuff that we didn't learn...屏幕快照 2018-09-07 下午6.34.34.png屏幕快照 2018-09-07 下午6.34.56.png屏幕快照 2018-09-07 下午6.35.20.png屏幕快照 2018-09-07 下午6.35.29.png

屏幕快照 2018-09-07 下午6.34.34.png

## miniChessDriver.py
## version 0.1
## September 5, 2018 ## Here's the crude, unpolished first version of a user
## interface for your miniChess function ## It doesn't really know much about who wins the game
## or when...although it does know that if it can't make
## a move, the human player wins. ## It does not validate the coordinates for the move
## that is entered by the user. You can move any pawn
## on either side to any square. So be careful. ## We have supplied "dummy" move_maker and
## move_chooser functions so that this ## program will run without causing an ## error. But the program will not play
## the game correctly until you replace ## our two functions with your functions. ## Put your definitions for move_maker and ## move_chooser up here in this space. ## ## Replace the two function definitions below
## with your functions. ## ## DO NOT LEAVE OUR FUNCTIONS HERE def move_makeeroard,color):
return [board] def move_chooserClist_of_boards, color):
return list_of_boards[0]

屏幕快照 2018-09-07 下午6.34.56.png

## print a board
## 0 prints as '—', 1 prints as 'w', 2 prints as 'b' def printBoardCboard): printC" ", end = "")
For i in range(@, leanoard[0])):
print(strCi)+" ", end = "")
print("\n")
row = 0
for r in board:
print(row, " ", end = "")
For c in r:
if c == .
print("w ", end = "")
eliF c == 2:
print("b ", end = "")
else:
print("— ", end = "")
printC)
row = row + 1
print() ## create an initial board, with dimension
## passed as the argument. is at the top,
## 25 at the bottom, 05 everywhere else def makeInitBoardCdim): board = E]
for i in rangeC0,dim):
row = E] For j in range(0,dim):
row.append(0)
board.append(row) For i in range(0,dim):
board[0][i] = 1
board[dim — 1][i] = 2 return board

屏幕快照 2018-09-07 下午6.35.20.png

## this is the user interface for the miniChess game.
## just run the program and type 'miniChess()' in the
## interaction window def miniChess():
from random import randint print("Welcome to miniChess") ## ask for board size and create initial board dim = int(input("What size board would you like? \nCenter an integer greater
bheight = dim bwidth = dim b = makeInitBoardCdim) print("\nHere's the initial board...\n") printBoardCb) ## ask user to select color of pawns
## if user selects white, then the program's color is 2 (i.e., black)
## if user selects black, then the program's color is 1 (i.e., white) while True:
answer = input("Choose the white pawns or black pawns (enter 'w' or 'b' if answer == "w":
mycolor = 2
break if answer == "b":
mycolor = 1
break if answer == "quit":
print("Ending the game")
return ## if program has white pawns, generate program's first move if mycolor ==
print("Here's my opening move.. \n")
column = randintCO, bwidth — 1)
b[1][column] = b[0][column]
b[0][column] = 0
printBoard(b) ## game loop
while True: ## ask For user's move
## coordinates are not validated at this time print("\nEnter the coordinates of the pawn you wish to move:")
Fromrow = int(input(" row: "))
Fromcol = int(input(" col: "))

屏幕快照 2018-09-07 下午6.35.29.png

print("Enter the coordinates of the destination square: ")
torow = int(input(" row: ")) tocol = int(input(" col: ")) # oops b[torow][tocol] = b[fromrow][fromcol] b[fromrow][fromcol] = 0 print("This is your move...\n") printBoardCb) ## here is where the program uses the functions created by the student possiblemoves = move_maker(b, mycolor) # don't change this function cal if possiblemoves == E]:
print("I can't move\nCongratulations! You win!")
return b = move_chooser(possib1emoves, mycolor) # don't change this function ca print("Here's my response...\n")
printBoardCb)

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question