CCG Tutorial Game Mechanics vs AI

Hi,

I’m going through Brian Broom’s CCG card game tutorial. Thank you I’m learning a lot about card layouts and animations. But just wondering about game mechanics. You know like, if statements when players reveal cards to each other, adding scoring and winning conditions. Are there any such lessons? And lessons how to create a game against the AI?

Cheers
h

Hi @zwolf,
I am not sure if there is a generic AI code that can learn or solves most gameplay. Here’s part of my journey (which started somewhere in the early 90’s). It started with the simple game of Tic-Tac-Toe or XO or Noughts and Crosses (whichever you know the game as).

At first I had an AI that played random moves and if the cell was empty, chose another random cell. It had no concept of a tactic.

As I learned, I had another go at the AI, this time it was based on analysing the game moves and playing to block the player. This was aggressive but would block the player and hence could also lose at times.

Then I tried with the case of winning than blocking, so it would play a winning move if there was none, then a blocking move and if even that did not exist, just a random move.

Now altering the strategy could have AI players of different types.

That is how I learned, there were no forums and books available at that time. I hope this has touched upon what you are after.

Cheers,

Thank you Jayant,

I will keep learning chipping away at learning swift :slight_smile:

Btw could you answer this particular question:

I am trying to add sound to a sequence.

First, in GameScene.swift in func didMove (after creating the mySprite of course), I added the property to the sequence:

let demoAction = SKAction.move(to: CGPoint(x: 450, y: 300), duration: 3)

let growAction = SKAction.scale(to: 3, duration: 3)

let dialogueOne = SKAction.playSounfFileNamed(“DialogueOne.m4a”, waitForCompletion: false)

let sequence = SKAction.sequence([demoAction, growAction, dialogueOne])

mySprite.run(sequence)

…and this didn’t work.

Then in GameScene.swift I added the property (globally):

let dialogueOne = SKAction.playSounfFileNamed(“DialogueOne.m4a”, waitForCompletion: false)

and called it at the end of the function:

let demoAction = SKAction.move(to: CGPoint(x: 450, y: 300), duration: 3)

let growAction = SKAction.scale(to: 3, duration: 3)

let sequence = SKAction.sequence([demoAction, growAction])

mySprite.run(sequence)

self.run(dialogueOne)

…this also didn’t work.

I also imported AVFoundation in both GameViewController.swift and GameScene.swift btw - not sure if this was necessary.

The sequence works without the sound. How can I add sound to a sequence?

This actually relates to the book 2D Apple Games by Tutorials which I’m reading at the moment. I can’t post a question on the book’s forum for some reason.

Thanks in advance

h

I solved it. I just changed the MySound.m4a extension to MySound.wav and now it works.

This topic was automatically closed after 166 days. New replies are no longer allowed.