logic

What is fuzzy logic?

五迷三道 提交于 2019-11-28 16:12:09
I'm working with a couple of AI algorithms at school and I find people use the words Fuzzy Logic to explain any situation that they can solve with a couple of cases. When I go back to the books I just read about how instead of a state going from On to Off it's a diagonal line and something can be in both states but in different "levels". I've read the wikipedia entry and a couple of tutorials and even programmed stuff that "uses fuzzy logic" (an edge detector and a 1-wheel self-controlled robot) and still I find it very confusing going from Theory to Code... for you, in the less complicated

determine whether point lies inside triangle

一世执手 提交于 2019-11-28 15:48:11
The program needs to read the values of three coordinates P1(x1,y1) P2(x2,y2) P3(x3,y3) as well as another coordinate P(x,y) and determine whether this point is inside a triangle formed from the 3 point above. The proper way to do this is by calculating the barycentric coordinates of the fourth point given the three points of your triangle. The formula to compute them is given at the end of the section "Converting to barycentric coordinates", but I hope to provide a less mathematics-intense explanation here. Assume, for simplicity, that you have a struct, point , that has values x and y . You

Higher-order unification

佐手、 提交于 2019-11-28 15:44:16
问题 I'm working on a higher-order theorem prover, of which unification seems to be the most difficult subproblem. If Huet's algorithm is still considered state-of-the-art, does anyone have any links to explanations of it that are written to be understood by a programmer rather than a mathematician? Or even any examples of where it works and the usual first-order algorithm doesn't? 回答1: State of the art — yes, so far as I know all algorithms more or less take the same shape as Huet's (I follow

Looping won't stop when reading user input

纵然是瞬间 提交于 2019-11-28 14:05:57
This code cannot stop looping even when I enter n or N. What is causing this? char next = ""; printf("Do u want continue\n"); scanf("%c", &next); getchar(); do { if (next=='y' ||next=='Y') { selection(); } else { printf("invalid Please Enter again"); scanf("%c", &next); } } while (next !='n'|| next!='N') The conditional (next !='n'|| next!='N') is always true. If next is 'n' then next!='N' is true making the whole expression true. Similarly, if next is 'N' then next!='n' is true again making the whole expression true. What you want here is to use a logical AND && : } while (next !='n' && next!

General rules for simplifying SQL statements

南笙酒味 提交于 2019-11-28 13:23:05
问题 I'm looking for some "inference rules" (similar to set operation rules or logic rules) which I can use to reduce a SQL query in complexity or size. Does there exist something like that? Any papers, any tools? Any equivalencies that you found on your own? It's somehow similar to query optimization, but not in terms of performance. To state it different: Having a (complex) query with JOINs, SUBSELECTs, UNIONs is it possible (or not) to reduce it to a simpler, equivalent SQL statement, which is

NASM Assembly mathematical logic

我怕爱的太早我们不能终老 提交于 2019-11-28 13:03:19
问题 I have a program in assembly for the Linux terminal that's supposed to work through a series of mathematical manipulations, compare the final value to 20, and then using if logic, report <, > or = relationship. Code is: segment .data out_less db "Z is less than 20.", 10, 0 out_greater db "Z is greater than 20.", 10, 0 out_equal db "Z is equal to 20.", 10, 0 segment .bss segment .text global main extern printf main: mov eax, 10 mov ebx, 12 mov ecx, eax add ecx, ebx ;set c (ecx reserved) mov

Java program to find the character that appears the most number of times in a String?

核能气质少年 提交于 2019-11-28 12:50:24
问题 So here's the code I've got so far... import java.util.Scanner; class count{ public static void main(String args[]){ Scanner s=new Scanner(System.in); System.out.println("Enter a string"); String sent=s.nextLine(); int len = sent.length(); int arr[]=new int[len]; int count=1; char ch[] = new char[len]; for(int i = 0; i <= len-1; i ++) { ch[i] = sent.charAt(i); } for(int j= 0;j<=len-1;j++){ for(int k=0;k<=len-1;k++){ if(ch[j]==ch[k]){ arr[j]= count++; } } } int max=arr[0]; for(int z=1;z<=len-1

PHP check to make sure request is either xmlhttp from my site or normal request from a certain domain

瘦欲@ 提交于 2019-11-28 12:35:57
问题 How would the condition be written to ensure a page is either accessed by xmlhttp request from my site or from an allowed outside domain? <?php $referrer = $_SERVER['HTTP_REFERER']; if($_SERVER["HTTP_X_REQUESTED_WITH"] !== 'XMLHttpRequest') { if(preg_match("/accepteddomain.com/",$referrer) { header("Location: http://www.domain.com/desiredpage.php"); } else { header("Location: http://www.domain.com/nondesiredpage.php"); } } ?> 回答1: Considering that both Referer and X-Request-With headers are

How to solve && operands to logical scalar

我是研究僧i 提交于 2019-11-28 12:17:21
After I run the code in matlab, I encounter this error and unsure how to solve it. How can I solve this problem. Warning: Operands to the || and && operators must be convertible to logical scalar values. Jgray = double(rgb2gray(J)); % Calculate the Gradients [dIx, dIy] = gradient(Jgray); if max(dIx)<=103 && max(dIy)<=100 B = abs(dIy) - abs(dIx); else B = abs(dIx) - abs(dIy); end user1083059 If dIx and dIy are matrices (as opposed to 1-D vectors), max(dIx) and max(dIy) will return vectors. && and || should be used to compare scalars, not vectors. You probably want to type if max(dIx(:))<=103 &&

What's the approach to solving this kind of logic problem?

荒凉一梦 提交于 2019-11-28 11:15:12
What would be the approach to a kind of problem that sounds like this: A says B lies B says C lies D says B lies C says B lies E says A and D lie How many lie and how many tell the truth? I am not looking for the answer to the problem above, but the approach to this kind of problem. Thanks a lot. A -> !B B -> !C D -> !B C -> !B E -> !A & !D Reminder: X -> Y <=> !X | Y Transform the 5 equations into logical propositions, and you will find answers. To solve equations of the form X 1 = NOT X 3 X 5 = NOT X 2 etc Form a graph with nodes as X i and connecting X i and X j iff the equation X i = NOT X