<s> import libtcodpy as libtcod <EOL> import os <EOL> try : <EOL> from numpy import * <EOL> except ImportError : <EOL> raise ImportError ( '<STR_LIT>' ) <EOL> SCREEN_W = <NUM_LIT> <EOL> SCREEN_H = <NUM_LIT:50> <EOL> HALF_W = SCREEN_W / <NUM_LIT:2> <EOL> HALF_H = SCREEN_H / <NUM_LIT:2> <EOL> libtcod . console_set_custom_font ( os . path . join ( '<STR_LIT>' ) , <EOL> libtcod . FONT_TYPE_GREYSCALE | libtcod . FONT_LAYOUT_TCOD ) <EOL> libtcod . console_init_root ( SCREEN_W , SCREEN_H , '<STR_LIT>' , False ) <EOL> ( x , y ) = meshgrid ( range ( SCREEN_W ) , range ( SCREEN_H ) ) <EOL> lights = [ ] <EOL> lights . append ( { '<STR_LIT:x>' : <NUM_LIT> , '<STR_LIT:y>' : <NUM_LIT:20> , '<STR_LIT>' : <NUM_LIT> } ) <EOL> lights . append ( { '<STR_LIT:x>' : <NUM_LIT:20> , '<STR_LIT:y>' : <NUM_LIT:20> , '<STR_LIT>' : <NUM_LIT> } ) <EOL> while not libtcod . console_is_window_closed ( ) : <EOL> key = libtcod . console_check_for_keypress ( ) <EOL> if key . vk == libtcod . KEY_ESCAPE : break <EOL> _R = zeros ( ( SCREEN_H , SCREEN_W ) ) <EOL> _R = add ( _R , <NUM_LIT:255> ) <EOL> _G = zeros ( ( SCREEN_H , SCREEN_W ) ) <EOL> _G = add ( _G , <NUM_LIT:255> ) <EOL> _B = zeros ( ( SCREEN_H , SCREEN_W ) ) <EOL> _B = add ( _B , <NUM_LIT:255> ) <EOL> _RB = zeros ( ( SCREEN_H , SCREEN_W ) ) <EOL> _GB = zeros ( ( SCREEN_H , SCREEN_W ) ) <EOL> _BB = zeros ( ( SCREEN_H , SCREEN_W ) ) <EOL> _RB = add ( _RB , <NUM_LIT:255> ) <EOL> _GB = add ( _GB , <NUM_LIT:255> ) <EOL> _BB = add ( _BB , <NUM_LIT:255> ) <EOL> render = zeros ( ( SCREEN_H , SCREEN_W ) ) <EOL> for light in lights : <EOL> if lights . index ( light ) == <NUM_LIT:0> : <EOL> light [ '<STR_LIT:x>' ] -= <NUM_LIT> <EOL> sqr_distance = ( x - light [ '<STR_LIT:x>' ] ) ** <NUM_LIT:2> + ( y - light [ '<STR_LIT:y>' ] ) ** <NUM_LIT:2> <EOL> brightness = light [ '<STR_LIT>' ] / sqr_distance <EOL> brightness = clip ( brightness * <NUM_LIT:255> , <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> _RB = subtract ( _RB , brightness ) . clip ( <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> _GB = subtract ( _GB , brightness ) . clip ( <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> _BB = subtract ( _BB , brightness ) . clip ( <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> _R = subtract ( _R , _RB ) . clip ( <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> _G = subtract ( _G , _GB ) . clip ( <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> _B = subtract ( _B , _BB ) . clip ( <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> libtcod . console_fill_background ( <NUM_LIT:0> , _R , _G , _B ) <EOL> libtcod . console_fill_foreground ( <NUM_LIT:0> , _R , _G , _B ) <EOL> print libtcod . sys_get_fps ( ) <EOL> libtcod . console_flush ( ) </s>
