ZX Collection Vol #1

Started by Qube, January 26, 2019, 02:33:36

Previous topic - Next topic

MrmediamanX

AI? yikes ... my usual method is generally move,attack,stop,reset or rush,retreat,reset.
if it's anything beyond that ... i'm out. 
It's a thing that doe's when it don't..

Qube

Quote from: Steve Elliott on February 15, 2019, 15:28:34
Ooo AI.  I've just gone for a simple fun quirky game I liked on the old Speccy - and re-visited it; so no need for such coding.  Good luck with the problem, I'm sure you'll crack it.
It's only for a small part of the game but I fancied having a crack at it ;D me and my stupid ideas :P. Think I'm on the right track now though as I appear to have had a bit of an early breakthrough thanks to shoving a load of debug info on screen.
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Steve Elliott

Quote
It's only for a small part of the game but I fancied having a crack at it ;D me and my stupid ideas :P.

That's partly what the competitions are about IMO - to learn new things.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Xerra

I've got AI at the back of my head constantly, even though I'm a long way from putting other cars on the road in my game. I don't actually have a road for starters - the one I showed before was a tiled dump of the NES original game. In my head I've got rough ideas how the different cars should interact but I wouldn't start until collision detection was in so the road can be the extra weapon.

A state machine is going to probably be the way because they have to lose control for a while, rather than driving along doing whatever they should be doing, and also they need to move with the road so it appears they are accelerating to keep up with the player and do nasty things - unless they're not an enemy, of course.

All sorts of stuff to think about - not looking forward to it but i'm sure it will come together when it's time to start.
M2 Pro Mac mini - 16GB 512 SSD
ACER Nitro 5 15.6" Gaming Laptop - Intel® Core™ i7, RTX 3050, 1 TB SSD
Vic 20 - 3.5k 1mhz 6502

Latest game - https://xerra.itch.io/Gridrunner
Blog: http://xerra.co.uk
Itch.IO: https://xerra.itch.io/

DaiHard

Sometimes the interesting thing with AI is working out how BADLY you want it to play! It's no fun competing against a perfect opponent -you are bound to lose. I think I first realised that with a moon lander program in the 80's: in the end I think I programmed it to land with something like a 10% safety margin, giving me JUST enough scope to beat it, if I played accurately...

:-)

D

Qube

