예제 #1
2
파일: play.py 프로젝트: vandrei/IA-Tema1
    line = ""
    for j in range(len(board[i*2+1]) - 1):
      line = line + cv[board[i*2+1][j]]
      if board[i*2][j] + board[i*2+1][j] + board[i*2+1][j+1] + board[i*2+2][j] == 4:
        line = line + 'X'
      else:
        line = line + ' '
    line = line + cv[board[i*2+1][-1]]
    print line
    print "*" + "*".join(map(lambda x: ch[x], board[i*2+2])) + "*"
  print "Score: %d - %d" % score

class HumanPlayer:
  def __init__(self):
    self.name = "Human Player"

  def move(self, board, score):
    display_board(board, score)
    r = int(raw_input("Row: "))
    c = int(raw_input("Col: "))
    while board[r][c]:
      display_board(board, score)
      r = int(raw_input("Row: "))
      c = int(raw_input("Col: "))
    return (r, c)

if __name__ == "__main__":
  from game_server import play_game
  from players.BetterPlayer import BetterPlayer
  result = play_game(HumanPlayer(), BetterPlayer(), 5, 5, False)
  print "Final score: %d - %d (%s)" % result
예제 #2
0
    line = ""
    for j in range(len(board[i*2+1]) - 1):
      line = line + cv[board[i*2+1][j]]
      if board[i*2][j] + board[i*2+1][j] + board[i*2+1][j+1] + board[i*2+2][j] == 4:
        line = line + 'X'
      else:
        line = line + ' '
    line = line + cv[board[i*2+1][-1]]
    print line
    print "*" + "*".join(map(lambda x: ch[x], board[i*2+2])) + "*"
  print "Score: %d - %d" % score

class HumanPlayer:
  def __init__(self):
    self.name = "Human Player"

  def move(self, board, score):
    display_board(board, score)
    r = int(raw_input("Row: "))
    c = int(raw_input("Col: "))
    while board[r][c]:
      display_board(board, score)
      r = int(raw_input("Row: "))
      c = int(raw_input("Col: "))
    return (r, c)

if __name__ == "__main__":
  from game_server import play_game
  from players.HuleaAlexandru19930205 import HuleaAlexandru19930205
  result = play_game(HumanPlayer(), HuleaAlexandru19930205(), 5, 5, False)
  print "Final score: %d - %d (%s)" % result
예제 #3
0
            if board[i * 2][j] + board[i * 2 + 1][j] + board[i * 2 + 1][
                    j + 1] + board[i * 2 + 2][j] == 4:
                line = line + 'X'
            else:
                line = line + ' '
        line = line + cv[board[i * 2 + 1][-1]]
        print line
        print "*" + "*".join(map(lambda x: ch[x], board[i * 2 + 2])) + "*"
    print "Score: %d - %d" % score


class HumanPlayer:
    def __init__(self):
        self.name = "Human Player"

    def move(self, board, score):
        display_board(board, score)
        r = int(raw_input("Row: "))
        c = int(raw_input("Col: "))
        while board[r][c]:
            display_board(board, score)
            r = int(raw_input("Row: "))
            c = int(raw_input("Col: "))
        return (r, c)


if __name__ == "__main__":
    from game_server import play_game
    from players.BetterPlayer import BetterPlayer
    result = play_game(HumanPlayer(), BetterPlayer(), 5, 5, False)
    print "Final score: %d - %d (%s)" % result