#!/usr/bin/python3

from script_utils import *

'''
(1) n, m <= 50
(2) only right
(3) up or down
(4) right or down
(5) n, m <= 500
'''

groupsHandler = GroupsHandler()


@groupsHandler.registerGroup(group=1, score=17, depends=[0])
def _():
    addScript(gmode='random', pmode='stupid_random', n=30, m=20, len=4, occ=200, flags=['ignore'])
    addScript(gmode='random', pmode='stupid_random', n=43, m=27, len=10, occ=100)
    addScript(gmode='random', pmode='random', n=49, m=50, right=2, offset=4, occ=200)
    addScript(gmode='random', pmode='random', n=49, m=50, right=4, offset=4, occ=100)
    addScript(gmode='random', pmode='random', n=49, m=50, right=5, offset=5, occ=30)
    addScript(gmode='random', pmode='random', n=50, m=49, right=4, offset=7, occ=50)
    addScript(gmode='random', pmode='random', n=50, m=50, right=25, offset=12, occ=0)
    addScript(gmode='random', pmode='random', n=50, m=50, right=25, offset=12, occ=4)
    addScript(gmode='random', pmode='random', n=50, m=50, right=49, offset=24, occ=0, flags=['ignore'])
    addScript(gmode='random', pmode='random', n=50, m=50, right=5, offset=2, occ=10)
    addScript(gmode='random', pmode='random', n=50, m=50, right=3, offset=3, occ=1000)
    addScript(gmode='random', pmode='random', n=50, m=50, right=0, offset=1, occ=50*50)
    addScript(gmode='excluded', pmode='random', n=50, m=50, right=7, offset=3, exclude=30)
    addScript(gmode='excluded', pmode='random', n=50, m=50, right=10, offset=6, exclude=60, flags=['ignore'])
    addScript(gmode='excluded', pmode='max_length', n=50, m=50, right=20, down=6, exclude=100)
    addScript(gmode='random', pmode='max_length', n=50, m=50, right=49, down=49, occ=0)
    addScript(gmode='random', pmode='max_length', n=50, m=50, right=24, down=24, occ=0)
    addScript(gmode='parity', pmode='parity', n=50, m=50, len=20, maxshift=5, extra=0)
    addScript(gmode='parity', pmode='parity', n=50, m=50, len=8, maxshift=10, extra=3)
    addScript(gmode='random', pmode='only_right', n=50, m=50, len=8, occ=30)
    addScript(gmode='random', pmode='up_or_down', n=50, m=50, len=24, flen=2*50*50, occ=2)


