I need a bit of counseling. I´m trying to reproduce one of M.C. Escher´s models in Actionscript, but I´m not entirely sure about where to begin. Ideally, I´d want to make something from his Circle Limit series look somewhat like this: http://vimeo.com/4154382
Could anyone provide any pointers as in what approach should I take? I am not an expert coder, so anything would help.
Thanks in advance,
Garfeel M.D.
The different copies of a hyperbolic transformation are related to one another via Möbius transformations which leave the circle fixed. You can represent them as transformations
(a+bi)z + (c+di)
z |-> ----------------
(c-di)z + (a-bi)
You might want to represent the switch from circle to half plane as a Möbius transformation as well, to avoid numeric issues with simple zooming.
I have tools available to make hyperbolic ornaments from Escher ornaments, and zoom into them in real time. But Escher isn't public domain yet, and in my experience the Escher foundation is less than enthusiastic in granting permission for derived works. So if you get ther OK, or decide on some other artist (possibly starting from a Euclidean ornament), feel free to contact me by e-mail to discuss this further.
I recently was a jury member foir an ornament competition where some submissions were hyperbolized from Euclidean drawings. Gaining permissions for those would likely be easier than from the Escher foundation.
Related
i put a small request on upwork where i am requesting help for a topic which is right now out of my skill zone.
The problem is a fitting problem of small rectangles in a big rectangle via a ANN.
Problem is the first freelancer baffled me a little bit with a comment.
So my thinking was, because the solution is easy verified and rewardable, that you can simply throw a ANN on this problem and with enough time it will perform better and better.
The freelancer requested labeled data first before he can tackle the problem(thats the comment which confuses me).
I was thinking that unlabeled random Input data is enough for the start.
Do I think wrong?
here the link to the job post.
https://www.upwork.com/jobs/~01e040711c31ac0979
edit: directly the original job description
I want python code for training a ANN and using it in a productive enviroment.
The problem it needs to solve is a rectangle fitting problem.
Input are
1000 small Rectangles(groupid,width,heigth,Oriantion(free,restricted,hor or ver), value) --sRect
1 big Rectangles(width, heigth)--bRect
Layout(bool,bool,bool,xpos,ypos,Oriantaion(hor or ver))--Layout
Output
Layout
The bRect will be duplicated to 3 Rectangles where the sRects need to be fitted into.
The Worth of the solution is determined by the sum of the value of sRect inside the bRect.
Further is the value decreased if the sRect is placed in the second bRect or third bRect.
sum(sRect(value))*0.98^nth bRect
Not all sRect needs to be placed.
Layout is structered that the three bool at the start represent at which bRect the sRect is placed. If a sRect is placed at one of the bRect, then the Solution Layout muss stay for this sRect the same.
Restricted Ori means all of the sRect with the same group need to be Oriantated the same way. Hor means the sRect is not turned, ver the sRect is turned by 90degrees.
Other then that normal rules apply, like all sRect needs to be inside the bRect and not Overlapp between sRect.
Looking forward to replys and i am avaible for further explanations.
edit: example picture
important i dont want to optimise for maximum plate usage, because it can happen that a smaller sRect can have a higher value then a bigger sRect.
example fitting problem
Without expected output for each input you cannot use the most standard training methodology - supervised learning. If you only have a way to verify the solution (e.g. in a game of chess you can tell me if I won but you cant tell me how to win) then the most standard approach is reinforcement learning. That being said, it is much more complex problem, not something that say a newcomer to the field of ML will be capable of doing (while supervised learning is something that one can do essentially by following basic tutorials online)
I'm a beginner in programming world, never touch any programming language before. But last 3 days I decide to try make a flash game, I looked some tutorial about AS3, try it, yes I understand a little bit. But I'm still confused about this:
How do I know or to decide what codes I write first, what next? example: I want to add a hero, then a enemy, then a tiles, then a background, event listener.
Is it okay if I write code randomly, example: first I add enemy, then add tiles, add background, then add hero, etc?
What is the best way to completely learn all AS3 codes, especially about flash game dev?
I'm now in frustration mode, so I decide to learn from you all who have mastered AS3.
Check out this guide by Michael James Williams. I was in the same situation as you, and that guide helped me a lot. It goes through a lot of the basics and does a good job of explaining each step.
To answer some of your questions, the order in which you code stuff doesn't matter too much. You can always go back and adjust your old code, and you'll definitely end up doing that at some point.
For learning AS3 syntax, just look through some examples and tutorials, and don't be afraid to read the official AS3 docs. They might be intimidating at first, but once you start learning some of the terminology, they're very helpful.
you can try some video tutorials like these
http://www.lynda.com/ActionScript-tutorials/AS3-language-fundamentals/123492/129625-4.html
http://www.lynda.com/Flash-tutorials/Building-Flash-Games-Starling/98951-2.html?srchtrk=index:1%0Alinktypeid:2%0Aq:flash%2Bgames%0Apage:1%0As:relevance%0Asa:true%0Aproducttypeid:2
If you're frustrated NOW, are you sure that you're ready to invest a couple of YEARS in becoming half-good with Actionscript? You'll have to like learning from your mistakes (an excellent way to learn, actually), because you will make thousands of them and they will cost you thousands of hours!
Do NOT write 'randomly' unless you want to greatly lengthen your time to mastery. Everything you do should have a purpose. I would start (if I were starting again) by giving myself a series of the smallest challenges: make an object appear; make it disappear; make it appear in one second from now; make it appear when I tap a key or click my mouse; make it move across the screen; make it move back; make it follow my mouse... etc.
There are many hundreds of basic programmatic elements like these that will add to your growing grasp of logic, data-structures and language. There are usually many ways to accomplish the same task -- learn and practice all of them.
Luckily, the Internet is full of good tutorials and references to Actionscript, and some decent forums like this one where you can get help.
I know this is king of old but someone might still find this useful.
I think that if you are serious about game development and also want to learn some techniques that are independent of the platform (Flash/AS3 in this case) you should use a framework.
For Flash the best game framework is the Starling along with Feather for UI.
They run on Stage3D which means that run on the GPU not the CPU which make them very fast.
With Starling you can also create mobile games that run in AIR so I think it really is something to consider.
On hsharma.com you can find a free video tutorial that goes through everything you need to know to get starting with game development so it should answer the question on how to create enemies, backgrounds, etc.
Hope this helps someone.
I am working on a simple drawing application, and i need an algorithm to make flood fills.
The user workflow will look like this (similar to Flash CS, just more simpler):
the user draws straight lines on the workspace. These are treated as vectors, and can be selected and moved after they are drawn.
user selects the fill tool, and clicks on the drawing area. If the area is surrounded by lines in every direction a fill is applied to the area.
if the lines are moved after the fill is applied, the area of fill is changed accordingly.
Anyone has a nice idea, how to implement such algorithm? The main task is basically to determine the line segments surrounding a point. (and storing this information somehow, incase the lines are moved)
EDIT: an explanation image: (there can be other lines of course in the canvas, that do not matter for the fill algorithm)
EDIT2: a more difficult situation:
EDIT3: I have found a way to fill polygons with holes http://alienryderflex.com/polygon_fill/ , now the main question is, how do i find my polygons?
You're looking for a point location algorithm. It's not overly complex, but it's not simple enough to explain here. There's a good chapter on it in this book: http://www.cs.uu.nl/geobook/
When I get home I'll get my copy of the book and see if I can try anyway. There's just a lot of details you need to know about. It all boils down to building a DCEL of the input and maintain a datastructure as lines are added or removed. Any query with a mouse coord will simply return an inner halfedge of the component, and those in particular contain pointers to all of the inner components, which is exactly what you're asking for.
One thing though, is that you need to know the intersections in the input (because you cannot build the trapezoidal map if you have intersecting lines) , and if you can get away with it (i.e. input is few enough segments) I strongly suggest that you just use the naive O(n²) algorithm (simple, codeable and testable in less than 1 hour). The O(n log n) algorithm takes a few days to code and use a clever and very non-trivial data structure for the status. It is however also mentioned in the book, so if you feel up to the task you have 2 reasons to buy it. It is a really good book on geometric problems in general, so for that reason alone any programmer with interest in algorithms and datastructures should have a copy.
Try this:
http://keith-hair.net/blog/2008/08/04/find-intersection-point-of-two-lines-in-as3/
The function returns the intersection (if any) between two lines in ActionScript. You'll need to loop through all your lines against each other to get all of them.
Of course the order of the points will be significant if you're planning on filling them - that could be harder!
With ActionScript you can use beginFill and endFill, e.g.
pen_mc.beginFill(0x000000,100);
pen_mc.lineTo(400,100);
pen_mc.lineTo(400,200);
pen_mc.lineTo(300,200);
pen_mc.lineTo(300,100);
pen_mc.endFill();
http://www.actionscript.org/resources/articles/212/1/Dynamic-Drawing-Using-ActionScript/Page1.html
Flash CS4 also introduces support for paths:
http://www.flashandmath.com/basic/drawpathCS4/index.html
If you want to get crazy and code your own flood fill then Wikipedia has a decent primer, but I think that would be reinventing the atom for these purposes.
I have a simple question regarding the Minimax algorithm: for example for the tic-tac-toe game, how do I determine the utility function's for each player plays? It doesn't do that automatically, does it? I must hard-code the values in the game, it can't learn them by itself, does it?
No, a MiniMax does not learn. It is a smarter version of a brute-force tree search.
Typically you would implement the utility function directly. In this case the algorithm would not learn how to play the game, it would use the information that you had explicitly hard-coded in the implementation.
However, it would be possible to use genetic programming (GP) or some equivalent technique to automatically derive a utility function. In this case you would not have to encode any explicit strategy. Instead the evolution would discover its own way of playing the game well.
You could either combine your minimax code and the GP code into a single (probably very slow) adaptive program, or you could run the GP first, find a good utility function and then add this function to your minimax code just as you would any hand-coded function.
Tic-Tac-Toe is small enough to run the game to the end and assign 1 for win, 0 for draw and -1 for lose.
Otherwise you have to provide a function which determines the value of a position heuristically. In chess for example a big factor is the value of the material, but also who controls the center or how easily the pieces can move.
As for learning, you can add weight factors to different aspects of the position and try to optimize those by repeatedly playing games.
How do determine the utility function for each play?
Carefully ;-) This article shows how a slightly flawed evaluation function (one for ex. which either doesn't go "deep" enough in looking ahead in the tree of possible plys, or one which fails to capture the relative strengh of some board positions) results in an overall weak algorithm (one that looses more often).
it can't learn them by itself, does it?
No, it doesn't. There are ways, however, to make the computer learn the relative strength of board positions. For example by looking into Donald Mitchie and his MENACE program you'll see how a stochastic process can be used to learn the board without any a priori knowledge but the rules of the game. The funny part is that while this can be implemented in computers, a few hundred colored beads and match boxes are all that is required, thanks to the relatively small size of the game space, and also thanks to various symmetries.
After learning such a cool way of teaching the computer how to play, we may not be so interested in going back to MinMax as applied to Tic-Tac-Toe. After all MinMax is a relatively simple way of pruning a decision tree, which is hardly needed with tic-tac-toe's small game space. But, if we must ;-) [go back to MinMax]...
We can look into the "matchbox" associated with the next play (i.e. not going deep at all), and use the percentage of beads associated with each square, as an additional factor. We can then evaluate a traditional tree, but only going, say 2 or 3 moves deep (a shallow look-ahead depth which would typically end in usually in losses or draws) and rate each next move on the basis of the simple -1 (loss), 0 (draw/unknown), +1 (win) rating. By then combining the beads percentage and the simple rating (by say addition, certainly not by multiplication), we are able to effectively use MinMax in a fashion that is more akin to the way it is used in cases when it is not possible to evaluate the game tree to its end.
Bottom line: In the case of Tic-Tac-Toe, MinMax only becomes more interesting (for example in helping us explore the effectiveness of a particular utility function) when we remove the deterministic nature of the game, associated with the easy evaluation the full tree. Another way of making the game [mathematically] interesting is to play with a opponent which makes mistakes...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I'm teaching a kid programming, and am introducing some basic artificial intelligence concepts at the moment. To begin with we're going to implement a tic-tac-toe game that searches the entire game tree and as such plays perfectly. Once we finish that I want to apply the same concepts to a game that has too many positions to evaluate every single one, so that we need to implement a heuristic to evaluate intermediate positions.
The best thing I could think of was Dots and Boxes. It has the advantage that I can set the board size arbitrarily large to stop him from searching the entire tree, and I can make a very basic scoring function be the number of my boxes minus the number of opponent boxes. Unfortunately this means that for most of the beginning of the game every position will be evaluated equivalently with a score of 0, because it takes quite a few moves before players actually start making boxes.
Does anyone have any better ideas for games? (Or a better scoring function for dots and boxes)?
Another game choice could be Reversi aka Othello.
A naive heuristic would be to simply count the number of tiles gained by each valid move and choose the greatest. From there you can factor in board position and minimizing vulnerably to the opponent.
One game you may consider is Connect Four. Simple game with straightforward rules but more complicated that Tic-Tac-Toe.
Checkers will let you teach several methods. Simple lookahead, depth search of best-case-worst-case decisions, differences between short-term and long-term gains, and something they could continue to work on after learning what you want to teach them.
Personally I think that last bit is the most critical -- there are natural points in the AI development which are good to stop at, see if you can beat it, and then delve into deeper AI mechanisms. It keeps your student interested without being horribly frustrated, and gives them more to do on their own if they want to continue the project.
How about Reversi? It has a pretty nice space of heuristics based on number of pieces, number of edge pieces, and number of corner pieces.
How about Mancala? Only 6 possible moves each turn, and it's easy to calculate the resulting score for each, but it's important to consider the opponent's response, and the game tree gets big pretty fast.
Gomoku is a nice, simple game, and fun one to write AI for.
Rubik's Infinity's quite fun, it's a little bit like Connect Four but subtly different. Evauluating a position is pretty easy.
I knocked together a Perl script to play it a while back, and actually had to reduce the number of moves ahead it looked, or it beat me every time, usually with quite surprising tactics.
Four in a line Hard enough, but easy enough to come up with an easy working evaluation function, for example, (distance to four from my longest line - distance to four from my opponent's longest line)
I really like Connect Four. Very easy to program using a Minimax algorithm. A good evaluation function could be:
eval_score = 0
for all possible rows/lines/diagonals of length 4 on the board:
if (#player_pieces = 0) // possible to connect four here?
if (#computer_pieces = 4)
eval_score = 10000
break for loop
else
eval_score = eval_score + #computer_pieces
(less pieces to go -> higher score)
end if
else if (#player_pieces = 4)
eval_score = -10000
break for loop
end if
end for
To improve the program you can add:
If computer moves first, play in the middle column (this has been proven to be optimal)
Alpha-Beta Pruning
Move Ordering
Zobrist Hashes
How about starting your Dots and Boxes game with random lines already added. This can get you into the action quickly. Just need to make sure you don't start the game with any boxes.
Take a look at Go.
Simple enough for kid on very small boards.
Complexity scales infinitely.
Has a lot of available papers, algorithms and programs to use either as a scale or basis.
Update: reversi was mentioned, which is a simplified variant of Go. Might be a better choice.
In regards to a better heuristic for dots and boxes, I suggest looking at online strategy guides for the game. The first result on Google for "dots and boxes strategy" is quite helpful.
Knowing how to use the chain rule separates an OK player from a good one. Knowing when the chain rule will work against you is what separates the best players from the good ones.