Advertisement

I'm looking for help creating/researching an AI/bot for my game.

Started by March 31, 2023 07:31 PM
5 comments, last by Bigalan09 1 year, 8 months ago

Hello.

I'm looking for some help creating an AI for my game (see below for game rules)

Currently the game is written in C# as a console app and I have 2 human players capable of playing each other. The next step is to create an AI that is capable of playing against a human.

I'm ideally looking for pointers in the right direct to solve the problem. I have implemented a DAWG for the word dictionary which accepts an array of char, if an element in the array is a blank char it acts as a wild card for the DAWG.

My issue is I don't know how best to go about using that. At the moment, it's very random and I populate the grid columns with random words. It's not optimal and it's very easy to beat this “AI”.

Thanks in advance!

---

Rules

**Premise**

WordSquare is a 2-player turn-based word game played on two separate 5x5 square grids, one for each player. The objective of the game is to score the most points by forming valid English words with adjacent letters on the grid.

**Objective**

In WordSquare, the objective is to score the most points by forming valid English words with adjacent letters on each player's individual grid.

**Turns and Actions**

On the first turn, the first player chooses any letter and places it in any empty cell on their grid. The first turn consists of only this one action. For all other turns, each player takes two actions:

1. Place the letter chosen by the opponent on the previous turn in any empty cell on their grid.

2. Choose any letter and place it on their grid in any empty cell.

Players do not see their opponent's grid, and only learn the letter chosen by the opponent in the previous turn, but not its placement.

**Game End**

The game ends when both players' grids are completely filled.

**Scoring**

In WordSquare, points are awarded for each unique word formed by connecting adjacent letters horizontally or vertically on a player's grid. Points are based on the length of the word:

- 3-letter word: 3 points

- 4-letter word: 4 points

- 5-letter word: 5 points

Only words that are valid English words found in a pre-existing dictionary are eligible for points. The maximum score achievable is 50 points.

Perhaps you can record and replay what the AI does. While doing that ask yourself what you would have done instead. Find out *why* you'd do something different. That should at least give clues where the AI goes wrong and the kind of reasoning it is not doing.

Advertisement

Here is the code if of interest. I've removed the AI because it's not clean code.

https://github.com/Bigalan09/WordSquare

@undefined This is great information, but still doesn't help in this scenario, well it does if you brute force a solution. However, brute force is slow!

Simple brute force is easy to program, but takes eons to complete very soon. Fast brute force takes a lots more effort and thinking, usually much more than you'd need for a normal program.

However, while brute force technically solves the problem, it also kills the game against AI. Nobody likes playing against an opponent that (almost?) always wins. (It's very hard to impossible to win if the opponent is playing optimally.)

@undefined I agree! There has to be an element of random and “fun”. I think for me is finding the optimal solution first, then dumbing it down?

Or is it better to start from simple AI, and work your way up to smarter AIs?

The main goal will ultimately be performance lead AI. I don't want a player waiting >10 seconds for a response and I also don't want it to be so easy that players get bored,also goes the opposite direction where I don't want an AI that's unbeatable.

I also think one of my end goals for this game is networked with human players playing each other over the network and so the AI aspect is more for me to learn as a challenge for myself.

This topic is closed to new replies.

Advertisement