Here is a link to an article from CodeProject, "Test Driven Chess Artificial Intelligence" by Kristian Ekman: https://www.codeproject.com/Articles/1168892/Test-Driven-Chess-Artificial-Intelligence
From the article: This is a fully functional yet simple chess program that aims to help
you understand how a chess engine works. There are already open source
chess engines on the Internet which focus on high performance. This is a
standard object oriented
C# solution that is meant to be easier to comprehend. The focus has not
been to make a fast and high rated chess engine. I have developed a
working chess AI that plays descent good moves with code that you
hopefully like to read. A few of the more specific
goals have been to correctly implement Alpha Beta Pruning and Zobrist
Hashing using C# 6.
If you are interested in artificial intelligence or computer chess, you might enjoy this.
Robert
Sunday, May 28, 2017
Saturday, May 27, 2017
Why Learn Pascal?
I purchased a copy of Genetic Algorithms in Search, Optimization & Machine Learning by David E. Goldman (1989). The book has sample code in Pascal. This is where Free Pascal comes in. When I coded last in Pascal it was with Turbo Pascal and I enjoyed it much more than coding in C. (I mentioned Free Pascal back in December 22, 2012 in this post: Learning to Program with Pascal.)
If you go to the Free Pascal website and look at their documentation you can see there is a great deal of documentation and that Free Pascal is now an object oriented language. You can download a copy of the language (free under the GNU General Public License). My complaint against the Genetic Algorithms book by Goldman is not that pascal is used, but that there is no license. I have looked at the book and there is no license that permits you to use the code. So if I typed up the code and posted it online at Sourceforge or Git Hub I would be violating copyright law, so I cannot share the code. And the code is not available online. You have to type the code yourself. There was an operating systems textbook for an OS called Xinu that had a statement from the author that the code could be used and I saw people use this OS professionally, typing the code from the book.
Criticisms against Pascal being old are misguided. The Scheme programming language is old, but it is a great educational language. The book Structure and Interpretation of Computer Programs by Harold Abelson et al is a great book to study. The Scheme programming language is also free.
So do not hesitate to get the book Genetic Algorithms by Goldman because the code is in Pascal. Pascal is a nice language worth knowing and Free Pascal can be used to run the code in the book.
Robert Canright
If you go to the Free Pascal website and look at their documentation you can see there is a great deal of documentation and that Free Pascal is now an object oriented language. You can download a copy of the language (free under the GNU General Public License). My complaint against the Genetic Algorithms book by Goldman is not that pascal is used, but that there is no license. I have looked at the book and there is no license that permits you to use the code. So if I typed up the code and posted it online at Sourceforge or Git Hub I would be violating copyright law, so I cannot share the code. And the code is not available online. You have to type the code yourself. There was an operating systems textbook for an OS called Xinu that had a statement from the author that the code could be used and I saw people use this OS professionally, typing the code from the book.
Criticisms against Pascal being old are misguided. The Scheme programming language is old, but it is a great educational language. The book Structure and Interpretation of Computer Programs by Harold Abelson et al is a great book to study. The Scheme programming language is also free.
So do not hesitate to get the book Genetic Algorithms by Goldman because the code is in Pascal. Pascal is a nice language worth knowing and Free Pascal can be used to run the code in the book.
Robert Canright
Wednesday, May 24, 2017
Comparing Files in Notepad++
A couple of years ago I posted an article about installing a Compare plugin for Notepad++. The links I used in the past have died, so here is new information.
On my copy of Notepad++, I did Plugins > Compare > About and got the window I show above. So you can go to Source Forge (https://sourceforge.net/) and search on "compare notepad plugin" and you will see you can download Compare Plugin 1.5.6.2.bin.zip (https://sourceforge.net/projects/npp-compare/?source=directory). Also there is a Notepad++ web page (https://notepad-plus-plus.org/community/topic/11116/compare-plugin) that lets you download Compare Plugin 1.5.6.7.bin.zip
This website (http://docs.notepad-plus-plus.org/index.php?title=Plugin_Development#How_to_install_a_plugin) has these instructions on how to install a Notepad++ plugin:
These are generic instructions. If the plugin comes with some different procedure, that procedure should be followed instead.
Once you installed the plugin, you can use (and you may configure) it via the menu "Plugins".
KDiff3
The KDiff3 tool is a little better. It compares directories as well. I am working a job now where the client provided me with a computer that had Notepad++ installed, but not KDiff3 and the client would not give me admin privileges to install KDiff3. So I am using the Compare plugin for Notepad++ and I'm glad I have it.
Here's what it looks like (below). Single-click on the image at it will enlarge.
On my copy of Notepad++, I did Plugins > Compare > About and got the window I show above. So you can go to Source Forge (https://sourceforge.net/) and search on "compare notepad plugin" and you will see you can download Compare Plugin 1.5.6.2.bin.zip (https://sourceforge.net/projects/npp-compare/?source=directory). Also there is a Notepad++ web page (https://notepad-plus-plus.org/community/topic/11116/compare-plugin) that lets you download Compare Plugin 1.5.6.7.bin.zip
This website (http://docs.notepad-plus-plus.org/index.php?title=Plugin_Development#How_to_install_a_plugin) has these instructions on how to install a Notepad++ plugin:
How to install a plugin
The plugin (in the DLL form) should be placed in the \plugins subfolder of the Notepad++ Install Folder. Configuration files should go in \Plugins\Config. Documentation files should go to \Plugins\Doc\ directory.These are generic instructions. If the plugin comes with some different procedure, that procedure should be followed instead.
Once you installed the plugin, you can use (and you may configure) it via the menu "Plugins".
KDiff3
The KDiff3 tool is a little better. It compares directories as well. I am working a job now where the client provided me with a computer that had Notepad++ installed, but not KDiff3 and the client would not give me admin privileges to install KDiff3. So I am using the Compare plugin for Notepad++ and I'm glad I have it.
Here's what it looks like (below). Single-click on the image at it will enlarge.
Saturday, March 18, 2017
Free Computer Science Math Book
You can download in PDF a free copy of a book on Mathematics for Computer Science. The book is Mathematics for Computer Science by Eric Lehman, F Thomson Leighton, and Albert R Meyer.
https://courses.csail.mit.edu/6.042/spring17/mcs.pdf
The book is almost a thousand pages long and it is not a cream-puff. Leighton is with MIT. It is used with this free on-line course: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-042j-mathematics-for-computer-science-fall-2010/index.htm
Some computer science work is very mathematical. Look at the book Communicating Sequential Processes by C. A. R. Hoare. It is very mathematical. This is a book and topic that you might want to at least glance at so you can see another way to look at parallel processing.
Here is the book in PDF: http://www.usingcsp.com/cspbook.pdf
Here is a Wikipedia article on Communicating Sequential Processes and another article on Tony Hoare.
Software is pretty cool. Enjoy your reading!
Robert
https://courses.csail.mit.edu/6.042/spring17/mcs.pdf
The book is almost a thousand pages long and it is not a cream-puff. Leighton is with MIT. It is used with this free on-line course: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-042j-mathematics-for-computer-science-fall-2010/index.htm
Some computer science work is very mathematical. Look at the book Communicating Sequential Processes by C. A. R. Hoare. It is very mathematical. This is a book and topic that you might want to at least glance at so you can see another way to look at parallel processing.
Here is the book in PDF: http://www.usingcsp.com/cspbook.pdf
Here is a Wikipedia article on Communicating Sequential Processes and another article on Tony Hoare.
Software is pretty cool. Enjoy your reading!
Robert
Sunday, March 5, 2017
C++ is Alive and Well
You might think that the C++ language, which has been around for many years, is an obsolete dinosaur. If so, you would be wrong because C++ is very much alive and well. Bjarne Stroustrup, the creator of C++, is a Managing Director in the Technology Division of Morgan Stanley. Companies are still writing code in C++. Here are a couple of open source C++ projects that are current.
Apache ActiveMQ C++ 3.9.3
Apache ActiveMQ C++ 3.9.3
IBM created the software called MQ (short for message queue). Then IBM embedded MQ into their WebSphere product. Now the open source community has created Apache ActiveMQ-CPP 3.9.3, which runs under the Apache License v2.0 license.
Apache ActiveMQ runs on Red Hat Linux.
Armadillo (C++ library)
Armadillo is a linear algebra software library for the C++ programming
language. It aims to provide efficient and streamlined base
calculations, while at the same time having a straightforward and
easy-to-use interface. Its intended target
users are scientists and engineers. The Armadillo was last updated (version 7.800.0) February 17, 2017, which is just last month, so this is software that is very much in use. Armadillo is open source software, so you can down-load it, study it, and use it.
C++ at Texas A&M
Programming: Principles and Practice Using C++ (2nd Edition) by Bjarne Stroustrup was developed at Texas A&M.
If you are interested in C++ programming, then you have an interest in a language still very much in use.
Robert
Tuesday, February 7, 2017
My Python Will Not Take a Command Line Argument
I had trouble getting my Python script to take a command line argument inside a subprocess.Popen call. I do not mean that I had trouble with something like "python my_script.py arg". No. Here is what was failing for me:
import subprocess
proc = subprocess.Popen(‘executable_file.bin arg’)
proc.communicate()
What I got was "file not found" errors. The Popen call could not recognize the argument as an argument. It thought it was part of the file name.
I could run the command from a command line in a terminal.
executable_file.bin arg
worked in a command line. Well, there is a way to make Popen work like a command line in a terminal/shell. This is what works.
subprocess.Popen(‘executable_file.bin arg’, shell=True)
The “shell=True” makes ‘executable_file.bin arg’work like it would in a terminal shell.
Robert
import subprocess
proc = subprocess.Popen(‘executable_file.bin arg’)
proc.communicate()
What I got was "file not found" errors. The Popen call could not recognize the argument as an argument. It thought it was part of the file name.
I could run the command from a command line in a terminal.
executable_file.bin arg
worked in a command line. Well, there is a way to make Popen work like a command line in a terminal/shell. This is what works.
subprocess.Popen(‘executable_file.bin arg’, shell=True)
The “shell=True” makes ‘executable_file.bin arg’work like it would in a terminal shell.
Robert
Monday, October 10, 2016
Check Python Code for Syntax
A friend recommended I use Pylint to check my code for syntax errors. Why not just run the code? In complex code you can write a python module that cannot be run because it is part of a complex system. You have to check your code into a code repository used by other people. You want to check your code before checking it into the code repository. But the Pylint program is not available for Windows. It works on Linux systems, but the yum install tool finds all dependencies and installs everything needed to make Pylint work. That does not happen in Windows, where you have to find and fix dependency after dependency. You really cannot get Pylint to work on Windows, but you do not need to.
Say you want to check a file called my_python_program.py for syntax errors. The trick is that importing a python module compiles that module, and the compilation finds all the syntax errors. Here is what you do: write a program called my_test.py that looks like this:
Run this program and the first syntax error found will throw an exception. Fix my_python_program.py and run my_test.py again. When all the errors are fixed, the program will print "finished test." Now you can check-in your program into the code repository and know that it will not roll-over-and-die. It might not work, but it will not die!
I launch the IDLE program, open the file through File > Open. Then in the file edit window I do Run > Run Module. The output is printed in the IDLE shell window.
Update January 2017
A friend told me Pylint would catch some errors that compiling Python code would not catch. It turns out he was right. I was glad I used Pylint. I said earlier that it is hard to test Python modules that are part of complex systems. You could use the unittest unit testing framework from Python, which is patterned after JUnit for Java, but then you have to write the test code. It is nice to have the budget and schedule to write test code, but that happens rarely. When your code interacts with an external software system then you have to wait until you have access to the other system or must have a simulator for the other system. A decent simulator is important for expensive and complex systems, but the simulator should be provided by the company supplying the external system. The external system can be a networked hardware unit. Getting good interface documentation (command messages and response messages) from the company providing the networked hardware or software is vital. Remember that both the interface documentation and the simulator must be in the contract. The other company cannot be relied upon to supply these unless they are contractually obligated to supply them.
Robert
Say you want to check a file called my_python_program.py for syntax errors. The trick is that importing a python module compiles that module, and the compilation finds all the syntax errors. Here is what you do: write a program called my_test.py that looks like this:
import my_python_program
print "***************"
print "finished test"
print "***************"Run this program and the first syntax error found will throw an exception. Fix my_python_program.py and run my_test.py again. When all the errors are fixed, the program will print "finished test." Now you can check-in your program into the code repository and know that it will not roll-over-and-die. It might not work, but it will not die!
I launch the IDLE program, open the file through File > Open. Then in the file edit window I do Run > Run Module. The output is printed in the IDLE shell window.
Update January 2017
A friend told me Pylint would catch some errors that compiling Python code would not catch. It turns out he was right. I was glad I used Pylint. I said earlier that it is hard to test Python modules that are part of complex systems. You could use the unittest unit testing framework from Python, which is patterned after JUnit for Java, but then you have to write the test code. It is nice to have the budget and schedule to write test code, but that happens rarely. When your code interacts with an external software system then you have to wait until you have access to the other system or must have a simulator for the other system. A decent simulator is important for expensive and complex systems, but the simulator should be provided by the company supplying the external system. The external system can be a networked hardware unit. Getting good interface documentation (command messages and response messages) from the company providing the networked hardware or software is vital. Remember that both the interface documentation and the simulator must be in the contract. The other company cannot be relied upon to supply these unless they are contractually obligated to supply them.
Robert
Subscribe to:
Posts (Atom)

