Still chasing a math jet bug.

This commit is contained in:
C. Guy Yarvin 2014-09-18 12:07:36 -07:00
parent f5507bfe65
commit 7c00827c56
4 changed files with 116 additions and 71 deletions

75
g/j.c
View File

@ -90,6 +90,16 @@ u3_cj_find(u3_noun bat)
}
}
/* _cj_soft(): kick softly by arm axis.
*/
static u3_noun
_cj_soft(u3_noun cor, c3_l axe_l)
{
u3_noun arm = u3_cx_at(axe_l, cor);
return u3_cn_nock_on(cor, u3k(arm));
}
/* _cj_kick_a(): try to kick by jet. If no kick, produce u3_none.
**
** `cor` is RETAINED iff there is no kick, TRANSFERRED if one.
@ -108,20 +118,54 @@ _cj_kick_a(u3_noun cor, u3_cs_hood* hud_u, c3_l axe_l)
if ( 0 == ham_u->fun_f ) {
return u3_none;
}
// printf("kick_a: %s\n", ham_u->fcs_c);
// return u3_none;
// XX: support tot and ice flags, and validator
//
{
u3_weak pro = ham_u->fun_f(cor);
if ( u3_none != pro ) {
u3z(cor);
return pro;
}
if ( u3_ne(ham_u->liv) ) {
return u3_none;
}
else {
if ( u3_so(ham_u->ice) ) {
u3_weak pro = ham_u->fun_f(cor);
if ( u3_none != pro ) {
u3z(cor);
return pro;
}
}
else {
u3_weak pro, ame;
ham_u->ice = u3_yes;
pro = ham_u->fun_f(u3k(cor));
ham_u->ice = u3_no;
if ( u3_none == pro ) {
u3z(cor);
return pro;
}
ham_u->liv = u3_no;
ame = _cj_soft(cor, axe_l);
ham_u->liv = u3_yes;
if ( u3_no == u3_cr_sing(ame, pro) ) {
printf("test: %s %s: mismatch: good %x, bad %x\r\n",
ham_u->cop_u->cos_c,
(!strcmp(".2", ham_u->fcs_c)) ? "$" : ham_u->fcs_c,
u3_cr_mug(ame),
u3_cr_mug(pro));
c3_assert(0);
return u3_cm_bail(c3__fail);
}
else {
#if 0
printf("test: %s %s\r\n",
ham_u->cop_u->cos_c,
(!strcmp(".2", ham_u->fcs_c)) ? "$" : ham_u->fcs_c);
#endif
}
}
return u3_none;
}
return u3_none;
}
/* _cj_kick_b(): try to kick by jet. If no kick, produce u3_none.
@ -181,9 +225,7 @@ _cj_hook_in(u3_noun cor,
return pro;
}
else {
u3_noun arm = u3_cx_at(huk_u->axe_l, cor);
return u3_cn_nock_on(cor, u3k(arm));
return _cj_soft(cor, huk_u->axe_l);
}
}
huk_u = huk_u->nex_u;
@ -322,6 +364,7 @@ _cj_activate(u3_cs_core* cop_u, u3_cs_hood* hud_u)
while ( 1 ) {
u3_cs_harm* jet_u = &cop_u->arm_u[i_l];
jet_u->cop_u = cop_u;
if ( 0 == jet_u->fcs_c ) {
break;
}
@ -548,7 +591,7 @@ u3_cj_mine(u3_noun clu,
memset(&fak_u, 0, sizeof(u3_cs_core));
fak_u.cos_c = nam_c;
printf("mine: dummy %s\n", fak_u.cos_c);
printf("mine: dummy %s\r\n", fak_u.cos_c);
fak_u.par_u = par_u;
fak_u.axe_l = axe_l;

2
g/m.c
View File

@ -232,7 +232,7 @@ int c3_cooked() { return u3_cm_bail(c3__oops); }
c3_i
u3_cm_error(c3_c* str_c)
{
printf("error: %s\n", str_c); // rong
printf("error: %s\r\n", str_c); // rong
return u3_cm_bail(c3__exit);
}

View File

@ -25,12 +25,14 @@
/* u3_cs_harm: jet arm.
*/
typedef struct _u3_cs_harm {
c3_c* fcs_c; // `.axe` or name
u3_noun (*fun_f)(u3_noun); // 0 or compute function / semitransfer
u3_bean (*val_f)(u3_noun); // 0 or validate function - retain
c3_o ice; // perfect (don't test)
c3_o tot; // total (never punts)
c3_l axe_l; // computed/discovered axis
c3_c* fcs_c; // `.axe` or name
u3_noun (*fun_f)(u3_noun); // compute or 0 / semitransfer
// u3_bean (*val_f)(u3_noun); // validate or 0 / retain
c3_o ice; // perfect (don't test)
c3_o tot; // total (never punts)
c3_o liv; // live (enabled)
c3_l axe_l; // computed/discovered axis
struct _u3_cs_core* cop_u; // containing core
} u3_cs_harm;
/* u3_cs_core: driver definition.

View File

@ -4,56 +4,56 @@
*/
#include "all.h"
static u3_cs_harm _mood__hoon_add_a[] = {{".2", u3_cwa_add}, {}};
static u3_cs_harm _mood__hoon_dec_a[] = {{".2", u3_cwa_dec}, {}};
static u3_cs_harm _mood__hoon_div_a[] = {{".2", u3_cwa_div}, {}};
static u3_cs_harm _mood__hoon_gte_a[] = {{".2", u3_cwa_gte}, {}};
static u3_cs_harm _mood__hoon_gth_a[] = {{".2", u3_cwa_gth}, {}};
static u3_cs_harm _mood__hoon_lte_a[] = {{".2", u3_cwa_lte}, {}};
static u3_cs_harm _mood__hoon_lth_a[] = {{".2", u3_cwa_lth}, {}};
static u3_cs_harm _mood__hoon_mod_a[] = {{".2", u3_cwa_mod}, {}};
static u3_cs_harm _mood__hoon_mul_a[] = {{".2", u3_cwa_mul}, {}};
static u3_cs_harm _mood__hoon_sub_a[] = {{".2", u3_cwa_sub}, {}};
static u3_cs_harm _mood__hoon_add_a[] = {{".2", u3_cwa_add, u3_yes}, {}};
static u3_cs_harm _mood__hoon_dec_a[] = {{".2", u3_cwa_dec, u3_yes}, {}};
static u3_cs_harm _mood__hoon_div_a[] = {{".2", u3_cwa_div, u3_yes}, {}};
static u3_cs_harm _mood__hoon_gte_a[] = {{".2", u3_cwa_gte, u3_yes}, {}};
static u3_cs_harm _mood__hoon_gth_a[] = {{".2", u3_cwa_gth, u3_yes}, {}};
static u3_cs_harm _mood__hoon_lte_a[] = {{".2", u3_cwa_lte, u3_yes}, {}};
static u3_cs_harm _mood__hoon_lth_a[] = {{".2", u3_cwa_lth, u3_yes}, {}};
static u3_cs_harm _mood__hoon_mod_a[] = {{".2", u3_cwa_mod, u3_yes}, {}};
static u3_cs_harm _mood__hoon_mul_a[] = {{".2", u3_cwa_mul, u3_yes}, {}};
static u3_cs_harm _mood__hoon_sub_a[] = {{".2", u3_cwa_sub, u3_yes}, {}};
static u3_cs_harm _mood__hoon_bind_a[] = {{".2", u3_cwb_bind}, {}};
static u3_cs_harm _mood__hoon_clap_a[] = {{".2", u3_cwb_clap}, {}};
static u3_cs_harm _mood__hoon_drop_a[] = {{".2", u3_cwb_drop}, {}};
static u3_cs_harm _mood__hoon_flop_a[] = {{".2", u3_cwb_flop}, {}};
static u3_cs_harm _mood__hoon_lent_a[] = {{".2", u3_cwb_lent}, {}};
static u3_cs_harm _mood__hoon_levy_a[] = {{".2", u3_cwb_levy}, {}};
static u3_cs_harm _mood__hoon_lien_a[] = {{".2", u3_cwb_lien}, {}};
static u3_cs_harm _mood__hoon_need_a[] = {{".2", u3_cwb_need}, {}};
static u3_cs_harm _mood__hoon_reel_a[] = {{".2", u3_cwb_reel}, {}};
static u3_cs_harm _mood__hoon_roll_a[] = {{".2", u3_cwb_roll}, {}};
static u3_cs_harm _mood__hoon_skim_a[] = {{".2", u3_cwb_skim}, {}};
static u3_cs_harm _mood__hoon_skip_a[] = {{".2", u3_cwb_skip}, {}};
static u3_cs_harm _mood__hoon_scag_a[] = {{".2", u3_cwb_scag}, {}};
static u3_cs_harm _mood__hoon_slag_a[] = {{".2", u3_cwb_slag}, {}};
static u3_cs_harm _mood__hoon_snag_a[] = {{".2", u3_cwb_snag}, {}};
static u3_cs_harm _mood__hoon_sort_a[] = {{".2", u3_cwb_sort}, {}};
static u3_cs_harm _mood__hoon_turn_a[] = {{".2", u3_cwb_turn}, {}};
static u3_cs_harm _mood__hoon_weld_a[] = {{".2", u3_cwb_weld}, {}};
static u3_cs_harm _mood__hoon_bind_a[] = {{".2", u3_cwb_bind, u3_yes}, {}};
static u3_cs_harm _mood__hoon_clap_a[] = {{".2", u3_cwb_clap, u3_yes}, {}};
static u3_cs_harm _mood__hoon_drop_a[] = {{".2", u3_cwb_drop, u3_yes}, {}};
static u3_cs_harm _mood__hoon_flop_a[] = {{".2", u3_cwb_flop, u3_yes}, {}};
static u3_cs_harm _mood__hoon_lent_a[] = {{".2", u3_cwb_lent, u3_yes}, {}};
static u3_cs_harm _mood__hoon_levy_a[] = {{".2", u3_cwb_levy, u3_yes}, {}};
static u3_cs_harm _mood__hoon_lien_a[] = {{".2", u3_cwb_lien, u3_yes}, {}};
static u3_cs_harm _mood__hoon_need_a[] = {{".2", u3_cwb_need, u3_yes}, {}};
static u3_cs_harm _mood__hoon_reel_a[] = {{".2", u3_cwb_reel, u3_yes}, {}};
static u3_cs_harm _mood__hoon_roll_a[] = {{".2", u3_cwb_roll, u3_yes}, {}};
static u3_cs_harm _mood__hoon_skim_a[] = {{".2", u3_cwb_skim, u3_yes}, {}};
static u3_cs_harm _mood__hoon_skip_a[] = {{".2", u3_cwb_skip, u3_yes}, {}};
static u3_cs_harm _mood__hoon_scag_a[] = {{".2", u3_cwb_scag, u3_yes}, {}};
static u3_cs_harm _mood__hoon_slag_a[] = {{".2", u3_cwb_slag, u3_yes}, {}};
static u3_cs_harm _mood__hoon_snag_a[] = {{".2", u3_cwb_snag, u3_yes}, {}};
static u3_cs_harm _mood__hoon_sort_a[] = {{".2", u3_cwb_sort, u3_yes}, {}};
static u3_cs_harm _mood__hoon_turn_a[] = {{".2", u3_cwb_turn, u3_yes}, {}};
static u3_cs_harm _mood__hoon_weld_a[] = {{".2", u3_cwb_weld, u3_yes}, {}};
static u3_cs_harm _mood__hoon_bex_a[] = {{".2", u3_cwc_bex}, {}};
static u3_cs_harm _mood__hoon_can_a[] = {{".2", u3_cwc_can}, {}};
static u3_cs_harm _mood__hoon_cap_a[] = {{".2", u3_cwc_cap}, {}};
static u3_cs_harm _mood__hoon_cat_a[] = {{".2", u3_cwc_cat}, {}};
static u3_cs_harm _mood__hoon_con_a[] = {{".2", u3_cwc_con}, {}};
static u3_cs_harm _mood__hoon_cut_a[] = {{".2", u3_cwc_cut}, {}};
static u3_cs_harm _mood__hoon_dis_a[] = {{".2", u3_cwc_dis}, {}};
static u3_cs_harm _mood__hoon_dor_a[] = {{".2", u3_cwc_dor}, {}};
static u3_cs_harm _mood__hoon_end_a[] = {{".2", u3_cwc_end}, {}};
static u3_cs_harm _mood__hoon_gor_a[] = {{".2", u3_cwc_gor}, {}};
static u3_cs_harm _mood__hoon_hor_a[] = {{".2", u3_cwc_hor}, {}};
static u3_cs_harm _mood__hoon_lsh_a[] = {{".2", u3_cwc_lsh}, {}};
static u3_cs_harm _mood__hoon_mas_a[] = {{".2", u3_cwc_mas}, {}};
static u3_cs_harm _mood__hoon_met_a[] = {{".2", u3_cwc_met}, {}};
static u3_cs_harm _mood__hoon_mix_a[] = {{".2", u3_cwc_mix}, {}};
static u3_cs_harm _mood__hoon_peg_a[] = {{".2", u3_cwc_peg}, {}};
static u3_cs_harm _mood__hoon_rap_a[] = {{".2", u3_cwc_rap}, {}};
static u3_cs_harm _mood__hoon_rip_a[] = {{".2", u3_cwc_rip}, {}};
static u3_cs_harm _mood__hoon_rsh_a[] = {{".2", u3_cwc_rsh}, {}};
static u3_cs_harm _mood__hoon_vor_a[] = {{".2", u3_cwc_vor}, {}};
static u3_cs_harm _mood__hoon_bex_a[] = {{".2", u3_cwc_bex, u3_no}, {}};
static u3_cs_harm _mood__hoon_can_a[] = {{".2", u3_cwc_can, u3_no}, {}};
static u3_cs_harm _mood__hoon_cap_a[] = {{".2", u3_cwc_cap, u3_no}, {}};
static u3_cs_harm _mood__hoon_cat_a[] = {{".2", u3_cwc_cat, u3_no}, {}};
static u3_cs_harm _mood__hoon_con_a[] = {{".2", u3_cwc_con, u3_no}, {}};
static u3_cs_harm _mood__hoon_cut_a[] = {{".2", u3_cwc_cut, u3_no}, {}};
static u3_cs_harm _mood__hoon_dis_a[] = {{".2", u3_cwc_dis, u3_no}, {}};
static u3_cs_harm _mood__hoon_dor_a[] = {{".2", u3_cwc_dor, u3_no}, {}};
static u3_cs_harm _mood__hoon_end_a[] = {{".2", u3_cwc_end, u3_no}, {}};
static u3_cs_harm _mood__hoon_gor_a[] = {{".2", u3_cwc_gor, u3_no}, {}};
static u3_cs_harm _mood__hoon_hor_a[] = {{".2", u3_cwc_hor, u3_no}, {}};
static u3_cs_harm _mood__hoon_lsh_a[] = {{".2", u3_cwc_lsh, u3_no}, {}};
static u3_cs_harm _mood__hoon_mas_a[] = {{".2", u3_cwc_mas, u3_no}, {}};
static u3_cs_harm _mood__hoon_met_a[] = {{".2", u3_cwc_met, u3_no}, {}};
static u3_cs_harm _mood__hoon_mix_a[] = {{".2", u3_cwc_mix, u3_no}, {}};
static u3_cs_harm _mood__hoon_peg_a[] = {{".2", u3_cwc_peg, u3_no}, {}};
static u3_cs_harm _mood__hoon_rap_a[] = {{".2", u3_cwc_rap, u3_no}, {}};
static u3_cs_harm _mood__hoon_rip_a[] = {{".2", u3_cwc_rip, u3_no}, {}};
static u3_cs_harm _mood__hoon_rsh_a[] = {{".2", u3_cwc_rsh, u3_no}, {}};
static u3_cs_harm _mood__hoon_vor_a[] = {{".2", u3_cwc_vor, u3_no}, {}};
static u3_cs_harm _mood__hoon__po_ind_a[] = {{".2", u3_cwcp_ind}, {}};
static u3_cs_harm _mood__hoon__po_ins_a[] = {{".2", u3_cwcp_ins}, {}};