Log In  

Cart #41516 | 2017-06-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

Isola is a board game (sometimes also known as Isolation or Solitude). After my last cart I decided I wanted to try a puzzle game or some kind of game that wasn't action oriented. After doing some research I found Isola, and it seemed like I could program an ai for it pretty easily. So I did. This was my first experience programming an ai that adapts to the player's moves. My previous game was a shooter with set motion and random starting points for enemies. It was an interesting experience. I think I'd like to try more complex move trees and point systems for a cart at some point.

The ai will not likely challenge anyone for long, but it will win games against casual players and should be a mild challenge for first timers with Isola.

The rules are included in the cart. Games tend to go pretty quickly. The two player mode uses only one key set and just swaps what piece that keyset controls. I can add alternate keys if people want.

This was a quick turnaround and I was well under the token and size limits, so I have not optimized the code much at all, but it should be mostly clear what is happening for anyone that is curious.

I hope y'all enjoy the game!

Update 1: I fixed a situation in which the computer opponent would cheat. The only other change I may make would be to improve the ai's play when destroying tiles...but it performs alright at present, so I may just keep it as is.

Update 2: In response to user feedback I have made it so that either X or Z can be used to move/destroy a tile. Rather than having those two things separated out (one for each button). I have also done a very mild improvement to the ai. It will now score the available destructions and when there are multiple with the same score it will pick randomly from them. The previous behavior was to always pick the first one (which made play more predictable). I still plan to improve the ai more and will potentially add an easy or hard mode (though with the present code structure for the ai, Im not sure how hard it will really be, but it will be better than the easy mode version).

Update 3: Hopefully one of the last updates for awhile. I have slightly improved ai performance. When possible it will prefer to destroy a tile that is useful to the player, but not useful to itself. It still does not see the board or game in their entirety, only move sets....but this should increase its difficulty a fraction. I would think that most decent players will win at least 60-70% of the time. I think this should be a good game for kids or people that do not play a lot of abstract strategy games though. I may return to it at some point to re-structure the ai, but for now this will do for what I was wanting to achieve/learn. Thanks in advance for playing.

P#41361 2017-06-07 16:58 ( Edited 2017-06-10 17:17)

Nice gameplay. I won against the ai multiple times by trapping myself near the ai to prevent ai's movement in the last turn.
Also about the control, I think it is better if moving piece and destroying tile are in the same button instead separated, especially both aren't active in the same time and it will be less hassle for finger.

P#41371 2017-06-07 22:49 ( Edited 2017-06-08 02:49)

Good feedback. Thanks! I can modify it so the player can use either x or z to place a move/destroy a tile and it just does them in order: move then destruction. I'll try to get that updated soon.

As for defeating the ai that way, one of my goals would be to have the ai take its own movement losses into account when destroying a tile. At present it tries to reduce its opponents tiles, but doesn't take its own open spaces into consideration during that process. I'll add that into its decision making process soon too.

P#41374 2017-06-07 23:42 ( Edited 2017-06-08 03:42)

You're welcome.
About adding more mechanism on AI, now that's open for AI difficulty addition (I mean like Easy, Medium, or Hard).

P#41376 2017-06-08 01:23 ( Edited 2017-06-08 05:23)

@NeithR: I updated the buttons so that either button can be used for either action. I also made a small improvement to the ai. If I can make the ai sufficiently better to warrant an easy and hard mode, then I will add that in the future (I have some ideas re: how to go about it).

As an aside: I loved your game (I posted on it's thread as well).

P#41394 2017-06-08 12:02 ( Edited 2017-06-08 16:02)

I think there might be a glitch in the AI now.

Sometimes it seems to hang on the destruction phase.

P#41415 2017-06-08 22:24 ( Edited 2017-06-09 02:24)

@sloum:
Thanks. Felt better now with the control after playing it again ;). Also thanks for playing my game ;).

Also, as apLundell said, there was a hang on the destruction phase. I forgot to screenshot it though.

P#41426 2017-06-09 02:37 ( Edited 2017-06-09 06:37)

@apLundell: I had noticed that once or twice as well, but was unable to reliably replicate it. I think it should be fixed now with my most recent update (which specifically worked on that phase of the game), but if you (or anyone else) notice it again, please comment and let me know.

@NeithR: Thanks for playing it again! As I said to apLundell, I think the destruction hang should be fixed.

Just in case though: does it hang or toss an error? If it tosses an error can you post what line it hits the error on? Thanks!

Update: I just had it hang in the browser, but I have never had it do so when run from Pico-8 on my system. I'm wondering if there is an issue with how it adapts tot he browser version? Or maybe I just have not been able to perfectly replicate the game conditions. I'll keep looking into it. I noticed I was using a local variable in a way that I'm not sure actually was working. So I have made said variable global. I'm hoping that will fix the issue. The cart on this page has been updated with the new code. I'll keep play testing and see if I can get it to hang again or not.

P#41466 2017-06-09 11:14 ( Edited 2017-06-09 17:47)

I have gotten the destruction phase hang a number of times now, both in the browser and in the app. I have modified the time conditions to be >= instead of equal to...just incase it isnt getting the tick at the equal point for some reason. I have also taken away the time randomness for the destruction phase and hard coded it to take a second and a half. I'm hoping that this helps. If it doesn't then that means it is an issue in how the ai's tile destruction choice function works and I'll have to figure that out. I can't currently think of any place in the code that would specifically cause that issue....but I can likely build in some kind of failsafe to prevent the hang if necessary.

P#41517 2017-06-10 13:17 ( Edited 2017-06-10 17:17)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 10:03:22 | 0.062s | Q:28