<jupyter_start><jupyter_text>COMP SCI 1015 IAP - Coding Assigment 2 - Connect-N  IntroductionIn this assignment, you will implement a **Connect-N** game, an extension of the popular **Connect-4** game. **Connect-Four** is a two-player connection board game in which the players first choose a color and then take turns dropping one colored disc from the top into a **seven-column, six-row** vertically suspended grid. The pieces fall straight down, occupying the lowest available space within the column. The objective of the game is to be the first to form a horizontal, vertical, or diagonal line of **four of one's own discs**. If you have never played the game Connect 4, you can find its rule and try the game here[https://www.mathsisfun.com/games/connect4.html](https://www.mathsisfun.com/games/connect4.html) Connect-N Game**Connect-N** game is a variation of **Connect-4** where the grid expands to **N+2 Columns** and **N+3 rows**. The winning condition becomes the first to form horizontal, diagonal line of **N of one's own discs**.  **N** will be a positive integer number larger or equal to 3, i.e. 3, 4, 5, 6... etc.You need to implement the following two functions:- `have_winner`: return 1 if there is a winner, return 2 if the board is full, return 0 otherwise.- `drop_disk(c, player)`: player drop a disk at $c_{th}$ colomn. Return 1 if successfully drop the disk, return 0 if this is a illegal move, e.g. the colomn is full.We have provided some utility functions to you:- `init_board`: start the board- `display`: draw the board- `game`: the main loop that starts the game and allows the players to drop disk in turn<jupyter_code># GLOBAL VARIABLES
N = 5
num_row = N + 3
num_col = N + 2
disk = ['\u2B1C', '\u26AA', '\u26AB']
board = []

def init_board(n):
    '''initialise the board'''
    global N, num_row, num_col
    N = n
    num_row = n + 3
    num_col = n + 2
    for c in range(num_col):
        board.append([0]*num_row)
    
def display():
    '''print the board'''
    to_print = "    "
    for i in range(num_col):
        to_print = to_print + f'[{i}]'
    print(to_print)
    for i in range(num_row):
        to_print = f'[{i:2}]'
        for j in range(num_col):
            to_print = f'{to_print}{disk[board[j][i]]:2}'
        print(to_print)

def game():
    '''play the game'''
    n = input('Please input N:')
    init_board(int(n))
    
    p = 0
    while True:
        c = input(f'Player {p} select colomn:')
        if c == 'q': # quit the game
            print(f'Player {p} resigned')
            break
            
        # drop disk    
        f = drop_disk(int(c), p+1)
        if f == 0: # illegal move
            print(f'Column {c} is an illegal move')
            continue            
        display()
        
        # check winner and switch side
        w = have_winner()
        if w == 1:
            print(f'Player {p} won')
            break
        elif w == 2:
            print('draw')
            break
        else:
            p = (p + 1)%2

def drop_disk(col, player):
    '''drop a disk at colomn col'''
    # INSERT YOUR CODE BELOW
    ...

...

def have_winner():
    '''return True if there is a winner'''
    '''check if there is a winner'''
    # INSERT YOUR CODE BELOW
    ...
# MAIN CODE
game()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11531476997578692, 'fraction_numerical': 0.01301452784503632, 'mean_word_length': 2.580715059588299, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '454621', 'license': 'MIT', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1004, 'n_words': 421, 'path': '22S1_Project2.ipynb', 'repo_name': 'ht-timchen/UA-CS1015', 'size': '3304'}