ScratchData LogoScratchData
Back to gregatku's profile

L-Game AI remix

GRgregatku•Created August 24, 2024
L-Game AI remix
41
25
861 views
View on Scratch

Instructions

L-Game AI remix There are 4 menu options: [How to Play] - Instructions for playing the game [How to Win] - Tips on how to beat the AI. [Win Positions] - See every Win for Red (you) or Blue [Play] - to play a Game My additions to @videogamearcade's original include: 1) Adding some reasonable AI 2) Making the game **Mobile device friendly** upon which it is considerably easier to play. 3) Adding a new Menu option that allows you to see all winning positions (from either player's perspective) 4) Making the L-pieces look like single unit L shapes 5) Finishing the 2 player version @videogamearcade had already made a good start on 6) Changing the in-game Instructions to be more in keeping with my fully Mobile friendly implementation 7) Adding a few sound effects for Game Over and to highlight the 2 phases of the AI's turn 8) Maintaining a # Wins count to show at Game Over 9) Making it display the correct number of possibilities for a Wall move, ie. 13 (skip + 2 x 6 wall moves) 10) Making the AI much better, so that there's now 2 modes [Easy] and [Hard] 11) Adding a Low winning #moves Leaderboard for winning against the Ai in [Hard] mode *** NEW Version ***: [Easy] & [Hard] modes removed & merged, because it turned out that [Hard] mode's Wall moves were too predictable, making it easier to defeat than [Easy] mode. The new merged mode is also a little harder than both were previously, because the AI no longer moves any Wall that is already in a central square, unless such a move gives it a win, and after its L move if there is still an empty central square, it will fill it with its Wall move. The Leaderboard is now universal to all games against the AI, but I have not reset it, because 3 & 4 move wins are still possible, and those who have already found a 3-move win will be able to do so again, it might just take them a little longer to achieve it. The goal of the game is to prevent your opponent from having anywhere to move their L-shaped piece. When your opponent has nowhere to move, you win! On your turn, you must move your L-shaped piece. You can rotate and flip it however you want to. To move your L, drag your mouse across the four squares you wish to move to. You can also move a dark grey wall on your turn, but it is optional. To skip moving the wall, click the [skip wall move] button. To move the wall, click the wall you wish to move and then where you want to move it. Only you can move your L, but both players can move the walls. Remember every turn should be focused on trapping your opponent so that they have no possible moves. Do this and you will win! At the start of each new game you can click the [Blue is AI] button to switch to 2 player mode, and alternatively if it is in 2 player mode at the start of a new game you can click the [Blue is human] button to switch back to playing against the AI. ** New Feature ** new [Win positions] option on the main Menu, lets you see, study and learn from seeing as many of the possible winning positions as you wish! Should help you to learn how to win! ** NOTE** In an early version the AI could cheat by just moving a Wall and leaving its L where it was. I have fixed the bug now, but in case you think the AI is doing that again, after it wins (or any time at the start of your turn), you can hold your mouse/finger down on the Green area to highlight the AI's last move, and lift it up to remove the highlight (although you can't remove it after Blue wins). You can see for sure if it cheated or not. It highlights the pre-move position of the Blue L in a lighter blue and if it moves a Wall as well, it highlights its previous position in a brighter pink than its border. ** Update ** 26 Feb 2025 - Minor change to the project thumbnail to show the results of the series of 9 games I just played against the AI, because I wanted to to show that it's possible to win more often than you lose, and that you can win in 3 moves, which I did in Game 9.

Description

Thanks to "thinking" expert Edward de Bono, who for the record introduced the term "lateral thinking", for inventing this game in 1967 & special thanks to @videogamearcade for making a great project. I'm also grateful to @colinmacc for drawing my attention to the game by putting the original version in his Board Game studio. I'm also grateful to him, for finding a couple of nasty bugs that took me way too long to fix. More recently he pointed out to me that I had missed 3 primary solutions from the Wikipedia article on the game, which have now been added in. He also helped Identify a number of careless bugs I kept introducing by not testing my changes properly! I bombarded him with a lot of messages about the game too and he has been most patient with me. Thanks also to the Wikipedia article on the game for documenting pictorially the 15 primary winning positions for Blue in the game (there are 120 altogether, for all the rotations & reflections of the 15), which enabled me to write the code for the AI to take as many next move wins as I could make it. I made lots of changes ... Firstly I made it fully Touch Screen friendly and I also completed the 2 player mode that @videogamearcade said was coming soon. He had already done some good work on that so I just finished it off. However the main motivation for making any changes to it at all is that I found I could beat the AI too easily, and I very rarely lost a game. I wanted the AI to be a bit smarter, but not too smart because if it played the perfect game it could never be beaten, but I wanted the AI to win when I made a mistake and presented it with a next move win, whereas in the original version it was sheer luck if it took the win I presented it with. I even tried to lose on purpose by leaving most of the central squares open, and it still let me back into many such games. ** STOP PRESS ** - the AI now finds and takes ALL next move wins you offer it (including those requiring an L move & a Wall move most of which it previously missed)! Woohoo! Despite that the AI can still be beaten consistently, but because of my latest change where the AI now avoids placing any part its L in a corner, unless you force it to, it now takes considerably more work to achieve a win! No more super easy wins, but I have been able to win in 4 moves in [Easy} mode. However in the new [Hard] mode there are no [Easy] wins at all! The least moves I had been able to win in, playing [Hard] mode was 6, but as the new Leaderboard shows, @colinmacc did it in just 4 moves! I have also achieved a 4-move win too, but it was completely different to the one achieved in the previous version and significantly more difficult to achieve. I also found the Instructions & Tips (which are very good by the way) hard to read in the previous version's Font so I have made them easier to read now. There are likely to be bugs as I spent almost 350 hours on all the changes, and getting the AI to even do something reasonable did my head in many times, and I tried several approaches and nearly gave up a few times. If you find what you think are bugs please report them in the Comments. I also disabled the H key help feature, in part because it was buggy in that if you hit H on a Wall move the game froze. But also I didn't find the suggested L moves particularly helpful. You will find all you need to know to play a pretty good game in the Tips section, so I definitely recommend reading them. I hope you enjoy playing it as much as I have. It is a most fascinating game with the simplest rules you could imagine but it is still be quite challenging to win!

Project Details

Project ID1059066077
CreatedAugust 24, 2024
Last ModifiedMay 16, 2025
SharedAugust 31, 2024
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root