示例#1
0
def play2win(gamePlan, sign, message):
	#THIS! Fick applicera en while sats som kontrollerar användarens input, annars kunde man skriva över.
	if sign == HUMAN:
		row,col = humanSelectABox(sign) #Fångar inputs som returneras av funktionen HumanSelectAbox()
		while gamePlan[row][col] != "-":
			print("Inget fusk, den platsen er tagen!")
			row,col = humanSelectABox(sign) #Tar in nya värden från användaren.
	else:
		row,col = tictactoe_functions.computerSelectABox(gamePlan,sign,EMPTY) #Låter datan ange värden.
		while gamePlan[row][col] != "-":
			print("Nu fuskar datan igen, den platsen er tagen!")
			row,col = tictactoe_functions.computerSelectABox(gamePlan,sign,EMPTY) #Låter datan välja nya dator
	updateGamePlan(row,col,gamePlan,sign)
	#THIS: Här kollande programet fall spelplannen var full, innan han kolla om någon vunnit.
	if(tictactoe_functions.lookForWinner(gamePlan,row,col,WINROW)):
		print(message)
		return True
	if not anyVacantBoxes(gamePlan):
		print("No winner!")
		return True
	return False
示例#2
0
def play2win(gamePlan, sign, message,WINROW,EMPTY,HUMAN):
  if sign == HUMAN:
    row,col = humanSelectABox(sign)
  else:
    row,col = tictactoe_functions.computerSelectABox(gamePlan,sign,EMPTY)

  updateGamePlan(row,col,gamePlan,sign)
  if not anyVacantBoxes(gamePlan,EMPTY):
    print("No winner!")
    return True
  if(tictactoe_functions.lookForWinner(gamePlan,row,col,WINROW)):
    print(message)
    return True
  return False
示例#3
0
def play2win(gamePlan, sign, message):
    if sign == HUMAN:
        row, col = humanSelectABox(sign)
    else:
        row, col = tictactoe_functions.computerSelectABox(gamePlan, sign, EMPTY)

    updateGamePlan(row, col, gamePlan, sign)

    if tictactoe_functions.lookForWinner(gamePlan, row, col, WINROW):
        print(message)
        return True
    elif not anyVacantBoxes(gamePlan):
        print("No winner!")
        return True
    return False
示例#4
0
def play2win(gamePlan, sign, message,EMPTY,WINROW):
  if sign == HUMAN:
    row,col = humanSelectABox(sign, gamePlan, EMPTY)
  else:
    row,col = tictactoe_functions.computerSelectABox(gamePlan,sign,EMPTY)

  updateGamePlan(row,col,gamePlan,sign)


  if(tictactoe_functions.lookForWinner(gamePlan,row,col,WINROW)):
    print(message)
    return True
    ## Swapped lookForWinner and anyVacantBoxes. Gave no winner if win on last turn
  if not anyVacantBoxes(gamePlan,EMPTY): 
    print("No winner!")
    return True

  return False