2 from curses import initscr, curs_set, newwin, endwin,\
3 KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP
4 from random import randrange
8 environ["TERM"] = 'Eterm'
12 win = newwin(16, 60, 0, 0)
15 win.border('|', '|', '-', '-', '+', '+', '+', '+')
17 win.addstr(0, 5, ' Eat all the OPNFV bugs by FunTest! ')
18 win.addstr(15, 7, ' Left,Right,Up,Down: move; other keys: quit ')
19 snake = [[20, 7], [19, 7], [18, 7], [17, 7],
20 [16, 7], [15, 7], [14, 7], [13, 7]]
25 win.addstr(0, 44, ' Score: '+str(len(snake)-len(body))+' ')
26 win.timeout(140 - 2 * len(snake))
28 key = key if getkey == -1 else getkey
30 0, [snake[0][0]+(key == KEY_RIGHT and 1 or
31 key == KEY_LEFT and -1),
32 snake[0][1]+(key == KEY_DOWN and 1 or
33 key == KEY_UP and -1)])
34 win.addch(snake[len(snake)-1][1], snake[len(snake)-1][0], ' ')
35 if win.inch(snake[0][1], snake[0][0]) & 255 == 32:
37 elif win.inch(snake[0][1], snake[0][0]) & 255 == ord('@'):
38 c = [n for n in [[randrange(1, 58, 1), randrange(1, 14, 1)]
39 for x in range(len(snake))] if n not in snake]
40 win.addch(c == [] and 4 or c[0][1],
41 c == [] and 44 or c[0][0], '@')
45 win.addch(snake[0][1], snake[0][0], body[ind % len(body)])
49 print '\nSnake.PY-26lines by Kris Cieslak (defaultset.blogspot.com).'
50 print 'OPNFV adaptation by Functest dream team.'
51 print 'Thanks for playing, your score: '+str(len(snake)-len(body)-1)+'.'
52 print 'Find and fix more bugs in your real OPNFV setup!\n'