@groupsHandler.registerGroup(group=2, score=14)
def _():
    addScript(gmode='random', pmode='only_right', n=200, m=470, len=40, occ=200*470//100)
    addScript(gmode='random', pmode='only_right', n=470, m=210, len=5, occ=200*470//3)
    addScript(gmode='random', pmode='only_right', n=500, m=500, len=499, occ=500*500)
    addScript(gmode='random', pmode='only_right', n=500, m=500, len=499, occ=3)
    addScript(gmode='random', pmode='only_right', n=500, m=500, len=250, occ=10)
    addScript(gmode='random', pmode='only_right', n=500, m=500, len=250, occ=1)
    addScript(gmode='random', pmode='only_right', n=500, m=500, len=1, occ=13)
    addScript(gmode='random', pmode='only_right', n=500, m=500, len=2*500*500, occ=100)


@groupsHandler.registerGroup(group=3, score=19)
def _():
    addScript(gmode='random', pmode='only_up', n=500, m=500, len=31, occ=500*500//400)
    addScript(gmode='random', pmode='up_or_down', n=200, m=470, len=40, occ=200*470//40)
    addScript(gmode='random', pmode='up_or_down', n=470, m=210, len=40, occ=200*470//30)
    mx = 2*500*500
    addScript(gmode='random', pmode='up_or_down', n=500, m=500, len=499, flen=mx, occ=500*500)
    addScript(gmode='random', pmode='up_or_down', n=500, m=500, len=250, flen=mx, occ=0)
    addScript(gmode='random', pmode='up_or_down', n=500, m=500, len=1, flen=mx, occ=0)
    addScript(gmode='random', pmode='up_or_down', n=500, m=500, len=249, flen=mx, occ=5)


@groupsHandler.registerGroup(group=4, score=23, depends=[2])
def _():
    addScript(gmode='random', pmode='right_or_down', n=228, m=499, occ=10, right=100, down=100)
    addScript(gmode='random', pmode='right_or_down', n=497, m=323, occ=100, right=50, down=100)
    addScript(gmode='random', pmode='right_or_down', n=500, m=500, occ=0, right=250, down=250)
    addScript(gmode='random', pmode='right_or_down', n=500, m=500, occ=10, right=250, down=250)
    addScript(gmode='random', pmode='right_or_down', n=500, m=500, occ=10, right=200, down=129)
    addScript(gmode='random', pmode='right_or_down', n=500, m=500, occ=2, right=499, down=0)
    addScript(gmode='excluded', pmode='right_or_down', n=500, m=500, exclude=340, right=130, down=111)
    mx = 2*500*500
    addScript(gmode='random', pmode='right_or_down', n=500, m=500, occ=10, right=mx // 2, down=(mx + 1) // 2)
    addScript(gmode='random', pmode='only_right', n=500, m=500, len=20, occ=200*470//190)


@groupsHandler.registerGroup(group=5, score=27, depends=range(0, 5))
def _():
    addScript(gmode='random', pmode='stupid_random', n=300, m=200, len=40, occ=20000)
    addScript(gmode='random', pmode='stupid_random', n=430, m=270, len=100, occ=10000)
    addScript(gmode='random', pmode='random', n=490, m=500, right=20, offset=40, occ=5000)
    addScript(gmode='random', pmode='random', n=490, m=500, right=40, offset=40, occ=1000, flags=['ignore'])
    addScript(gmode='random', pmode='random', n=490, m=500, right=50, offset=50, occ=300)
    addScript(gmode='random', pmode='random', n=500, m=490, right=40, offset=70, occ=500, flags=['ignore'])
    addScript(gmode='random', pmode='random', n=500, m=500, right=250, offset=120, occ=0)
    addScript(gmode='random', pmode='random', n=500, m=500, right=250, offset=120, occ=40)
    addScript(gmode='random', pmode='random', n=500, m=500, right=490, offset=240, occ=0)
    addScript(gmode='random', pmode='random', n=500, m=500, right=490, offset=1, occ=0)
    addScript(gmode='random', pmode='random', n=500, m=500, right=50, offset=20, occ=100)
    addScript(gmode='random', pmode='random', n=500, m=500, right=30, offset=30, occ=10000, flags=['ignore'])
    addScript(gmode='random', pmode='random', n=500, m=500, right=0, offset=10, occ=500*500)
    addScript(gmode='excluded', pmode='random', n=500, m=500, right=70, offset=30, exclude=300)
    addScript(gmode='excluded', pmode='random', n=500, m=500, right=100, offset=60, exclude=600)
    addScript(gmode='excluded', pmode='max_length', n=500, m=500, right=200, down=60, exclude=1000)
    addScript(gmode='random', pmode='max_length', n=500, m=500, right=499, down=499, occ=0)
    addScript(gmode='random', pmode='max_length', n=500, m=500, right=249, down=249, occ=0)
    addScript(gmode='parity', pmode='parity', n=500, m=500, len=200, maxshift=50, extra=0)
    addScript(gmode='parity', pmode='parity', n=500, m=500, len=80, maxshift=100, extra=90)
    addScript(gmode='random', pmode='only_right', n=500, m=500, len=80, occ=300)
    addScript(gmode='random', pmode='up_or_down', n=500, m=500, len=249, flen=2*500*500, occ=20)
    addScript(gmode='random', pmode='right_or_down', n=500, m=500, occ=8, right=250, down=250)

if __name__ == '__main__':
    groupsHandler.execute()
