本文整理汇总了TypeScript中ceval.ctrl函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ctrl函数的具体用法?TypeScript ctrl怎么用?TypeScript ctrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ctrl函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: instanciateCeval
function instanciateCeval() {
if (ceval) ceval.destroy();
ceval = cevalCtrl({
redraw,
storageKeyPrefix: 'puzzle',
multiPvDefault: 3,
variant: {
short: 'Std',
name: 'Standard',
key: 'standard'
},
possible: true,
emit: function(ev, work) {
tree.updateAt(work.path, function(node) {
if (work.threatMode) {
if (!node.threat || node.threat.depth <= ev.depth || node.threat.maxDepth < ev.maxDepth)
node.threat = ev;
} else if (!node.ceval || node.ceval.depth <= ev.depth || node.ceval.maxDepth < ev.maxDepth)
node.ceval = ev;
if (work.path === vm.path) {
setAutoShapes();
redraw();
}
});
},
setAutoShapes: setAutoShapes,
});
};
示例2: instanciateCeval
function instanciateCeval(failsafe: boolean = false) {
if (ceval) ceval.destroy();
ceval = cevalCtrl({
redraw,
storageKeyPrefix: 'puzzle',
multiPvDefault: 3,
variant: {
short: 'Std',
name: 'Standard',
key: 'standard'
},
possible: true,
emit: function(ev, work) {
tree.updateAt(work.path, function(node) {
if (work.threatMode) {
if (!node.threat || node.threat.depth <= ev.depth || node.threat.maxDepth < ev.maxDepth)
node.threat = ev;
} else if (!node.ceval || node.ceval.depth <= ev.depth || node.ceval.maxDepth < ev.maxDepth)
node.ceval = ev;
if (work.path === vm.path) {
setAutoShapes();
redraw();
}
});
},
setAutoShapes: setAutoShapes,
failsafe: failsafe,
onCrash: function(e) {
console.log('Local eval failed!', e);
if (ceval.pnaclSupported) {
console.log('Retrying in failsafe mode');
instanciateCeval(true);
startCeval();
}
}
});
};