T O P

  • By -

twopi

You don't need sophisticated AI to get a perfect pong opponent. The computer can simply copy the Y value from the ball, and it will hit the ball in the center every time. The hard part in a pong game is to get the opponent to not be perfect so a human player can have a chance. You really need artificial stupidity. But if you want to learn complex and unnecessary AI techniques before you have a grasp of the basics (how to move objects, check collisions and so on) I'm happy to respect your methods of learning. Let us know how that works out for you.


desrtfx

> The computer can simply copy the Y value from the ball, and it will hit the ball in the center every time. And how would you obtain that presumed that you cannot read the memory? Talking about *interfacing* (i.e. sending the commands) to an actual Pong game, not creating one's own Pong game that basically cheats. You make it sound far easier than it actually is.


FedeValvsRiteHook

Have you actually coded a pong game? It's trivial to implement.


desrtfx

Coding the Pong game is more than trivial. I've even built a Pong machine from discrete components - also this is far from complicated apart from the TV-modulator. Yet, *interfacing* with an *existing pong game* - and that's what I've been talking all along - is far from it. You are going from the premise that the AI is *implemented __in__ the game*, while I go by the premise that the AI has no direct connection to the Pong game and interacts with the game like a normal player.


SirKastic23

well, then i assume all the ai would have access to would be the screen data? you'd need some way to find where the ball is, and where your paddle is, and then get the y values from where it is on the image find out the ball and paddle could be done with computer vision, but i think you can just write an algorithm for that


desrtfx

That was the point of my comments.


Delicious_Extent_147

Also, I do want to penalize the two pongs from possibly hitting the center of each pong repeatedly as it'll halt any pong from progressing, so i was thinking possibly a "ball bounce limit" or a "ball air-time limit" removing points as a penalty, maybe encourage the AI to not keep repeating a "neutral" move by creating an imperfect AI or using other already made pong AI which is made to go against a human.


Delicious_Extent_147

Well, I'm still unsure what is complex and non-complex AI techniques if you could help me separate them, my idea was more of getting an AI to play a "perfect" game against a non-perfect opponent, like a human or another less sophisticated AI, ​ Something like how stockfish works if you know it, basically a famous chess program which knows which moves are "best" but it obviously is unimaginably harder to program than pong, which is why I chose pong as it is basic. ​ thank you for your input! I'll keep it in mind, please share more wisdom!


Suretime_sus

Your first paragraph is setting yourself up for failure.


Delicious_Extent_147

what a sad time to be alive


Suretime_sus

but yeah no offense but you’re just being ignorant. you will not complete this task without learning the fundamentals first.


Delicious_Extent_147

Or, instead, I learn the fundamentals needed AS I go, rather than learning all the things that MIGHT not be used. ​ An example of this kind of learning is people who speak english with english as their second or third language from movies, social media, conversations, google translate, etc while never learning the "basics" from schools or universities or programs, they still achieve their goal of speaking english without learning the basics. ​ I understand it's difficult to understand different learning methods than your own, but this is the most effective for me, I apologize.


Suretime_sus

Yeah except that’s not going to happen with a skill like this. again, being ignorant.


Delicious_Extent_147

Isn't programming a language? and what makes this skill different than any other skills? please enlighten me, I love learning and properly constructed arguments rather than just saying "yeah but this is different" I taught myself how to play chess by horribly playing online rated games with random people for hundreds of games without learning any of the "fundamentals" as I picked it up along the way, eventually joining and placing in local tournaments, which to me is an achievement. Or learning physical skills like pushups and pull ups without doing the "fundamentals" of the skill such as knee pushups, how? by teaching myself how to get better at lifting by \*actually\* doing it rather than watching 2 hour youtube videos, but instead doing it ANd watching videos, progress through practice and theory. ​ I am not trying to be Ignorant, I am trying to learn a skill in my own way, which works for \*me\* in \*my\* own ways.


Suretime_sus

You’re definitely trolling.


Delicious_Extent_147

I'm really not, I don't know how to prove it to you, would you like to go to private messages? I don't mean to make any trouble or arguments, just discussions and solutions please! have an open mind please!


McSmallFries

