diff -urN rt_v54/Makefile rt_v55/Makefile --- rt_v54/Makefile 2018-06-23 11:36:50.000000000 +0900 +++ rt_v55/Makefile 2018-06-26 23:15:29.000000000 +0900 @@ -2,6 +2,7 @@ CFLAGS += -Wall LIBS = -lm -lpthread OBJS = area.o img.o dat.o val.o sock.o lstx.o ax.o cylx.o fcx.o vecs.o line.o v.o mt.o ut.o +YAMLS = tmp.yaml blk_balls.yaml blk_bars.yaml dots.yaml mons.yaml pm.yaml all: cross rt @@ -16,5 +17,5 @@ rm -f *.o *~ *.pyc rm -rf __pycache__ find . -type d -name 'out*' | xargs rm -rf - rm -f blk_balls.yaml blk_bars.yaml dots.yaml mons.yaml + rm -f $(YAMLS) # EOF diff -urN rt_v54/dat.py rt_v55/dat.py --- rt_v54/dat.py 2018-06-21 21:25:38.000000000 +0900 +++ rt_v55/dat.py 2018-06-26 23:15:29.000000000 +0900 @@ -98,10 +98,17 @@ f = lambda k: ( k, setup_eval( o.get(k), sec + tm_sft, start_lst, top_marks ) ) return dict( map( f, o.keys() ) ) if t == str and o: + o_ = '' if any( map( lambda sta: o.startswith(sta), start_lst ) ): - return eval(o) - if o[0] in top_marks: - return eval( o[1:] ) + o_ = o + elif o[0] in top_marks: + o_ = o[1:] + if o_: + try: + return eval(o_) + except: + print(list(o_)) + ut.err_exit( "err eval '{}'".format(o_) ) return o ydic = {} # for export @@ -389,7 +396,7 @@ for d_ in lst: d_['maps'] = d_.get('maps', []) + d.get('maps', []) - for k in [ 'def_col', 'def_col_r', 'rtd' ]: + for k in [ 'def_col', 'def_col_r', 'rtd', 'hide' ]: if k not in d_ and k in d: d_[k] = d.get(k) @@ -430,7 +437,7 @@ for d_ in args: d_['maps'] = d_.get('maps', []) + d.get('maps', []) - for k in [ 'def_col', 'def_col_r', 'rtd' ]: + for k in [ 'def_col', 'def_col_r', 'rtd', 'hide' ]: if k not in d_ and k in d: d_[k] = d.get(k) diff -urN rt_v54/mon.yaml rt_v55/mon.yaml --- rt_v54/mon.yaml 2018-06-23 01:43:03.000000000 +0900 +++ rt_v55/mon.yaml 2018-06-26 23:15:29.000000000 +0900 @@ -12,23 +12,56 @@ m2g: - ax.zoom_all(0.5) -@include mons.yaml - -mon: +mon_r: - kind: export - export: mon_R + export: mon1 def_col: '*red' +mon_c: - kind: export - export: mon_C + export: mon1 def_col: '*cyan' +mon_m: - kind: export - export: mon_M + export: mon1 def_col: '*magenta' +mon_y: - kind: export - export: mon_Y + export: mon1 def_col: '*yellow' +mon_weak: +- kind: export + export: mon1 + def_col: '*blue' + +mon_blink: +- kind: export + export: mon1 + def_col: '*[ int(way.get( [(50,0.5),(200,0.5)], sec )), 50, 50 ]' + +eye: +- kind: ball + rtd: '*rtd_a' + def_col: '*dark' + m2g: + - ax.zoom_all(0.2) + - ax.slide_x(-0.2) + rxs: + - [ m2g, append, 2, [ ax.slide_x(0.4) ] ] + +mon_ret: +- kind: export + export: eye + m2g: + - 'ax.rot_z( way.get( [(0,0.5),(360,None)], sec ) )' + +@include mons.yaml + +mon: +- kind: exports + exports: [ mon_R, mon_C, mon_M, mon_Y ] + # EOF diff -urN rt_v54/pac.yaml rt_v55/pac.yaml --- rt_v54/pac.yaml 2018-06-23 00:42:21.000000000 +0900 +++ rt_v55/pac.yaml 2018-06-26 23:15:29.000000000 +0900 @@ -3,10 +3,17 @@ @include blk.yaml @include dot.yaml @include mon.yaml +@include pman.yaml + +dot_pman: +- kind: xor + args: + - kind: exports + exports: [ dot, pman ] pac: - kind: exports - exports: [ blk, dot, mon ] + exports: [ blk, mon, dot_pman ] m2g: - 'ax.slide([-21.0/2,-23.0/2,0])' - ax.zoom_y(-1) diff -urN rt_v54/pac_dat.py rt_v55/pac_dat.py --- rt_v54/pac_dat.py 2018-06-23 01:33:52.000000000 +0900 +++ rt_v55/pac_dat.py 2018-06-26 23:15:29.000000000 +0900 @@ -104,37 +104,105 @@ d.update( { 'blk_vs': ut.map_up_lst( mk_blk_v, blk_vs ) } ) ut.yaml_save( 'blk_bars.yaml', d ) -def dot_dat(lst_xy, w, h): +def dot_d(lst_xy, w, h): xys = xys_c( lst_xy, w, h, '.' ) d = { 'dots': mk_sld_lst( 'dot1', xys ) } xys = xys_c( lst_xy, w, h, 'O' ) d.update( { 'pdots': mk_sld_lst( 'pdot1', xys ) } ) + return d + +def dot_dat(lst_xy, w, h): + ut.yaml_save( 'dots.yaml', dot_d( lst_xy, w, h ) ) - ut.yaml_save( 'dots.yaml', d ) +def lines_to_d(lines, k, in_name, out_name): + lst = ut.filter_lst( lambda s: s.startswith(k), lines ) + def f(s): + (x, y, t) = s.split(' ')[1:] + return [ int(x), int(y), float(t) ] + lst = ut.map_lst( f, lst ) + for i in range( len(lst)-1 ): + lst[i][2] = lst[i+1][2] - lst[i][2] + lst[-1][2] = None + + xs = ut.map_up_lst( lambda x, y, t: (x, t), lst ) + ys = ut.map_up_lst( lambda x, y, t: (y, t), lst ) + defs = { 'xs': str(xs), 'ys': str(ys) } + m2g = [ '@ax.slide([ way.get( xs , sec ), way.get( ys , sec ), 0 ])' ] + + d = { 'kind': 'export', 'export': in_name, 'defs': defs, 'm2g': m2g } + return { out_name: [ d ] } def mon_dat(mon_log): s = ut.file_read_inc(mon_log) lines = s.strip().split('\n') d = {} for k in 'CMYR': + d.update( lines_to_d( lines, k, 'mon_'+k.lower(), 'mon_'+k ) ) + ut.yaml_save( 'mons.yaml', d ) + +def lines_1st_time(lines): + return float( lines[0].split(' ')[3] ) + +def lines_to_modes(lines, k): + lst = ut.filter_lst( lambda s: s.startswith('mode '+k), lines ) + def f(s): + (md, t) = s.split(' ')[2:] + if md in [ 'run', 'cage' ]: + md = k.lower() + return [ md, float(t) ] + return ut.map_lst( f, lst ) + +def pac_dat(pac_log, lst_xy, w, h): + s = ut.file_read_inc(pac_log) + lines = s.strip().split('\n') + + t1st = lines_1st_time(lines) + for k in 'CMYRP': + (x, y) = xys_c(lst_xy, w, h, k)[0] + lines.insert( 0, '{} {} {} {}'.format(k, x, y, t1st) ) + + d = {} + for k in 'CMYR': + in_name = 'MON_' + k + out_name = 'mon_' + k + + d_ = lines_to_d( lines, k, in_name, out_name ) + d.update(d_) + + mds = lines_to_modes(lines, k) + mds.append( mds[-1] ) + mds = ut.map_lst( lambda i: ( 'mon_' + mds[i][0], mds[i+1][1] - mds[i][1] ), range( len(mds)-1 ) ) + mds.pop(-1) + + lst = [] + for m in ( k.lower(), 'weak', 'blink', 'ret' ): + md = 'mon_' + m + hds = ut.map_up_lst( lambda md_, t: ( md_ != md, t ), mds ) + defs = { 'hds': str(hds) } + dd = { 'kind': 'export', 'export': md, 'hide': '@*way.get( hds , sec , step=True )', 'defs': defs } + lst.append(dd) + d_ = { in_name: lst } + d.update(d_) + + ut.yaml_save( 'mons.yaml', d ) # overwrite + + ut.yaml_save( 'pm.yaml', lines_to_d( lines, 'P', 'pm1', 'pm' ) ) + + d = dot_d(lst_xy, w, h) + def add_hide(k, name): lst = ut.filter_lst( lambda s: s.startswith(k), lines ) - def f(s): + for s in lst: (x, y, t) = s.split(' ')[1:] - return [ int(x), int(y), float(t) ] - lst = ut.map_lst( f, lst ) - for i in range( len(lst)-1 ): - lst[i][2] = lst[i+1][2] - lst[i][2] - lst[-1][2] = None - - xs = ut.map_up_lst( lambda x, y, t: (x, t), lst ) - ys = ut.map_up_lst( lambda x, y, t: (y, t), lst ) - defs = { 'xs': str(xs), 'ys': str(ys) } - m2g = [ '@ax.slide([ way.get( xs , sec ), way.get( ys , sec ), 0 ])' ] - mon_d = { 'kind': 'export', 'export': 'mon1', 'defs': defs, 'm2g': m2g } - d[ 'mon_' + k ] = [ mon_d ] - - ut.yaml_save( 'mons.yaml', d ) + (x, y, t) = ( int(x), int(y), float(t) ) + t -= t1st + sld_s = 'ax.slide([{},{},0])'.format(x, y) + for d_ in d.get(name): + if d_.get('m2g')[0] == sld_s: + d_['hide'] = '*sec > {}'.format(t) + add_hide('.', 'dots') + add_hide('O', 'pdots') + ut.yaml_save( 'dots.yaml', d ) # overwrite if __name__ == "__main__": pac_txt = 'pac/pac.txt' @@ -154,4 +222,8 @@ if ut.exists(mon_log): mon_dat(mon_log) + pac_log = 'pac/pac.log' + if ut.exists(pac_log): + pac_dat(pac_log, lst_xy, w, h) + # EOF diff -urN rt_v54/pac_mon_pos_out.patch rt_v55/pac_mon_pos_out.patch --- rt_v54/pac_mon_pos_out.patch 2018-06-23 00:02:00.000000000 +0900 +++ rt_v55/pac_mon_pos_out.patch 2018-06-26 23:15:29.000000000 +0900 @@ -1,5 +1,5 @@ --- pac-/pac.py 2018-06-22 23:16:20.000000000 +0900 -+++ pac/pac.py 2018-06-22 23:57:37.000000000 +0900 ++++ pac/pac.py 2018-06-26 06:29:58.000000000 +0900 @@ -3,6 +3,7 @@ import sys import os @@ -8,7 +8,32 @@ import kon from kon import dbg, DIRS, U, D, L, R, flush, has, set, get, mk_slst -@@ -384,7 +385,10 @@ +@@ -59,6 +60,7 @@ + if v == 'get' or v == mode: + return mode + ++ print('mode {} {} {}'.format( c, v, time.time() )) + stat.mode = v + + col = { 'M': 'magenta', 'R': 'red', 'C': 'cyan', 'Y': 'white' }.get(c) +@@ -273,6 +275,7 @@ + if c in '.O': + arr.set(x, y, c, False) + stat_get('P').dot -= 1 ++ print( '{} {} {} {}'.format( c, x, y, time.time() ) ) + else: + bonus.eat() + +@@ -320,6 +323,8 @@ + + (nx, ny) = step_to(px, py, d) + if d: ++ if d != pd: ++ print( '{} {} {} {}'.format( c, px, py, time.time() ) ) + hz = get_hz(c, nx, ny, d) + move(c, d, hz) + try_eat(nx, ny) +@@ -384,7 +389,10 @@ (px, py) = arr.pos(c) ds = next_ds(px, py, c) diff -urN rt_v54/pman.yaml rt_v55/pman.yaml --- rt_v54/pman.yaml 1970-01-01 09:00:00.000000000 +0900 +++ rt_v55/pman.yaml 2018-06-26 23:15:29.000000000 +0900 @@ -0,0 +1,16 @@ +@include defs.yaml + +pm1: +- kind: ball + rtd: '*rtd_a' + def_col: '*yellow' + m2g: + - ax.zoom_all(0.5) + +@include pm.yaml + +pman: +- kind: export + export: pm + +# EOF diff -urN rt_v54/ut.py rt_v55/ut.py --- rt_v54/ut.py 2018-06-21 22:04:01.000000000 +0900 +++ rt_v55/ut.py 2018-06-26 23:15:29.000000000 +0900 @@ -16,6 +16,10 @@ sys.stdout.write(s) sys.stdout.flush() +def err_exit(s, ret_v=1): + err_msg(s) + sys.exit(ret_v) + hex = lambda s: ''.join( map( lambda c: '{:02x}'.format( ord(c) ), s ) ) map_lst = lambda f, lst: list( map( f, lst ) ) diff -urN rt_v54/way.py rt_v55/way.py --- rt_v54/way.py 2018-06-15 21:57:23.000000000 +0900 +++ rt_v55/way.py 2018-06-26 23:15:29.000000000 +0900 @@ -32,12 +32,20 @@ (v2, _) = lst[j] return (v2 - v) / t -def get(lst, t, itp3=False): +def get(lst, t, itp3=False, step=False, abs_to_rel=False): # itp3 is using mt.interp3 (vs, ts) = zip(*lst) + + if abs_to_rel: + ts = ut.map_lst( lambda i: ts[i+1]-ts[i], range( len(ts)-1 ) ) + [ None ] + ts_ = ts if ts[-1] != None else ts[:-1] (idx, t) = get_idx_t(ts_, t) + + if step: + return vs[idx] + n = len(lst) if itp3: ka = get_k( lst, (idx-1+n)%n )