Multi-game round-robin tournament - javascript

Each year I am part of a group that hosts a "Lawn Game Olympics." 6 different lawn games (boccee, ladder golf, washer toss etc...) and every year a different amount of teams shows up. The first year was an unbalanced schedule and the drama that ensued was ridiculous, so i've set out to create a balanced schedule with a program that we can just punch in the amount of teams.
The issue is everyone wants to play eachother, or everyone wants to play the same game the same amount of times with a great effort and playing every team.
The traditional round robin formula only works for 13 teams with 1 bye, as it just happens to rotate around 6 games. Using the technique below, its simple (with 14 being a bye, and each line being a different game)
13 teams never happens, just my luck, and i cannot figure anything out for any other amount of teams. I have seemingly tried everything. The closest i've gotten is using combinatorics to generate all the matchups then try to brute force them together tracking whos played who and what etc.. but that still never works before crashing.
The ideal scenario, is every team plays each game twice (12 games per team). The other scenario would be each team playing eachother, with what games they played being luck of the draw, as long as each game is played at least 1 time, and no game is played 3 times when another has been played once.
Does anyone know if this is even possible? If it is, can i get a point in the right direction?

Related

Best way to orchestrate a sequence of events based on user input in a browser game?

I really struggled to phrase the title, which shows how lost I am. I consider myself a good web developer, but structures like this break my head :D
–––
The game
I'm remaking a little ear-training game of mine (http://twelvenotes.co/) with Nuxt3.
The game features 8 rounds of questions. Each round plays 2 musical notes and the player must tell which one is higher.
The interactive concept for the new version has changed. The game does not start automatically, but waits for a "Start now" input from the Playeyr. Each round the two notes play automatically in sequence. The Player has two options now:
Click on one note to lock in the answer to which note he thinks is higher
Replay the two notes in the same sequence, but lose "1 life" (or "extra listen") of 3
Answering a question shows an animation indicating if Player is right or wrong. After the animation is completed the game should move to the next round automatically and also start the round automatically, after the animated transition to the new round is done.
The whole game and each round individually is timed with a visible stop watch which will influence the final score.
After 8 rounds the Player is presented with an end screen showing the performance and a score.
The problem
As of right now, Creating the array of playable rounds, locking in the answer, moving to the next round, playing notes, replaying notes are all separate functions.
Now to the question: Whats the best way to control all these functions? Especially with timeouts needed for animations and playing notes etc. it's hard to structure which function does what and who tells it when to do it.
Who controls when we move to the next round and when we will start that round? Moving to the next round should only be possible when the current round has been answered. But should all of this be the job of moveToNextRound()? And who actually starts the round as in playing the notes, starting a stopwatch for this round etc. – And who stops the timer of the played round when the round has been answered? Is that a job for moveToNextRound() or startRound(roundIndex) or is that the job of a new function finishRound() - but who then calls finishRound()? Or should it be finishCurrentRound(). When a question is answered we need time for an animation telling the player if his answer was right or not and so on and so forth...
... I guess you get the picture. Structuring this is not easy for me. While doing it I constantly go back and forth between which function does what.
The question
Can you guys point me to best practices or resources in that field? Only thing I can think of googling is: "Gamecontroller"... which obviously only gives you results for gaming console gamepads.
Thanks!

Socket.io switch between game states

I'm making a multiplayer game in Node.js using Socket.js. Between the games I want users to be able to place their bets before a counter is ticking down. After that an incrementing number should pop up on the screen which eventually stops and then the counter and period to place bets comes back. I'm struggling to find anything on how to documentation or help on how to do something like this, where you are switching states/periods in a game.

Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn?