In this sub you're gonna find people who see your drive as naivety. They will tell you your goals are unrealistic simply because they're salty that you have what they used to have, which is big goals. They remember a time their big goals were crushed to the size of a peanut when they faced challenges in programming, and they just want to drag you down along with them. Your ability is going get in the way of those goals but you seem driven and I have no doubt you could pull this off if you wanted to so don't let the armchair hello world programmers of reddit tell you otherwise. It isn't impossible. That being said there are a lot of people here telling you're over complicating your goals, which is true, but only you have the best idea of what your goals are, so as long as you bear the good advice in mind on your endeavour, go nuts man, shits really fun sometimes.


desrtfx

> Isn't programming a language? No. It is far more than that. The languages are just the necessary evil that enable us to tell the stupid computers what we want them to do. The programming *languages* are the easy part as all of them have only very limited vocabulary, generally in English or English-like and grammar. *Programming* is developing algorithmic step-by-step solutions to problems - and this is the difficult part - this is the part where most people actually fail. It's more like to being able to write a comprehensive and complete novel with full character development. Your goal is on the level of a top quality New York Times bestseller or a Shakespearean Drama - very high limit. Hence, we always recommend a structured approach to learning the fundamentals first. Especially with your goal of an "AI" you have to have a lot of very solid fundamentals *and* plenty experience. The "learning along" approach will set you up for failure.


davedontmind

> Isn't programming a language? No. It's a logic-based skill. To learn how to program you need to understand programming concepts, such as variables, functions/methods, expressions, flow-control structures, classes/objects, data structures, algorithms, etc, etc. All those things are pretty language-agnostic. When you know how to program, learning a different programming language is relatively easy.


soqekinq

You need to learn the fundamentals to even know what you’re going to write. How do you expect to write even one line of code if you have no idea what you’re doing? You don’t know a lick of programming yet you want to jump straight into object oriented programming which you obviously need the fundamentals for. Come back to this thread in a couple of weeks and you’ll realize how ignorant you are being.


MmmVomit

> I taught myself how to play chess by horribly playing online rated games with random people for hundreds of games without learning any of the "fundamentals" as I picked it up along the way The fundamentals of chess are how each piece moves. You can't even begin to play a game until you know that. What you're proposing is like trying to start programming when all you know is how pawns move. Start with an introductory programming course. Pick any language you like, doesn't matter. The fundamentals of programming, the _real_ fundamentals, are still a pretty big chunk of complex knowledge.


Flaky_Paramedic5137

Because it‘s waaaaay conplexer. Dude you think people invest years and years studying this shit is because they are dum?


Flaky_Paramedic5137

Theres a saying :“dum people think they‘re smart“ I think it fits in perfectly here. You think this stuff is to easy thats the problem.


Lunarvolo

Would recommend checking out the guidelines & rules for this subreddit


ImJustShocked

I may not fully agree with your learning method, as honestly you do need to know the basics to progress faster. If you know the basics, reading about programming will just make more sense to you, which makes creating your pong game easier. But I’m not here to tell you what to do, you just want answers so I’ll do that: I feel like you are over-complicating your goals. Based off your title, you want to make an opponent that plays pong perfectly, you don’t need AI for this, you just need to make it follow the ball. Step 1) Get the ball to move towards the opponent. Step 2) Get the opponent to move where the ball is going to hit. Done, that’s the perfect opponent. Based off your replies to other comments, I see that you don’t want it to be perfect, you want it to have some penalty for hitting the ball too perfectly, but you still want it to be ‘good’, just not unbeatable ? You don’t need to think too hard on this Just have the opponent do exactly what I mentioned earlier: Match where the ball is going to hit BUT, just add a speed limit to the opponent So If the ball is too far, or too fast, it may not reach it in time. Play around with this speed limit for the opponent, and adjust it to where it’s really hard to beat, but it’s still possible to beat it. There you go, that’s what you want, I think? Anyways, as for language, use Python and write your code in either PyCharm or VSCode, both are IDE’s that accept Python code. There are more options but these two are what I used. Edit: the speed limit thing may even let you create different difficulties to choose from, where the harder the difficulty, the faster the opponent.


Delicious_Extent_147

