AI Project Help

I took a look at it a bit ago, I didn’t have enough time to find the problem, but I did notice that you have two variables for each card. You could have more cards and less code to check the codes (and less code is often better) if you used an object as a list of cards, where each clone represents a card. I’d also recommend making the ai seem to every other object to be a second human player with full controls, so that the only ai specific code is in choosing what to do, not in responding to what the ai wants.
For example, when the ai plays a card, have it tell some other object which exists only to play cards to play the card for it. This object will remove it from the list of ai cards and add it to the current card pile. The player controls would tell the same object to do it, and the object would not be able to tell the difference between the ai and an actual player, and it doesn’t need to because to it, they are identical.

If you do this it will make your code more organized and easier to fix, as well as easier to customize the players (2 players? 2 ais? More than 2 players? If you do it right, that wouldn’t be too hard to make)

The main way this relates to the problem you are having is it takes a card from being something that is different but similar for every card in the game to being something that is basically the same but with different values for a few variables. It also reduces the check once ifs needed, which is definitely a plus.

6 Likes

It could be you are setting c1c/c1n back from -1 without realizing it. Or any of the other variables, just c1 is what I saw first.
Edit: Although I think that they are only set in the when game starts so that is probably not it.

3 Likes

What is an Al?

3 Likes

Artificial Intelligence
Wikipedia

2 Likes

AI stands for artificial intelligence, and, according to Wikipedia, Is ”Intelligence demonstrated by machines, in contrast to the natural intelligence displayed by humans and animals.”

any device that perceives its environment and takes actions that maximize its chance of successfully achieving its goals.

This splits into many sub categories, such as machine learning, deep learning and reinforcement learning, among others.

In its most simplistic style, AI is programming a computer to make its own decisions, or basically making a computer brain.

3 Likes

detailed explanation

2 Likes

:woman_facepalming:t6:

I knew that already!

Also, I got confused and thought that they said Al, as in AL.

3 Likes

Ahhh, mistook the uppercase I for an lowercase L

Glad to help either way I guess.

3 Likes

Ok. Sorry about how long this took me to reply. I didn’t have time yesterday. I sort of understood most of that. Would it really be any simpler than what I currently have if I had an object that played all the cards? I managed to fix the -1 bug.

1 Like

Great. Is there any other problem?

It would be simpler if you move everything that changes the current card into a single place, yes, but it might be easier to continue with what you have if you found the bug already and don’t expect to have trouble finding more.

1 Like

There’s one other bug where the AI will play a completely random card, but it’s pretty rare. The rest of the bugs are probably going to come when I make it so you can scroll through your cards (once the draw card feature is available).

1 Like

How do you know it is random?

2 Likes

I don’t. I’m just assuming it is. On a rare occasion it will play a card that has a completely different color and number than the previous card. I’m not sure why it does that.

On another note, do you know how I could make it so you could draw an unlimited amount of cards, and the AI also could?

1 Like

Yes, I do!
I’ve actually done something similar in my scrabble project.

First, you need to redefine what a card is. Currently it is two times the amount of cards variable, card n color and card n number. Each card uses different variables, and requires different code to use.

But each card ony uses 2 variables each, color and number. So lets say that instead of 2 variables floating around, only associated with each other by their names, a card is an object. To create a card, we create a clone of some object. This clone is a card. It has a self color and a self number. You set it to the correct amount of colors/numbers then shuffle the order the clones will be drawn in, assuming they start outin cloning order, which should also be used to determine what card it is. When a card is drawn, you remove that card from the undrawn cards and add ot to the player who drew it’s cards.

Try to figure this out, if you have trouble coding it let me know and I’ll explain a little more.

2 Likes

Oh, ok. That makes sense. Can I have a link to your scrabble project? Thanks for all the help!

1 Like

I can’t find it. It’s either filtered or I never published it. I assume it’s the second option, since I don’t think I ever finished the design. I’ll search my drafts for it.

2 Likes

It’s all right, you don’t have to.

Yes he does

2 Likes

Wow this is complicated to implement…

1 Like

Not really. What are you trying and what are the main problems?

2 Likes