I'm making some good progress and 60% of the time the AI is making good choices. This leads me to believe there are some tiny logic bugs in my game code which build up and sometimes result in a bigger error outcome. I think as things stand now I need to somehow visually output every choice made by the code so I can see where it's failing ( knowing my luck it's a stupid mistake )

OK... As a small part of the game I'm doing you can play a custom Speccy version of Puyo Puyo and it's you vs the computer. It's probably not the easiest of AI's to code if you've never really done this sort of thing but I do love a challenge ;D

The basic idea of Puyo Puyo is to match four or more blobs of the same colour together and also make chains ( 4+ the same colour explode, board falls down and creates more 4+ blobs, etc etc ).

Currently the AI side looks for the best match across the columns ( including rotations of your two pieces ) + takes into account the effect of such action, i.e. the knock on effect of creating chains. If you watch the YouTube video you'll see that there are quite a few things for the AI to decide, eg, position, rotation and knock on effect. I also assume that greater AI's would use the upcoming colour combinations to work out the best scenario but all I'm after is a pretty decent CPU player and not some master wizard who never makes a mistake.

But as it's not always accurate there is definitely a bug or bugs somewhere in the logic. It's driving me absolutely nuts but I'm determined to sort it. I'm giving it the weekend to sort out but if by Sunday evening I've not figured out what's wrong then this side will be ditched, but I will come back to it after the comp as I refuse to fail :P

As said in a previous post, coding AI is not my thing but as it's a weak area of mine I thought I'd dive into a challenge ( as I like to do with the comps ) and it's been good to take a task and break it down into as simple as possible logic steps. Should've picked something like connect-4 / tic-tac-toe but that would have been a cop out.

I probably shouldn't be spending this amount of time on a small part of my game but I'm like a dog with a bone when I start things :P
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

3DzForMe

@Qube
QuoteAlthough there are some Spectrum games that do colour clash as per the video above. I wanted to do the other method which turns out was harder to do but luckily managed to get it sorted. Faking this stuff is madness on modern tech :P

Colour clash test 2 - The correct way, go speccy go ;D
Wow, you're attention to detail with the colour clash is such great attention to detail, kudos.

@col...
QuoteAhh the good ole days :))
I'm sure that description was as confusing as hell itself so here's a loading screen on Youtube showing the data being loaded sequentially straight into the screen memory location.
Its funny how the old grey matter works (or doesn't) I was genuinly thinking of invoking a screen loader of a similar nature to the Hobbit (but a lot faster... real time tape loading was defo for the eighties. Yep, blowing the 'authenticity' of the spectrum out of the window.) Maybe I could make up for it by prompting 'Select your tape players volume' inside a randomizer, so every time you try to load the game, you need a different number. Too much?

@Qube
QuoteI probably shouldn't be spending this amount of time on a small part of my game but I'm like a dog with a bone when I start things :P
I'm sure it comes from coding on the Speccy, gives you tendencies to go that extra mile ;)

BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

Qube

QuoteWow, you're attention to detail with the colour clash is such great attention to detail, kudos.
QuoteI'm sure it comes from coding on the Speccy, gives you tendencies to go that extra mile ;)
I like to add new challenges when doing a comp entry to push myself to do new things ;D
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Derron

Regarding that bug and how to tackle it:
- instead of "random" use a mersenne twister pseudo random generator for everyting "not an effect" - so which blob colors are selected for new "blobs", for moves of the AI.
- let both players be played by the AI
- on game start set a fixed "seed"

That way you can play the same game over and over and see what happens if you change something (from that moment on the game might differ). This works as with mersenne PRNG and a fixed seed the random numbers are known in advance - and will always be the same on each restart. So if everything is based on this random numbers it will "play the same game". Nice to checkout stuff.


bye
Ron

Qube

Quote from: Derron on February 16, 2019, 19:41:33
Regarding that bug and how to tackle it:
- instead of "random" use a mersenne twister pseudo random generator for everyting "not an effect" - so which blob colors are selected for new "blobs", for moves of the AI.
- let both players be played by the AI
- on game start set a fixed "seed"

That way you can play the same game over and over and see what happens if you change something (from that moment on the game might differ). This works as with mersenne PRNG and a fixed seed the random numbers are known in advance - and will always be the same on each restart. So if everything is based on this random numbers it will "play the same game". Nice to checkout stuff.
Yeah, I just went for the easy route of putting numbers into an array so the game always plays the same and makes the same mistakes / errors so I can pin down the issue and know when it's fixed :)
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Qube

Woohoo, got the AI to work \o/ - Plays a pretty decent game so that's me done on that side ;D

Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Rick Nasher

Good to hear, but don't get ahead of your powers for you might turn into Dark Helmet.   ;)
_______________________________________
B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

chessish


therevills

Quote from: Qube on February 17, 2019, 16:54:11
Woohoo, got the AI to work \o/ - Plays a pretty decent game so that's me done on that side ;D

Screenshot or it didnt happen  :P

Qube

Quote from: therevills on February 22, 2019, 23:46:24
Screenshot or it didnt happen  :P
Lol a screen shot won't show the AI in action :P - Also my Speccy version-ish of Puyo-Puyo won't win any graphical awards as I'm aiming to keep all the graphics very basic on purpose. As it's just a small part of the overall game planned I don't think it'll be worth posting any screen shots of it as it's so basic looking compared to the other entrants screen shots and I don't want to give a false impression of the overall game ;D
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.