Unconquerable chess engines in Hopscotch

Now, I am curious on how to program some type of AI/engine which is unconquerable.

In other words, a human that can make mistakes, is creating something that cannot. Sounds weird.

What do I mean?

Let’s use chess as an example. Let’s say you go to the most difficult mode in an online chess game. This means that the AI will always make the best possible decisions. What is most puzzling to me, is that people who code these programs are human, and will be likely to make mistakes in a chess game, or not make the best possible decision ever time.

To be able to make a good decision, one must look ahead. But looking ahead means interpreting code that is not there. You may respond that this code can be ‘implemented behind the scenes’, but I will respond by saying how? How would a chess engine which can analyse everything, project a few potential moves, and make a decision that is in fact better than what I, the very programmer of it, can make?

Please share your thoughts, and if anyone has a website which can explain this, that would be super helpful!


I can mention an exqmple of a game i started but never finished making.
In a large square area, around 20 sprites are scattered randomly and have random values from 1 to 3.
A cannon is in the squares center.
The player aims the cannon and shoots a ball that bounces around the square until it eventually slows and stops.
When the ball collides with a number, that numbers value is added to the players score.

The bot AI would play first and shoot a ball at every angle from 1 to 359 in succesion.
This process would be hidden from being seen by the player.
The AI would store the angle of the cannon that resulted in the highest score when the ball was shot out.

So after the player sets an angle for the cannon and shoots then scores, the bot AI would shoot at the best angle it recorded to score the highest.
This player would have to wait while the AI tests out 360 angles to fins the best angle to shoot.
If multiple balls could be shot and coded so the balls ignore eachother, not collide, the AI could find the best angle quickly


I meant every angle from 0 to 359
I don’t have the option to edit my own post for some strange reason.


That’s really well thought out, I never thought of that. So in a chess game, (applying your ideas), for every chess piece I can make an invisible one. Then, before it makes its moves it can determine which square to move to (and when playing multiple moves ahead, it will predict my moves and move invisible versions of my pieces) and determine which move will yield the greatest amount of points in the long run?


I had a wonderful response to this, but it’s pending. In my response, I explained how this AI would work in a way that Hopscotch’s target demographic should understand and I showed how you could improve your method. Wonderful post btw.


This sounds neat
I thought about making an AI play against the human in a game of chess, but it was out of my ability by about the size of the universe to the power of 88.


Well with that attitude it is… Hopefully my post will break it down for you.


oh ok
i was thinking that chess would be a bit complicated, so i thought about making an AI for Tic Tac Toe first


but that’ll take some figuring out too


This is a very clever interpretation of a basic AI that would work in Hopscotch. Bravo!

For the rest of us, let me simplify this solution and explain it to make it more understandable.

A simple explanation of AI

AI stands for: Artificial Intelligence.
It basically means to perform a task that usually only humans can do because of how our brain works.

AI is very useful because it can do things that humans can do much faster and more accurately.

How does AI work

The AI strategy that @Stradyvarious used is one of the simplest forms of AI, but it can be used for really cool and complex things.
The AI learns by randomly doing whatever it can with the control you give it until it finds a random thing that works best for the goal you gave it.
Think of it like this:
Somebody (let’s call him Bob) gives you an unlocked iPad and asks you to find the Hopscotch app. You have no idea how to use an iPad, but Bob tells you that you use it by tapping the screen. You start tapping the screen in random places and end up barely ever touching an app and never touching Hopscotch, so Bob tells you that Hopscotch is an app and shows you what apps look like.
With these new instructions, you start tapping every app on the iPad. You start off tapping a lot of apps that are not Hopscotch. When you tap any app that is not Hopscotch, Bob tells you that that’s the wrong app. Finally, you tap the Hopscotch app. When you tap the Hopscotch app, Bob tells you that you picked the right one. Now you know where the Hopscotch app is and you can tap it every time Bob gives you the iPad.

That is how an AI works. Bob was the code and you were the AI. Although finding an app is a very simple task that would’ve probably been easier to do if Bob just showed you where Hopscotch was, there are lot more complex things you can do using the same method. You can even do things that would usually take you years in a day or less. In fact, did you know that YouTube uses a version of that method? In that case Bob (the code) tells the AI to give videos to the user that they will click on. When you click on a video, Bob tells the AI what video you clicked on and the AI gives the user videos that are like that one. With enough information, the AI will be able to get it right every time.

Now read how Stradyvarious created their AI. They told the AI to shoot in the place that gives the highest score. They also told it how to use the cannon. The AI fires the cannon randomly and when it finds a spot that gives it a score higher then the one it had before, it saves that shooting spot and tries to shoot there next time. If you wanted the AI to be even more accurate, you would tell it what number that gives it the highest score and the position of that number. Then it has more information to work with and become a more accurate shooter.


So basically, Bob “gives you the iPad” or basically what you’re doing, and you find the “Hopscotch app” or the goal or best move by going through all the “apps” or possible solutions?


If Bob were to give clearer instructions, like where the Hopscotch app is, then you could’ve found it faster. Sometimes you don’t have that information or it would be too complex to explain it, so you have the AI figure it out on it’s own.


In something like tic tac toe, you could technically program something that would play it perfectly. You could tell it that if a player moves here, then go here; but that takes forever. It’s a lot easier to give the program instructions and a goal so that it could figure it out on it’s own.


Nice explanation.

No wonder you took so long typing this… because it’s long, detailed, and clear.


This project seems related to what we are discussing here. (It’s Stradyvarious’s project)

So the objective is for the chick to not hit the ball. The chick will try random moves like jumping, going left, or staying, and from doing that, it will eventually never hit the ball consecutively.

If the chick makes a move and that move lets it hit the ball, the chick will now use the move less often because it lets the it hit the ball. After time if the chick uses the same move and that move lets the chick hit the ball again which it will for sure, then the chick will no longer make that move if the number below the move becomes 0.

So this project shows how AI learns.

It’s a cool project.


Yes. To save the progress of that AI, all you have to do is copy the values that it eventually decides to consecutively miss the ball.


Isn’t that the purpose of checking every angle, or am I missing something?


Yeah it is. Sorry about that.


Thanks for explaining simple AI (Brute force)


You made an amazing post, I was just making it easier for other people to understand. You really simplified the method for me, so I Broke it down for other people

So was that o compliment forced and you didn’t really mean it? Or do you mean something else by that?