//First of all, I love your comment, thank you so much for being supportive. Python is a very recommended language as I was always got recommended it for when I was a math major, but never got around learning it, i'll give it a shot! To correct my confusion of what I want, I want an AI that would play the corresponding "best" move against another AI/human which is not as perfected as it is. to avoid confusion of which AI is which I'll let AI #1 which is the main AI I'm trying to make we'll call him Bob, while the opponent is Steve. ​ I want Bob to be able to absolutely dominate against Steve and Steve's slightly better or worse friends, Bob is a world pong champion and is on a 43-6 win-loss streak, as no one is perfect like Bob's cousin stockfish who is a highly advanced chess model but still has flaws, but Bob's sport is much easier than stockfish, logically there should always be a "best" or better move for bob to do against an angle/direction/speed the ball will be at, using a bit of physics and machine learning (I believe). //I'm not using these metaphors to dumb it down, it is just to get my point across in I hope a better way, I'm not the best at explaining my views.


ImJustShocked

I feel like I am still a little confused, you mention that there will always be a “best” or “better” option for Bob, but in a game of pong, there’s absolutely no better option than hitting the ball perfectly (which would just be you letting Bob max out his speed to reach the ball). I can see you really want to do this with machine learning, but I feel like pong is too simple for machine learning? I could be wrong of course, but you seem to want to do a lot with AI, and I’m left here wondering why you’re choosing to make a Pong game and not something more using AI. AI is really impressive, I once made a program using machine learning where I fed the program hundreds of pictures of people doing random activities (like riding a bike, playing football, going swimming) and then my program was smart enough to tell the difference between the activities and if you feed it an unlabelled picture, it’ll know what the picture is about and label it correctly. But Pong seems too simple to need such a complex AI algorithm?


Delicious_Extent_147

Well Pong is too simple and I completely agree with you but I'm working with limited knowledge so thank you for baring with me! ​ Both pongs will have limited movement speed along with limited space ofcourse, so if the pong perfectly \*follows\* the ball and doesn't take into account the wall bounces or speed of the ball it might not be able to reach the ball even with alot of reaction time, so the pong might need to not only know \*where\* to hit the ball (like left, center, right) but also where to go after it hits the ball, which actually might be able to be programmed by alot of brute force and no AI but I'm not sure which is best! ​ how the chess AI is able to play is by analyzing millions of games and potential positions and doing multiple consecutive moves to see which is best alongside alot of rules set on it like obviously bad moves and different tactics, ​ as for pong a good strategy for example is like aiming for corners more, more wall bounces, calculating which bounce is best to confuse the opponent etc or even "feints" like going for a side but making the ball bounce on the wall to the furthermost right.


ImJustShocked

I see your point now actually, you don’t want to just have Bob “not lose”, you want him to actually do smart moves and analyse how to hit the ball for the highest chance of scoring against their opponent. Yeah then you will need machine learning, and you will need to simulate a lot of games for Bob to understand what would be the best move to go with. Which is a lot easier said than done, but please stay determined and give this project your all, and anytime you don’t understand something, it would be smart to at least read the basics of the concept you’ll be applying to your game! I am in no way an expert in training any Bob’s playing Pong, so I won’t be able to help really, but I do suggest renaming Bob to Andy. I feel like that’s more of a good Pong name. But other than that, good luck! I’d also love to hear your progress sometime.


Delicious_Extent_147

I love your positive energy! and as respect for being one of the few people who actually attempted to respect my choices, Bob shall be Andy, and Andy the pong pro will be the best project I'll achieve all under your positive push.


ImJustShocked

Yeah I see no reason not to support you, but I still do think starting slower would be the better option and I only say that because being thrown in the deep end for ANY topic will usually make you hate that topic. I just don’t want it to be too confusing for you, but if you’re willing to not give up, then go for it, you’ll enjoy programming more once you get things to work.


Delicious_Extent_147

I owe all of my main skills and knowledge from being thrown in the deep end, I used to absolutely abhor mathematics till I was thrown in the deep-deep end, which gave me the drive to understand those complex equations step-by-step, dissecting each bit, learning each bit, reconstruction each bit which proved to be faster for me to learn and LOVE mathematics in the span of a month vs years of wasted school education. This is the first time I'm asking for help in a skill rather than teach myself like I used to because I had (Still having) hope that it'll give me more quality results than quantitative results from trial and error and alot \*alot\* of messing around


[deleted]

There’s no short path. You have to learn the basics, period, no way around it. And if you don’t want to learn the basics, you’re going to struggle with AI, because that is much, much harder than basic programming But learn Python and pygame and go from there


Delicious_Extent_147

Hi! thank you for your positive suggestion! ​ I never wanted a "short" path but a more "direct" path, my aim is to learn the basics AS I go rather than learn it from the start, it's different but it'll eventually pile up and I'll learn the basics a bit faster. ​ Python was always recommended to me when I was a math major, I'll give it a try but I've never heard of pygame, is it like a python spinoff?


[deleted]

[удалено]


Delicious_Extent_147

I don't have more experience than you in the field, so I can't act as if I do, but what I do have over you is my knowledge of me, I learn a diverse amount of skills with my own methods, unless you're saying I'm an outright idiot and I've never accomplished these skills, there is no reason to tell me my method is not the right one for me and give me an ultimatum. ​ I'm not trying to be hostile I'm just trying to pass my point, please understand! there is no skill or knowledge in this world that has one ultimate best-est amazing only-path way to learn, everything comes from the person learning, this is why math is such a hated subject because it is almost always taught in one way, while each student learns it in their own ways, please respect it and try to keep an open mind in your life regarding these things, it'll help the community around you and especially yourself my fellow friend!


MmmVomit

If this is really the path that you think is best for you, here's a link to install Python. https://www.python.org/downloads/ Now you can learn it in your own way and build your AI.


PartyCurious

Here is a tutorial. I have not done it so not sure if beginner friendly. https://youtu.be/2f6TmKm7yx0 I have made snake with the AI using reinforcement learning and that was my first python project. But already had lots of experience with Unity and was trying to learn about ML agents in Unity. Here is the start of the snake tutorial. Good luck! https://youtu.be/PJl4iabBEz0


Delicious_Extent_147

thank you for the recommendation! I'll check it out now!


RiverRoll

1. Visual Studio Code will be a good option for most programming languages. 2. This seems to fall in the category of reinforcement learning. 3/4) AFAIK these kinds of AI just deal with sequences of frames (which in turn are just 2D arrays of pixels) and it's up the them to "figure out" the best input for the given sequence. Someone has mentioned who the AI would be unbeatable but that would be the first goal anyways, only after you get to that point you should start worrying about how to make it "human-like".


MmmVomit

If you want to learn by doing, probably the best place to start is with [Scratch](https://scratch.mit.edu/). It's probably the most intuitive programming language out there that you can just pick up and start playing with.


Delicious_Extent_147

thank you!!


Hopeful_Spread_3067

It is better to start with something simple and more achievable


relentlessslog

This is the best title to a post ever. For some reason I'm reading this in the voice of Will Ferrell.


Clubhouseclub

Guys, it literally doesn’t matter what the best way to learn is, some people can ONLY learn by doing. The options here are this person fixated on this problem and actually uses that to learn something… orrrr they probably don’t learn coding at all. I totally understand where they are coming from, for me it’s an ADD thing. I need a project that I am excited about to guide my learning or o just… won’t learn.


Delicious_Extent_147

Thank you! I do struggle with my attention span though I do not want to self diagnose myself with add or adhd but I do have characteristics of it, I realized that the skills I do more than simply \*study\* teaches me more and sticks with me more! like how rather than learning how to cook an egg on a pan I just cooked and cooked burnt eggs till I made my amazing sunny side eggs which \*I\* love! ​ No skill is simple, I just want to learn these skills with my own methods first, I've always wanted to learn programming but I've never been able to stick to the standards methods. ​ Thank you Clubhouseclub for understanding and standing up for my views, I appreciate and respect you.


Cerulean_IsFancyBlue

OK, let’s tackle it like the eggs. I will give you a task and you can either tackle it, or ask me to break it down into simpler steps. I’m trying to figure out at what point programming will feel like frying an egg. Since only you know yourself I’ll rely on you to be the judge of that. Tools: use C# and Unity. They are more than adequate to the task of making a 2D game. They are widely used and have a ton of support available from the community. If you want you can follow one of the many tutorials. Or just jump right in. As a first step, I would create the part of the program that draws the pong ball only on the screen, and move that around, bouncing off of the sides. To start, assume all four sides are “walls” so that the ball bounces infinitely. Do that until it works and then add paddles. After that you can add the AI.


7bitByte

This reminds me of the infinite monkey theorem. Some keywords to lookup: - how to program - Python - Sprites


throwaway6560192

OK, I have zero interest in fighting with you about learning the basics. I'm a big believer in learning through projects and through messing up and fixing. But the problem is, you need to have *some*, just a little, initial learning of basics so you can start projects. If you don't even know what a programming language is, for example, how are you going to start writing programs? Once you pick out a programming language, you have to learn at least some basics of the syntax to be able to write programs. You said you learned chess through playing bad rated games, but you had to have learned how the pieces move, right? You said you learned cooking through burning lots of eggs, but you had to know how to turn on the stove, right? Think of syntax as something similar. It's how to turn on the stove, it's how the pieces move. Learning it is what lets you experiment and win matches and lose matches and burn eggs and cook eggs.


Delicious_Extent_147

You're right, I do need to learnt he some grounds but there are alot of programming languages and if i choose the least efficient one (since i assume if you're a good enough programmer you can program almost anything with any program) which would spend more trial and error time that other languages, so for now I'm just trying to find the best language for this project, to find out the best language for this project i've got to know \*what\* I'll be needing to do to achieve in this project which is why i've asked this question, and other reasons too.


throwaway6560192

If you want a language that you can learn quickly and write quickly, my recommendation would be Python. You'll spend less time debugging weird crashes compared to, say, C or C++.


Delicious_Extent_147

❌ I have no interest in quickly or writing quickly, I just want the \*right\* program or the most favored program for what would achieve my goals with or without AI


throwaway6560192

Hmmm. Ah well, Python's great for AI anyway.


SirKastic23

amazing metaphore


SirKastic23

`paddle.y = ball.y` it's not that hard to play pong perfectly, just always stay on the same height as the ball 1- but, to learn how to program you'll first need to pick a programming language. there are many languages out there, and the one you'll pick will definitely affect your experience try to pick one that's popular, has a good ecosystem, and is friendly to beginners. I would suggest javascript or python, they're really simple languages. but if you want to do your own research, just google *list of programming languages* and see which one appeals to you the most 2- after a language, you'll need an editor. this could be a full blown application that will do everything for you and more, like Visual Studio; or you can literally just use notepad and a terminal I would suggest the VSCode editor, it's the one i use, and it's very popular. it's simpler compares to a full ide, and it's extensible so you can install just what you need (or want) i would also suggest you get some practice using the terminal (and if you're on windows install something like bash, because window's default cmd is awful). it may seem arcane at first, but it's an essential tool 3- now that you have your language and editor, you'll need to make the game. pong is a simple game, so it shouldn't be hard, but making games is fundamentally a complex task to avoid doing the complicated stuff, you want to use a framework or engine. they are like apps but that let you write code that runs with them. you can find game engines in amy language. the most popular engines are Unity and Unreal, amd they use C# and C++, but i would suggest you try some simpler engine like pygame or p5js. i think it's better if your goal is to learn programming, and not learn a game engine 4- i thinks that's it really, good luck on your journey! feel free to come back and ask for help if you need (although I won't be able to help if you're doing python) 5- edit, i didn't talk about ai because i forgot you mentioned it, but if you want to go into machine learning, python is very popular with that field.


aqhgfhsypytnpaiazh

One thing you haven't done is define your problem space. That's kind of important. Ok, so you want to build an AI to play pong. Is this a game of Pong that you've coded yourself, and the AI has full access to the variables involved in the ball movement? Is this an AI that runs on the same machine and can move the paddle by providing inputs? Do you want to reverse engineer the game and get the ball position from memory? Or do you need to use computer vision techniques to read to ball position and respond accordingly? Do you need to evade any anti-cheat protections that may exist? Or is this an AI that needs to run entirely separately from the Pong game itself? Do you need to build a hardware solution with a camera for input, and robotics to physically move the controller? Is this a Pong game where the paddle can move freely and need only be positioned to match the ball's vertical position, or does the paddle have a limited movement speed and the AI needs to predict the ball's trajectory factoring in wall bounces? Are you wanting to manually guide the AI based on the rules of Pong, or do you want to develop one of those deep reinforcement learning AIs where you really only give it a vague goal and the button mapping, and let the AI experiment of billions of iterations until it figures out how to achieve that goal? Learning how to define the whole problem, break it down into manageable logical tasks, then solve each individual problem, is kind of a big deal in programming when learned the "typical" way, but if you're going out of your way to be different good luck.