Jump to content

  • Log In with Google      Sign In   
  • Create Account

larspensjo

Member Since 19 Mar 2012
Offline Last Active Oct 30 2014 01:33 PM

Topics I've Started

Fitness function for self modifying programming

19 October 2014 - 02:54 AM

Problem: How to make a good fitness function?

 

Assumptions:

  • There is a specially designed programming language.
  • The program will not directly modify itself, but indirectly through the use of genetic algorithms.
  • Using mutations combined with child generation from random parents.
  • The language is fairly resilient to bit mutations.
  • The merger of two parents will have a high chance of producing a new algorithm that is not completely broken.

A problem with using randomly created algorithms, compared to e.g. neural networks, is that these algorithms are unlikely to produce any usable output. At least initially. Designing a fitness function for a numerical output can be easy, which could be a measurement of the distance from the result to the target. But what about a fitness function for a sorting algorithm?

 

Using a fitness function limited to the outputs 0 and 1 is not good enough. It will almost always produce 0, not providing any help for the genetic algorithms. Given my preconceptions about sorting, I could create a fitness function that gives some score for actually reproducing some input on the output. And gradually increase the score the better the output is ordered.

 

But there are drawbacks with this kind of fitness functions:

  • It presumes that a certain intermediary result is good, a step on the way to a final solution. But that may prevent the algorithm from finding the non obvious solutions I didn't know about.
  • It requires a lot of effort to formulate. A different function will be needed for different algorithm problems.

I am not sure there a solution to this problem. Any feedback or references are welcome!


How to find uv coordinates for a 3D triangle?

04 January 2014 - 04:21 PM

I am using the uv coordinate as a seed for a 2D simplex noise to create surface effects. If the triangle has the normal pointing at z, then xy can be used as uv coordinates.

 

However, the triangles have more or less random orientations. I suppose I need a rotation so as to have the normal aligned with e.g. z, then I can again use xy as uv. I have difficulties to find out how to do this rotation.

 

It may be that the problem can have more than one solution, but I only need one. Is there an efficient algorithm for this?

 


Log file viewer

15 September 2013 - 10:45 AM

I created a log file viewer. Source code is available at https://github.com/larspensjo/lplog. It works a little like "tail -F file | grep pattern" where you can change pattern afterwards.

 

Features:

  • Display text in a window, loaded from a file.
  • Whenever more lines are added to the file, the window will be updated.
  • Whenever the file is restarted, the display will be restarted, in a new tab.
  • Support pattern conditions in the form of a tree of OR ('|'), AND ('&') and NOT ('!') nodes.
  • Parts of the filter can be enabled or disabled by a click to make it easy to change.
  • Pasting of clipboard or drag-and-drop into a new tab.
  • Incremental quicksearch.
  • Optional display of line numbers.

lplog1.png

 

It is based on GTK, and I compile it on both MinGW and Ubuntu. Windows installation files are available at https://www.dropbox.com/sh/lxneh66393icwb4/7J7vhx1olq


c++11 iteration and warnings

08 March 2013 - 11:29 AM

I want to iterate through an object in c++11, and like the new syntax. If I have the following code:

for (auto x : object) {
    ...
}

 

I have a case where I don't want to use 'x'. That will produce a warning, as expected. How do I best suppress this warning?

 

I suppose I can add a line (void)x; but maybe there is some better way?

 

If there is no better way, can I be sure that the void reference to 'x' generates no code?

 

There is of course the old way of using iterators, but it looks much better with the new way of doing it. Or tell the compiler to ignore these warnings, which I do not want to do.


Compatibility between MVC and ECS patterns?

08 March 2013 - 01:42 AM

Are the Model-View-Controller and the Entity-Component-System design patterns compatible with each other?

 

Do they overlap, or can they both be used at the same time?


PARTNERS