Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to explain XOR logic compared to OR logic.
OR examples are many, e.g. "i need to be inside or use an umbrella to stay dry", but XOR examples are harder.
XOR is like cheating on your girlfriend: if you are alone with her it is ok, if you are alone with the other girl is ok, if you with none or with both you are screwed.
[ no girls were harmed for the sake of this example ]
"OR" example of yours gives about "dryness" while my "XOR" tells "if an action is a waste" .
If you are inside while using an umbrella == waste.
If you are outside while not using an umbrella == waste again.
IF you are inside while not using umbrella, it is ok.
If you are outside while using umbrella, it is ok.
Actually, neural networks getting popular and will become real life. Plus, there are many xor examples made for neural network training, there are so many of them that you need to have an umbrella to stay dry.
It's up to you to give some meaning to 1s and 0s.
Triple XOR:
Moving through time : yes=1, no=0
Moving through space: yes=1, no=0
Screaming : yes=1, no=0
Mission: escaping from a falling-piano.
time :(1,0,0) => (1) see the future,
call an ambulance
space :(0,1,0) => (1) walk one step back
so piano misses you
scream :(0,0,1) => (1) people hear you
people help you get to
emergency of hospital
time space :(1,1,0) => (0) at that time and location,
you are kept as hostage
in a robbery scene
time scream :(1,0,1) => (0) yelling at wrong time,
will not save you
space scream :(0,1,1) => (0) you evade the piano,
but you are still screaming,
:D
time space scream :(1,1,1) => (1) you see future and call ambulance,
also move
now you are in robbery
but you scream
so robbers escape
they had fake guns
you save money and life
(none) :(0,0,0) => (0) piano falls, noone hears
also they loot your body
epic items
Think of it like telling a child they can have candy, or ice cream. But they can't have both!
A Simple real life example is magnetic pole.
Like poles repel while unlike poles attract.
The room has two light switches controlling one light bulb. If both switches are ON, the light is off. If one is ON, the light is on, if none is ON, the light is off.
Pushing both buttons opens the trap door, so we wired that to the AND gate.
Pushing only one of the buttons, either one, releases the hounds, so we wired that to the XOR gate.
Method of operation:
Press one of the buttons to release the dogs. Once subject is running frantically press both buttons to open the trap door. Caution, opening the trap door first may be disastrous for the dogs.
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)
One pet peeve I have with a lot of older rock music records from the 60's and 70's
is they sometimes are slightly of of tune with the standard a440 reference pitch, so playing along on my guitar sounds bad. Right now I manually adjust the pitch of the track by ear in Audacity, but this often takes some time. I was hoping there was something out there that could detect the frequency of the first few notes of a music file, analyze that and see how far it is from any standard A440 note, and then you could use that number to determine how much you needed to make the track sharp or flat to match A440 tuning.
Is it possible to create an app that automatically retunes slightly out-of-tune music to be A440 with Javascript?
Yes. Check out this pitch detection demo by Chris Wilson.
There are some big caveats though, and they don't really have anything to do with JavaScript.
Voice Selection
What instruments do you care about? Obviously wideband stuff like percussion is atonal... but it's still going to turn up in your audio, and will have a pitch. How about the difference between a voice and wind instruments? A lot of vocalists will go off pitch intentionally. You will need to use bandpass fliters to get the range you care about, at a minimum.
Original Intonation
What about the instruments being in tune in the first place? "Another one bites the dust" comes to mind as a rock record from the 70s that starts off terribly out of tune... and maybe intentionally.
Pyscoacoustics and Harmonics
Sometimes we hear things that aren't really there. If I play a trombone down a scale, to the very bottom of its range, it will actually stop producing a fundamental... yet because I was playing a familiar scale downward, us humans will still perceive one. This might not throw off your detection by a lot, but it will somewhat, particularly on those atonal-but-not-really percussion instruments.
In summary, this is possible but it's going to be a lot of work. Please come back and post a link once you've done this!
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
In my University tests I often have to write programs and algorithms with pen and paper. For example, for my next test I'm going to have to write quite a lot of code in scheme and Java on paper.
I write quite a lot of code, but never on pen and paper. When writing code on paper, I often go at it with the same attitude as if I'd be writing the code on a computer. This often results in a lot of strikethroughs and additions, which often results in a total incomprehensible mess, because I'm used to being able to add and remove blocks as I please.
The problem is the programs or algorithms are complex enough so that it's not possible to think them completely through in your head before writing the code.
Is there any way to effectively and efficiently write code with pen and paper?
You are right in writing the code on paper as you write it on the system. But, to write an efficient code, you need to learn few things
Always use indentation at every line of code to make it presentable
Don't forget to add comments at various points so that what you are writing and trying to convey gets clear to the examiner
If anywhere you want to cut through some parts of your code, or encounter a strikethrough, better strike out the whole line and rewrite it. It improves the visibility of the code and makes it appealing.
Remember to leave ample amount of space between two lines of codes, probably a blank line or two. This spacing makes your code presentable.
More suggestions are welcome.
Ugh... Programming on paper!! =(
When I am backed into a corner and forced to do this, I like to have a pad of scrap paper handy. I nut out the shape of the program on my scrap paper.. That means I draw a bunch of rectangles, roughly representing how much code I might have to write in a block. When I realise I need something else in between, I sketch more rectangles and draw obvious arrows.
A rectangle might say a few hasty words about what it's achieving, like load stuff from thing. Or x < y ? Or whatever helps me get a feel for what I think I'm going to write, without wasting too much time. I might also note down variable names I intend to use further down, and draw an arrows to where that may be... Or even write a line of code that I mustn't forget!
That means I already have an overview of what I'm doing before I start the code. It gives me time to sit back and make sure I have thought it through. Then I can focus on implementing small chunks at a time and keep my thinking more linear. That's useful because I make more mistakes if I'm thinking ahead at the same time as writing.
Works for me... Might be useful to you, or it might just sound like rubbish.
while playing to this game I wondered how an AI controlling either the detectives either the criminal could work.
For lazy people the aim of the game is simple:
the board game is an undirected graphs that has 4 kinds of edges (that can also overlap for same pair or vertices), each kind is a type of transport that requires a specific kind of ticket
detectives have a bunch of tickets to move around this graph, one move per turn (which means from a node to another node). The criminal can do the same set of moves (plus 3 exclusive paths) but with no limits on tickes
the criminal is usually hidden to detectives but it has to show up himself in 5 specific turns (and then hide again)
if detectives are able to catch him (one of them must occupy the same cell of the criminal) before 24 moves then they win, otherwise the criminal wins
the criminal has to show which ticket he uses each turn but he also has 1 black ticket per detective (let's assume 5) that can be used to vanify this thing
the criminal also has two 2x tickets that allow him to use two tickets (and so two movements) in the same turn
I can think effectively about an AI for the criminal that it would be just a minmax tree that tries to choose movements that maximize the number of moves needed by detectives to reach him (it seems to be a good metric) but I cannot think anything enough cool for detectives which should cooperate and try to guess where the criminal can be by looking at tickets it uses.
It's just for fun but do you now any cool ideas to work out something quite clever?
You've asked how to model this, not how to solve this efficiently:
It can be easily modeled as a partially observable markov decision process (wiki link). This works both for the detectives and the criminal. POMDPs are a very generic model.
I love this game, and I think for the detectives you want to model the probability that the criminal is at each location. Every once in a while you know the exact position of the criminal, and then you can take into account the following moves he makes to determine which spots he could possibly be at.
Once you have this, I'm not quite sure how to optimize the detectives moves. You can move the detectives to reduce the set of possibilities, effectively corraling the criminal. But I'm sure there is also some higher level strategy needed surrounding the tickets and not running out of them.
I'd imagine some kind of a monte carlo implementation would be an excellent candidate for this, ie. simulating thousands of combinations and choosing the one that ends with the best result most of the time. Since the criminal has to be visible for 5 turns, the branching factor should stay well under control, although MC has also been shown to be a very good technique in games of high branching factor, ie. Go.
In order to get teamwork going between the detectives you need to model them as a team rather than as individuals. Minimax is still a good way to go but (sadly) your branching factor is going to soar.
Instead of stepping through all the detectives making what appears to be the best for each instead for your team of detectives you work out each permutation of moves they could make. If teamwork helps in this game then the minimax will favour the permutations in which the detectives are working together.
I'm not sure if it will be practical, 5 detectives for 24 ply might be too much work but it'd be fun to try and that's the point right?
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.