Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm currently using Java to code a program that can have conversations and solve problems.
So far, the program can only have conversations. The solving problems is still in process.
The program is capable of learning, however, it's how I made that happen that gives me doubts.
The way my program learns new words is it stores them in a TreeView menu as branches.
Each branch (word) has sub-branches that give the word meaning.
Each sub-branch has sort of like different tags to differentiate the relation to the main branch.
For example, if I teach it the word Hello and type Hello>>Hi, it then saves Hi as a sub-branch in the main branch Hello, but in the form of =s=Hi=s= to tell the program it's a synonym of Hello, so it can use Hi instead of Hello. More synonyms can be added.
Though if you type, for example, Hello<>Greeting, it stores the branch Greeting in Hello in the form of =m=Greeting=m=. To show that Hello is a type if greeting.
There is more, but too much to explain.
Just my cheap attempt on A.I.
Can this class as a program learning? Or have I got a long way to go?
As per definition of AI:- It's the capacity to perform operations analogous to learning and decision making in humans.
Your program do seems to learn the new words and make decision on what type of word it is i.e. Hello, Hi -->Greeting
But more than learning, how you control its learning will be AI. For example if I use a bad word for greeting, it should not learn it. Controlled learning and decision-making do make your program a true AI program.
You have actually started to learn AI. And this what you do is called giving ground terms manually for the machine. But AI is something that the system learns by itself. For example, now you have taught that hi is a way of greeting, if some other user greets it, it must greet him too. And yes you will be writing logic for that too. You cannot fully achieve AI such that the computer learns itself without writing any logic for it (only fictional characters like Jarvis can do so).
To be frank I am not deep into machine learning and AI. But to my perception, I think some sort of implementation which involves human like thinking would be better. For example, try to implement a chess game. In that you have back tracking. You can get a better understanding. Properties of each coin and their power is what you give as ground terms(base knowledge). And based on the moves of User, system must analyze future moves and predict user's view and backtrack to make its move.
Not sure whether I answered your question, but you seem to be doing cool stuff, thumbs up for you, move on and develop cool and small scale AI systems first which involves lot of computation and Algorithm stuffs.
Related
I am developing a chess game and at the moment I'm trying to implement a minimax algorithm. I haven't done this before, also the little i known about how to programmatically represent and implement the following evaluation function features(material, mobility, piece square table, centre control, trapped piece, king safety, tempo and pawn structure) is not quite clear to me (I will be grateful if someone can explain to me in detail). I have been able to assign values to each chess pieces, piece action values and a square table for each piece. The problem am having at the moment is how to generate Piece attacked and defended values which will be added or subtracted from the score. The idea here is that i want to reward the AI agent for protecting its pieces and penalize it for having the pieces attacked. thanks in advances.
Each of the evaluation features you mentioned will take up compute time. As you may already be aware, playing strength of a chess engine comes from two sources:
Search
Evaluation
And both contend for the same valuable resource, compute time. Evaluation tends to be heuristics based and hence a bit fuzzy, whereas search tends to yield more concrete and relevant results. If you are starting to build an engine then I would recommend focusing on search while keeping evaluation basic (but not weak!). That way you will be able to tell exactly where something went wrong and hence avoid possible early disappointments. Moreover, popular engines like Stockfish also started out by first building a strong search algorithm.
If you've been patient enough to read this far, let me point you to two useful resources for evaluation:
Chess Programming Wiki's evaluation page: This website is probably the best online resource for chess engine development in general.
Link to a basic but not weak evaluation function: This is C# code. Unfortunately I can't find the original article that I based this evaluation on.
Hope it helps :)
I think that you shouldn't include the computation on attack and defended pieces. That functionality is already taken into account by the minmax algorithm in a more efficient way.
A piece in under attack if at the following move the opponent can take it. If you try to evaluate this possibility in a static evaluation function you will get into troubles if you want to do it correctly. If my protected pawn is taken by the opponent queen that is not an issue. How do you take this into account? If my queen is taken by the opposite pawn but moving the pawn puts the king under attack?
These considerations are better managed by the minmax algorithm, not the evaluator. Consider that to know how many pieces you can eat/can be eaten, you should take into account all possible moves and you probably would spend the same time that would be used to go one level deeper in the minmax algorithm. Moreover that time is wasted if you later decide to indeed proceed one step further in the minmax.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have been experimenting with ways to use the processing power of two computers together as one (not by physically connecting them, but by splitting the task in half and each computer does a half, then the result from the "helper" computer is sent back to be combined with the result from the "main" computer via internet)
I've been using this method to compute fractal images and it works great. The left half and the right half of the image are computed on separate computers, then combined into one. The process of sending one half of the image to the other computer and combining them takes maybe a second, so the efficiency is great and cuts time down by about half.
The problem comes when you want to do this "multi computer processing" with something that needs data exchanged very frequently.
For example, I'd like to use this for something like an n-body simulation. You need the data exchange to happen multiple times per second, so if the exchange takes about a second it actually takes much longer to try and use two computers then it would with one.
So how do online video games do it? The players around you, what they are doing, what they are wearing, everything going on has to be exchanged between everyone playing many times per second.
I'm just looking for general ideas on how to send larger amounts of data and at fast speeds.
The way I have been doing it is with PHP on a free hosting site. The helper computer will compute its half of the data then sends it to the PHP file which saves that data somewhere. Then the main computer reads this and combines it with the data it computed already.
I have a feeling PHP isn't the way to go, but I don't know much about this sort of thing.
Your first step will be to move from using HTTP Requests to using Sockets directly - this will give you much more control over the communication, and give you improved performance by reducing the overhead of the HTTP protocol (this is potentially pretty significant). Plus, with sockets you can more easily have your programs communicate to each other directly, rather than through the PHP-based software.
There are a ton of guides online as to how you would do this sort of system, and I would recommend Googling things like "game networking" and "distributed computing".
Here is one series of articles that I have found useful in the past, that covers the sort of things that you will want to read about: http://gafferongames.com/networking-for-game-programmers/
(He doesn't use Java, but the ideas are universal)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I spent quite some time researching for a library that allows me to compare images to one another in Java.
I didn't really find anything useful, maybe my GoogleSearch-skill isn't high enough so I thought I'd ask you guys if you could point me into a direction of where I could find something like this.
Basically what I want to do is to compare two images with each other and get a value of how much the two are similar. Like a percentage or so.
I hope you guys have something I can use, I wouldn't know how to write something like that myself...
PS: It doesn't necessarily has to be in Java, that's just the environment my app will be running.
You could take a look at two answers on SO itself: this one is about image comparison itself, offering links to stuff in C++ (if I read correctly) while this one offers links to broader approaches, one being in C.
I would suggest starting with the second link since there's links on that discussion that'll lead to implementation code of some relevant techniques which you might be able to "translate" into Java yourself.
That's the best my google skills could do, no Java though - sorry. I hope it's a good starting point!
EDIT:
Here's someone with your problem who wrote his own comparison class in Java. I didn't read the source code though. He expressly states that he couldn't find Java libraries for that purpose either, so that's why he wrote it himself.
Oh, and this question on SO has probably the best links on this, all regarding Java libraries of image processing. Hopefully there's one amongst them that can compare images for similarity.
Ok, last edit:
The Java Image Processing Cookbook shows a Java implementation of a basic algorithm to determine the difference between two pictures. It also has an email to contact the guy who wrote it as well as a host of references. No library though.
EDIT after reading your comment to your question:
Unless you've already checked all of the above links, since what you want seems to be checking whether two images are equal, I would suggest starting with the Java Image Processing Cookbook (since that has an implementation of an algorithm in Java to check for equal images) and the last link to an SO question. Also, check PerceptualImageDiff and the source code of that project (C++); it sounds really nifty - it's apparently supposed to check whether two images look equal to the human visual system.
Just off the top of my head, OpenCV is a great image processing library, but it might be overkill if you just want to compare images. If that's the case, I'd go with ImageJ.
Someone already asked how to do this using OpenCV here.
I'd use C++ for this, but if you must use Java, there is a project which made a Java wrapper for OpenCV, here.
I used the class in this link to compare two product images, and the results were cool. It's not very hard to implement it just to be used for comparing two images, you just need to delete the lines of JAI and Swing and such. It resizes images to 300x300 and returns a difference value such as "1234". The maximum difference value is near "11041", it's stated in the link. Doing a division, you can simply get the percentage. If interested I can post the modified code here later.
The results were cool, but I still got "digital camera photos", detected to be similar to "TV photos". So, I used ImageJ to detect edges in the picture. Using the detect edges operation, ImageJ converts the image into a edge detected greyform image. Than I put the two edge-detected images in the same comparator and multiplied the both values. The results got even more accurate.
Getting the edge-detected form of the images
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have just started programming with Java and noticed I might need to improve my math skills if i'm to do anything worthwhile with it. I just noticed that some of the exercises should be easy for someone with a solid understanding in math as there seems to be some math formulae running the show. I finished high school two years ago and did not get any opportunity to do math at the highest level there. I'm deeply worried by this and so i'm looking for pointers from more experienced and knowledgeable people on what I should study to get a basic grasp of mathematics before indulging in deep waters.
I was generally a sharp student in math and I have got a real quick mind. My goal is to become a certified and well-experienced Java programmer by the end of the year. I know people will say experience takes time and effort but i'm willing to sacrifice whatever that I have towards fulfilment of this goal. I have programmed with PHP and MySQL a bit before and got a general understanding but Java gave me a real kick when I read about it. If you know any other stuff that may help me in this endeavour, please let me know.
Thanks.
I strongly encourage you to read Steve Yegge's Math for Programmers.
If you're looking for some books, I recommend Concrete Mathematics and The Art of Computer Programming.
If you're looking for some problems to practice with, check out Project Euler.
Do not be discouraged by challenging problems. It's is only through overcoming challenges that you will grow. The community here is quite willing to give you assistance and nudges when you reach a roadblock.
Let's also not forget the famous quote:
Whatever your difficulties in mathematics, I can assure you mine are far greater.---Albert Einstein
My goal is to become a certified and well-experienced Java programmer by the end of the year.
Finally, the only way to become well-experienced is to write code, and lots of it.
Discrete Mathematics is what you are most likely needing. Understanding base 2 (binary) base 16 (hex) number systems is helpful a must. You don't have to get bogged down in discrete mathematics as some of that is way too deep and makes math majors cringe. Look over basics such as sets and logic.
As for trig/calculus... I have taken all these in college and have never relied on these extensively... or well, at all.
Mathematical aptitude is not necessarily a prerequisite for being a good programmer. There is a strong association though in that good programmers tend to be good at math. That doesn't mean that learning more math will necessarily make you a better programmer. To become a better programmer usually takes a lot of coding. So with that in mind:
Code much and often and with best practices, try not to "cheat"
Challenge yourself
Try working through some problems on Project Euler
Trying doing advanced Sudoku in your head to practice deduction and to warm up
Linear equations, matrix algebra, Base 2, 8 ,18, and 10 conversions, logarithms, and set theory (intersections, unions, etc) will give you a basic foundation. If your algebra is sound, look into discrete mathematics, precalculus, and trig. Once you've gotten that far, you should have no trouble continuing if you wish.
Honestly, it may be worth your time to take a placement test at a local community college to get an honest evaluation of your skills. From there, you have the choice of enrolling in a class or learning their curriculums through self-instruction.
Go through http://www.khanacademy.org/ math section. Most people graduate high school with only Calculus I under their belt.
If you go through all math here, you will have almost satisfied math requirements for a bachelors in CS. What remains is discrete math, algorithms, finite automata.
Check out MIT Open Courseware for that as well.
IF you have any free time left after all these great suggestions, I might throw Head First Statistics on your reading list as well.
http://www.amazon.ca/Head-First-Statistics-Dawn-Griffiths/dp/0596527586
While not directly related to core Java programming, statistics finds many uses in some areas of computer science. For example, i"ve found this book very useful in some of the data mining projects I've been a part of.
I recommend this book because it is very easy and fun read, and serves as a good intro to statistics without bogging you down. This is that "before bead" reading you can do with minimal effort.
This isn't recommendations so much as general encouragement; I learn by doing. Reading books on mathematics, out of the context of some problem to solve, is boring, dry and generally not conducive to learning. I find if I set myself a programming challenge, one that is above my current level of competency, I will learn a lot and open up new areas of knowledge as a consequence of solving the problem. Perhaps it's harder/slower this way, but I find it gives me a solid, practical grounding in a subject. For example, back in the days I learned a lot about modulo mathematics by trying to find the simplest way to do human Vs computer rock-paper-scissors game.... My two cents.
I've quite often tried working through books, and have a good selection of partly read maths books. I gained a lot doing a second-year Open University pure maths course (M208) a couple of years ago - it's well structured, you have to do all the exercises, and it was both wide enough to introduce a few things I wouldn't have looked at off my own bat, but deep enough to be satisfying.
"Concrete Mathematics" would be a book suggestion on this topic.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
When interviewing college coops/interns or recent graduates it helps to have a Java programming question that they can do on a white board in 15 minutes. Does anyone have examples of good questions like this? A C++ question I was once asked in an interview was to write a string to integer function which is along the lines of the level of question I am looking for examples of.
Is there any reason why it has to be on a whiteboard? Personally, I'd rather sit them in front of a keyboard and have them write some code. Our test used to be a simple 100 (IIRC) line Swing text editor. We then broke it a few simple ways, some making the code not compile and some a little more subtle, and gave the candidates half and hour and a list of problems to fix.
Even if you can't have them do anything hands on make sure that you do give them some explicitly technical questions. In another round of interviews there were a surprising number of recent graduates who were just buzzword-spouting IDE-jockeys, so they could look OKish waving their hands around in front of a whiteboard talking about Enterprise-this and SOA-that, but when given a simple Java fundamentals multiple choice exam asking things about what final and protected meant did horrifyingly badly.
I've always thought that algorithmic questions should be language agnostic. If you want to test the java level of a student, focus on the language: its keywords (from common one like static to more exotic one, like volatile), generics, overloading, boxing/unboxing of variable, standard libraries.
Some stuff that has showed up on SO:
IsPalindrome(string s)
ReverseWordsInString(string s): "I know java" --> "java know I"
Other stuff that springs to mind:
multiply a Vector with a Matrix (can this be done OO-Style?)
echo (yes, a simple clone of the unix tool)
cat (15 min should be enough, should weed out the clueless)
a simple container for ints. Like ArrayList. Bonus question: Generic?
Write a function to swap variable values using pointers (Really poor ones will fall for this)
Write a program to find the distance between two points in the XY plane. Make use of a class to store the points.
Demonstrate the use of polymorphism in java using as simple program.
Write a program to print the first n prime numbers.
Write a program to replace a string in a file with another.
If you don't know what questions to ask them, then may be you are not the right one to interview them in Java. With all due respect, I hate when people ask me questions in interviews which they themselves don't know answers for. Answers for most of the questions can be found online by googling in a few secs. If someone has experience in Java, they will definitely know Abstract class, interface etc as they are the core building blocks. If he/she does not know 'volatile' keyword - big deal.
I agree with Nicolas in regards to separating the algorithmic questions from the actual language questions.
One thing that you might want to consider is giving them a couple simple algorithm questions that they can write up the pseudo code for on the white board (ex. "Explain to me the Bubble sort and show me the pseudo code for it."
Then once they have demonstrated their algorithmic knowledge you can move on to the Java questions. Since some people work better in front of a computer than in front of the whiteboard, I would give them something simple, but leveraging their knowledge of Java, that they can implement in 30 minutes or so in using the same IDE that you are using at the company. This way if they claim to know the IDE you can also get an idea of how well they know it.
Write a function that merges two sorted lists -- stopping at limit. Look for the easy optimizations and correct boundary checks / sublist calls. Tell them T implements compareTo.
public List<T> merge(List<T> one, List<T> two, int limit)
Write a function that returns true if any two integers in the array sum to the given sum. Have them try to do better than n squared using some sort of set or data structure.
public boolean containsSum(int[] nums, int sum)
I would avoid asking them questions that would have been covered in their undergrad classes. I would be more curious about their ability to apply everything they've learned to solve complex technical problems. If your business has a specific need for an IT solution you could use that as a starting point. You could ask the candidate what technologies they would use and the pros and cons of using those technologies versus alternate technologies. As the discussion progresses you could get a feel for their technical skills, problem solving skills, interpersonal skills, etc. I think it is important to avoid coaching them, even in awkward moments. This is important to weed out the BSers.