I have been learning about neural networks and genetic algorithms, and to test my learning, have tried to make an AI that learns to play flappy bird:
I have left it running for at least 10 hours (overnight and longer), but the fittest member still fails to show any significant advancements in intelligence from when I began the simulation apart from avoiding the floor and ceilings.
The inputs are the rays (as you can see above) that act as sight lines, and the network is fed in their lengths, and the birds vertical velocity. It seems that the best bird is essentially ignoring all the sight lines except the horizontal one, and when it is very short, it is jumping.
The output is a number between 0 and 1, if the output is larger than 0.5, then the bird jumps.
There are 4 hidden layers, with 15 neurons each, with the input layer feeding forward to the first hidden layers, then the 1st hidden layer feeding forward to the 2nd one ... and the final hidden layer feeding forward to the output, the dna of a bird is an array of real numbers representing the weights of the neural networks, I have made another project using the same style of neural network, and genetic algorithm, in which ants had to travel to food, and it worked perfectly.
Here is the code: https://github.com/Karan0110/flappy-bird-ai
Please say in the comments if you need any additional information
Please can you say whether my method is flawed or not, as I am almost certain the code works correctly (I got from the previous working project).
I like your idea, but I suggest you change some things.
Don't use a network with a fixed structure. Look up Neural evolution of autgmenting topologies and rather implement it yourself, or use a library like neataptic.
I don't believe your network needs that many inputs. I believe 3-5 sensors (20-50° gaps) would be enough, since many of the input values seem to be very similar.
If you are not sure why exactly your project is not working try this:
Try view an image of your current best network. If the network doesn't take important sensors (like the velocity) into account, you'll see it instantly.
Make sure all of your sensors are working fine (looks fine in the image above) and be sure to nkrmalize the values in a meaningful way.
Check if the maximum & average score increases over time. If it doesn't your GA isn't working properly or your networ receives inputs that are not good enough to solve the problem.
One trick that helped me out a lot, is to keep the elite of the GA in a seperate array. Only replace elite networks if some other network has performed better than the elite. Keep the elite trough all the generations, so once your algorithm finds an extraordinarily good solution, it won't be lost in any future generation if nothing else performs better.

Randomizer for baseball positions

I'm a web designer with a good amount of knowledge in html and css. I have some js knowledge, mainly just basic site interaction. I teach my son's T-ball team and the league has asked me to make a tool on their website to randomly assign positions and batting order for the team. This needs to be random for every player but not repeating a position in the lineup or fielding position until everyone has been in all of them. I need it to make sure everyone has an equal amount of time in every spot.
The coach would go to the league website go to the lineup/position tool put in there team names and then a lineup and position assignments would be generated and could be saved as a pdf.
I need this to be saved so that the next week the players wouldn't get the same position or spot in the lineup.
I know this is a lot, whatever help I get would really be appreciated.
Thank You!

How to check if a video is stabilized or not?

I was wondering how to detect camera motion in a youtube video.
I want to read in an youtube link process the video and tell the user if it was filmed using a tripod or if it was super shakey.
Do anyone know where I would even start? It might not even be possible?
Just spitballing here, but I'd start by capturing frames that are close together at various points throughout the video.
You would take the frames from each section and compare them to each other for variations in composition, dunno how to best go about that.. I'd probably start with like colour detection in various spots? anyway, start building a "difference score"
once you've gone through the frames for each section you sampled, you'll have a "difference score" and you can then start trying to figure out what the cut off point is for detecting a shakey video.
you probably couldn't do this anywhere close to realtime, so be prepared to have a bit of a wait period while the video processes.
Take some images each seconds (avoid to take it at a fixed frequency, because if the film has a move frequency, ie: if we are on a boat and we film during high waves)
After you can convert it to black and white (not gray levels) and compare it. Using the position of the minor color. (But it ain't gonna work fine)
Usually we use, edge detection : http://fr.mathworks.com/discovery/edge-detection.html and compare some of it. To see what is the scene and work together and waht is not. You must find "interest points" an calculate the vector between two frames. Some of this vector will move together. It's an object. Now you have to find which object if the scene.

Categories

Resources