Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 06 Jan 2000
Offline Last Active Oct 19 2013 05:32 PM

#5067891 Data structure to represent/access synonym lists

Posted by on 06 June 2013 - 02:08 PM

I have data which consists of list of synonyms and within each list there is a preferred synonym.  For example, [A,b,c,d,e] and [Z,y,x,w,v], with the capitalized letter being the preferred name for that particular list of synonyms.  I want to be able to access all the members of the synonym list with any member of that list, and I want to be able to access the preferred name for a synonym list by any member of the list. 


The things that come to mind in C++ are maps and multimaps, and in Python Dictionaries.  I don't know of a version of multimap in Python.  Even with these, though it seems clunky.


For maps/dictionaries, I could create a vector/list of each synonym list which is stored in a map/dictionary multiple times, once for each item in the synonym list.  If this were in C++ I could store the pointer to the vector of each one to save some space.  Something like:


std::vector<std::string> syn_list_a

std::vector<std::string> syn_list_z

std::map<std::string, std::vector<string> > syn_map

std::map<std::string, std::string> > pref_map


syn_map["A"] = &syn_list_a

syn_map["b"] = &syn_list_a


syn_map["Z"] = &syn_list_z

syn_map["y"] = &syn_list_z


pref_map["A"] = "A"

pref_map["b"] = "A"


pref_map["Z"] = "B"

pref_map["y"] = "B"


For Python, I could translate this to dictionaries.


But, this all seems very inelegant and clunky.  Any suggestions for a better way??

#5037215 2D Array - really that hard?

Posted by on 27 February 2013 - 11:16 AM

By 'inherited' I hope you mean 'replaced within minutes'.


Excellent observation, but actually "inherited" in this case translates to "deleted and rewrote from scratch."  8^D


Just one more layer of fun.  When my colleague left, I was given access to his folders where he stored code - he didn't use any code management system, as if you needed to be told that.  I had to navigate by timestamps since his directory structure consisted of :










I'm not kidding.  <shudder>

#5036757 2D Array - really that hard?

Posted by on 26 February 2013 - 11:00 AM

OK, I have to play.


Over a decade ago I was working on a project with another developer whose job it was to implement the model for a 2D scatter plot.  The scatter plot had the ability to color-by and size-by - pick a data column and you would get a color or size gradient based on the data values. We had settled on 20 color steps and 20 size steps for the plot, and he was perplexed by how to accomplish this.  I suggested a 20x20 2D array, each element of which would hold the indices of the points corresponding to that a particular size and color, with the data range divided by 20 to get the bins for each one.  Not the most elegant solution, but seemed workable.


We were developing in VB 6 and he was enamored with dictionaries - everything was a dictionary.  So, he developed a dictionary that would be accessed by a two element string consisting of the bin locations.  In other words instead of the array bins(x,y), he had the dictionary bins["x,y"].  In his code, he would compute the color/size bin numerically, combine these into a string, use this to access the dictionary.  OK, whatever.


Put on top of this that his code computed the color and size bin locations in different locations and they might not always occur in the same order - sometimes you got "color,size" and sometimes you got "size,color."  It all depended on if the user clicked "color by" or "size by" first.  Oh, and he would use "first element 0" based calculations in one area and "first element 1" based calculations in another area. 


Now the kicker - the item stored in the dictionary was - wait for it - another dictionary.  This one was accessed by breaking up the original string key, doing some non-sensical conversions (not the obivous 20*y+x to get a linearlized array from the 2D array), and then access this dictionary with that new, converted key.  Which was converted to a string.


I inherited this code when he left.


#5010029 Online card game - backend questions

Posted by on 12 December 2012 - 06:45 PM

Aeramor - thanks for the tip. They have a great selection of platforms - best I've seen thus far. I might have other projects that can use this sort of thing.

#5009505 Online card game - backend questions

Posted by on 11 December 2012 - 01:00 PM

I've come up with an idea for a card game which I think would be good as an in-person as well as an online game. The details of the game are quite superfluous to my question, which is...

Given a multiplayer card game, or even something like Words with Friends, what are the backend requirements? I have no experience with this sort of thing, and I'm probably way out of my league on it all, but I'm curious as to what such a game entails. Is it run on a server which players log into and all the gameplay is managed there, or is it be done on the users' machines? How about as an Android app?


#4925392 Neural Network Genome Help Please :'(

Posted by on 26 March 2012 - 10:18 AM


There are a number of problems that you're going to run into along the way using this approach. I think that other posts have addressed most of the issues quite well, but I want to add a few details.

First, refer to Dagz's post regarding the topology of the networks. If the network structure does not change, then it should be quite easy to recombine two networks to get a child network. If you are also trying to evolve the network structure - number of nodes, specific connections, and weights - follow Dagz's advice to look at NEAT here: http://www.cs.ucf.edu/~kstanley/ He has a number of very good publications that describe NEAT itself, applications of NEAT, and extensions. The reading is somewhat technical, though.

Assuming that your network structure is not changing, crossover is only part of the story. If you only use crossover to recombine your networks, you will only be shuffling the existing weights around from place to place. You will want some sort of additional mechanism to apply changes to those weights. You could do crossover to generate your child network and then run backpropagation to optimize it, keeping the resulting weights for future generations. You could apply a mutation operator that modifies a very few weights slightly. You could specify a crossover operator that does this weight modification for you - maybe averaging some of the parent weights instead of copying them directly. There are many, many different ways to approach this, and you'll need to do a lot of experimenting to get the one that works for you.

Speaking of cross over, there are lots of different ways to do this. The one mentioned by laztrezort is the most common method, but in practice it does perform very well. A better option is 2-point crossover where you specify to random positions within each the genome, and swap the middles. Note that the sizes must be the same. Something like this:



Another commonly used crossover operator is one that randomly swaps single elements between genes. You might get something like this using the first two genomes I mentioned above:


And there are dozens of other ways to do this.

Finally, the behavior you're shooting for - entities that learn to seek food - will require a fairly long time to evolve. You'll need to be very patient and it may come down to just the right crossover and mutation operators run for an adequately long time.

Feel free to ask questions if you have them.


#4921365 Genetic Programming in Games

Posted by on 12 March 2012 - 09:36 AM

From a research perspective, you should check out NERO by Ken Stanley: http://nerogame.org/ The premise is evolving neural nets to control bots in a FPS type game. He has done a lot of work on evolving neural nets (see http://www.cs.ucf.edu/~kstanley/), and at the risk of being flamed out of existence, I've incorporated a NEAT implementation for evolving a Pac-Man controller: http://sourceforge.net/projects/aipac/?source=directory

Again, all of this is from a research perspective and doesn't necessariliy apply to a commercial game.


#4615394 any neural network experts?

Posted by on 08 March 2010 - 04:28 AM

I think your network structure is actually too complex, especially in the modified version with 3 hidden layers. Two hidden layers should be plenty.

You mention oscillatory behavior - are you doing batch training or individual training. Often oscillations occur when you have a training step after each example, and you can avoid this with batch training - running all of your examples through once, accumulate the errors, and the do one training step afterward.