Card Game - AI Woes

Get help using Construct 2

Post » Fri Nov 23, 2012 6:26 am

Hello everyone,

This is my first post so please be patient with me. I have been using C2 for the past few months and have leaned heaps in this time toying with many different kinds of projects (platformers, smups, adventure games etc) and have decided to do my first full app to completion on a card game I play with my kids. I am planning on publishing this to IOS to begin with if I can get it to work...

The rules are simple, the first player who discards their entire hand wins. There are 4 players (1 human, 3 AI), and you discard numeric values, each player discards the same value +/- 1 as the player previous. The twist is you can lie about your discard. So you can put an Ace down and say it was a 5 etc (up to 4 cards at a time). But if you get caught lying you pick up the entire discard pile.

To allow this to happen in the interface I have your hand where you select the card/s to discard, but before you click 'DONE' you must click one of the icons in the row at the bottom of the screen (should be clear when you see it). I haven't done the tutorial so sorry if it doesn't make sense at the moment.

What I've done so far which works.
    - shuffle and deal cards
    - reorder hand
    - player hand browsing
    - player card selection and discard
    - assign face value to each card


What I can't get to work.
    - compare AI hands to discard and take appropriate yet random course of action. e.g. place their cards down or call 'CHEAT'(it freezes at the moment but I did have this kinda working a while back but I don't know what I did to kill it...)


I have been stuck at this stage for a week or so and I don't know how many different ways I can try but I've tried more than I care to recall.

Also, I don't know how to attach a capx so if you would like to lend a hand (also let me know how to get you the file) please let me know. None of the art assets are done so it is very poor in aesthetics right now.

Thanks for taking the time to read this post.

Brett
B
5
Posts: 19
Reputation: 513

Post » Fri Nov 23, 2012 6:33 am

Worked out how to get my public folder back into Dropbox.

Here is the link to the capx.

http://dl.dropbox.com/u/31121080/Cheat%20-%20Stuck.capx

Thanks again!

Brett
B
5
Posts: 19
Reputation: 513

Post » Fri Nov 23, 2012 7:49 am

Ah man. I wanted to look into this. But you have a custom plugin. I try to just help Vanilla C2 projects as it becomes too difficult to download every plugin people are using.
B
20
S
4
G
2
Posts: 124
Reputation: 2,482

Post » Fri Nov 23, 2012 7:54 am

Hi IsometricRobot, is there a way to save without the plugin?
B
5
Posts: 19
Reputation: 513

Post » Fri Nov 23, 2012 8:07 am

I'm sure you could make a temporary copy of your project and just remove the plugin from the second copy. It looks like the plugin is some Font plugin that I get the warning about. the game may not work properly, but that should not really affect the section in question.
B
20
S
4
G
2
Posts: 124
Reputation: 2,482

Post » Fri Nov 23, 2012 8:10 am

I know what the plugin is, SpriteFont. All my text is done this way as I don't want font issues with the app. :(
B
5
Posts: 19
Reputation: 513

Post » Fri Nov 23, 2012 8:12 am

Will try to get a capx done without the plugin for testing purposes.
B
5
Posts: 19
Reputation: 513

Post » Fri Nov 23, 2012 8:50 am

Alrighty, a no-plugin version has replaced the SpriteFont capx. The same link should work with the updated file.

Brett
B
5
Posts: 19
Reputation: 513

Post » Fri Nov 23, 2012 10:43 am

Hmm,


I have never had much luck using Blank Sub-Events to regulate OR events into a focused action.

perhaps you can drop the or statement condition down to the sub event while providing a simple event to trigger when that check is performed (like a Boolean).

Condition NPC1TurnToCheck = True   - Action Set text Player 1 is considering your move.
Action wait 2.0

Sub condition (the or statements) - action Set text Player 1 says Cheat!
Action set call_cheat to 1
Action set Player_Cheat to 0
B
20
S
4
G
2
Posts: 124
Reputation: 2,482

Post » Fri Nov 23, 2012 12:18 pm

Thanks so much for your help IsometricRobot!

It didn't fix my issue but I managed to halve my AI code after your suggestion twigged an idea.

Subsequently I found the freezing issue which had nothing to do with the AI, lol. I must have dragged a condition to the front of the script which stopped progression when the player 1's turn was up.

It happens with mouse driven interfaces I suppose, I'm so used to typing all my JavaScripts at work I didn't think that the issue could have been put down to an accident like this.

Now I can start debugging the AI without the script freezing! Thanks so much again, I'll remove the capx from Dropbox now because I should be OK from here on!!!

Brett
B
5
Posts: 19
Reputation: 513

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest