or try game learning machine
Pick a simple game maybe enlarged tic-tac-toe (3 dimensional, or more than 9 boxes) or maybe a 4x4 checker game. Devise a learning machine that rewards a path to winning by incrementing numbers in link(s) and punishes a path to losing by decrementing numbers in link(s). Make it play both as the first mover and the second mover.
Play it against itself and remember the link numbers. It should learn...
User Profile
Collapse
-
Got it to work
after making the target const and a little more massaging, the following works:
[code=c]
#include <string>
#include <queue>
using namespace std;
typedef string (*attr_func_T) (const string);
typedef const string attr_arg_T;
class multi
{
public:
string invoke (void)
{
...Leave a comment:
-
STL error message in g++
I'm trying to get the class multi to store a series of function/argument pairs. The functions are of the form:
[code=c]
string funcA (const string argA)
[/code]
I thought that I had all the signatures matching in:
[code=c]
#include <string>
#include <queue>
using namespace std;
typedef string (*attr_func_T) (const string);
typedef ... -
Java is a language that (0riginally) compiled into byte codes which are opcodes for a specified (non-existant) machine. The machine in implemented in a Java Virtual Machine. This machine has a defined length of the integers, characters .... The idea was write once, run on many different machines with no changes to the byte codes, just to the JVMs.
/s/ Jim WIlliamsLeave a comment:
-
check on whether char is signed or unsigned by default
/s/ Jim WIlliamsLeave a comment:
-
C++ STL to generate HTML for vertically alphabetized table
presented for editing and comment
The article is about using STL components in processing data and producing a <table> with the elements sorted vertically. The ideas in the program demonstrating STL use are interesting IMHO and the generation of vertically sorted tables is useful for some applications.
/s/ Jim WIlliams
Both files use UNIX line termination
The article text is in HTML...Last edited by Niheel; Sep 1 '24, 06:20 PM. -
You are probably not checking for end of file correctly. Look at the documentation of .get() and its friends (google get())
/s/ Jim WIlliams
also note that 0-037, 0177 and 0200-0237 (octal) are not directly printableLeave a comment:
-
I've written a C++ STL function that generates xtml to build a table of words in alphabetical order by column (vertically) rather than by row. I find alpha by column easier to read. Would it be reasonable to post it as a shared insight? If so should it go into C++ or HTML? Also would a code review be a good preliminary to posting an article?
Thanks
/s/ Jim WIlliams
(Message also send to weaknessforcats... -
I've written a C++ STL function that generates xtml to build a table of words in alphabetical order by column (vertically) rather than by row. I find alpha by column easier to read. Would it be reasonable to post it as a shared insight? If so should it go into C++ or HTML? Also would a code review be a good preliminary to posting an article?
Thanks
/s/ Jim WIlliams -
I believe you are probably reading a line from your input file that is missing a token.
Try checking the token value for NULL before passing it to atoi(), then printing a error message and exit. If this shows up a problem, I'd then count input lines as I read them in and print the line number as part of the error message, this will make it easier to find the bad line in the input file.
Checking for NULL is good defensive...Leave a comment:
-
found the solution in Meyers, Effective STL item 22
Thanks, your hint about const ness was the clue. It turns out that STL implementations differ on the const of set objects. GNU makes them const.
Meyers shows a workaround for non-key data members of the objects in the set, using a cast to alter the const ness of the reference
is...Code:const_cast<key_word_T&>(*global_itor).inc();
Leave a comment:
-
error message text
Thanks for the style suggestions
andCode:global_itor->inc();
produce the identical error message (g++)Code:(*global_itor).inc();
error:passing 'const key_word' as 'this' argument of 'void key_word::inc() ' discards qualifiersLeave a comment:
-
how can I reference a member function using a SET itor
Please pardon my ignorance. I'm writing a C++ STL program after not writing code for 7 years, I'm trying to invoke key_word.inc() using an iterator for a set containing key_word_T. The following is a pared down version.
...Code:#include <cstdlib> #include <set> #include <string> using namespace std; class key_word { public: string word (void) const { return
No activity results to display
Show More
Leave a comment: