How to make AI

I don’t know how to make AI. But I want to in Microsoft MakeCode.

6 Likes

What kind of AI, one where they randomly walk around or, like wait for the player to get close. Ect. I can totally help with this.

3 Likes

I made a handy AI Extension for that!
I can also answer any questions if you have any : )

4 Likes

I have 2 ideas for what I want. One AI which does in fact walk around but also shoots enemies and says quips. Another would be one similar to Akinator. My school blocked to use of searching anything up using “AI” so I have no idea how to do it and my Computer Science teacher wont teach me how.

1 Like

How do I use the extension? I’ve tried to use it but I don’t know how to navigate it.

2 Likes

Ah, sorry! You’re looking for enemy AI. That extension is neural network AI, whoops!

1 Like

I have no Idea how you would be able to make Akiniator, (It would probably be very complex.) However I can totally make the projectile-shooting enemy. I made a little demo.

The AI walks around randomly (The skeletons) using a path finding algorithm. When the AI finds the player it will shoot asteroids at them. Sometimes they will even say little quips. Click edit code to open the code up to see my comments and how it’s coded. Don’t worry about the “Namespace user config” at the beginning, it makes the screen bigger for the example.
Her are the extensions involved.

https://github.com/felixtsu/pxt-sight - lets the enemy see you.

https://github.com/jwunderl/arcade-tilemap-a-star - Path finding

https://github.com/jwunderl/arcade-sprite-util - utility

Let me know if this is not what you wanted.

2 Likes

You could do this

1 Like

1 Like

well is possible to make a AI but instead of moving it would text almost like replying to the text its given

1 Like

Generative AI, like ChatGPT, is not possible in Makecode as it requires massive amounts of data and servers to train, and even running it locally requires more resources than Makecode has. The closest you can get to real “AI”, aka neural networks, is something like @randomuser’s extension (mentioned above) or my Cars with brains project, but generating text is something you cannot do in Makecode.

2 Likes

well what about a small ai that is given a words like a pumpkin is blank and it goes thro all the words to at one point get it but that also might not work so would it work to connect your game to a like AI like I don’t use python but cant you do like import OpenAI or something

1 Like

The limit is the number of words you can physically store. When @AlexK made his What’s My Word? Wordle clone, he included over 2000 words, and that’s only the 5 letter words! You would run out of space eventually.

No you can’t “import OpenAI”. You have to pay to use all those APIs, so if you’re willing to pay up then be my guest. And they are pay-per-use, so every time someone played your game it would cost you money.

1 Like

To answer the first senario, if I understand correctly, that wouldn’t work; Not because the theory is wrong, but just because MakeCode can’t store a neural network that large and complex, or compute it in an reasonable amount of time.

The same is true for the second, as importing an AI database is theoretically possible, but again too large and resource-intensive for MakeCode :slightly_frowning_face:

Although, there were definitely early adventure games that had the game reply to (or do some action because of) the user’s text, using very little processing power or storage! Each game really had a different method, but there’s a great thread on reddit here to get you started on some different methods.

From there, I think this may be what you’re looking to create:
A simple noun-verb parser would be the easiest option. This example is written in C but definitely shows the theory behind the parser well. In MakeCode, you’d likely create a program to decide which verb and which noun a player was trying to use, then run it through an ‘if’ statement to decide what the program should do with that information.
For example: If the player told a character to ‘run west’ it would understand ‘run’ means to set velocity very high and ‘west’ means that velocity should be towards the left.

Let me know if this is what you were looking for! The idea of a verb-noun parser in MakeCode is very interesting to me. :eyes:

well i had a texting game that i wanted to have a ai to reply to

1 Like

so technically if I pay I can do this also with GitHub and coding stuff could there be something like it thats free that someone made

1 Like

also could it be possible to put all the like pain/lag into something that could do it also what about vs code I don’t really use it or know what I’d use for but

1 Like