crossword puzzle in php

ChatGPT vs Google Bard: Can they write PHP code for a crossword game?

In this article, I compare the capabilities of ChatGPT and Google Bard in generating PHP code for a crossword game.

I recently tested both platforms by requesting them to create a small application that utilizes Latvian words. The goal was to develop a crossword puzzle-type game where players need to find words in a grid. However, both tools failed to deliver the expected results, opting for a “word finder” instead of a crossword puzzle.

My overview of experience with each tool and explores their limitations in generating accurate PHP code for the game. Let’s dive into “text to code” world!

Version from ChatGPT

When I started my interaction with ChatGPT, things didn’t go perfectly right away. It took a few back-and-forth prompts to get it to understand what I wanted. It demonstrated the capability to retain information from previous questions, which helped in refining the details of the game.

Crosswords game in PHP with help of ChatGPT
Crosswords game in PHP with help of ChatGPT. PHP output.

List of generated Latvian words

ChatGPT’s generated list of Latvian words exhibited some inaccuracies. It included non-existent words and combinations, necessitating manual clean-up.

It was like having a chat with a witty friend who knew how to adapt to the situation. However, ChatGPT’s list of generated Latvian words had a mix of weird and made-up ones. I mean, who knew Latvian had its own fantasy vocabulary?

Though I must admit, it did hang a few times during the process, but with a little encouragement, it finally delivered a lowercase list of words upon clarification.

Selection of the length and width of the area

The originally proposed code did not specify the length and width of the field. It varied, but most often the length was of the longest word in the list.

With ChatGPT we tried

  • 100×100 symbols. Too big.
  • 50×50 was also too big.
  • 30×20 is already closer to the desired size and a reasonable number of words.
  • In the end, as you can see in the picture above, it looks like 25×25 for 50 words is OK .

It should be mentioned here that the size of the area depends on the number of words.

Does the PHP code provided by ChatGPT work?

Partially. If we do not take into account the fact that the choice of words in the Latvian language should not be relied on, then the final code is also not very accurate. Here and there the ends of words are torn off or another word is inserted in the middle of another word

Google Bard attempt

Google Bard, the fresh-faced competitor to ChatGPT, promised a lot of excitement. Google Bard faced several challenges in fulfilling the requirements. Google’s Bard is answer to OpenAI ChatGPT. Google Bard has only been out for a few days (less than a week as of this writing).

Crosswords game in PHP with help of Google Bard
Crosswords game in PHP with help of Google Bard. PHP output.

It is not available in Latvia and the entire European Union. I have access. If the first impressions, after 4 tests, were OK, now when I start something practical, it is already clear, at least about the use of Bard for PHP programming purposes, will not be usefull.

Bard lacked support for Latvian and other smaller languages, which posed difficulties in communicating the game’s specifications.

I had to convince Bard to speak English, and even with simple tasks like converting words to lowercase. Language barrier.

Furthermore, Google Bard struggled with designing the dimensions of the grid and arranging words vertically and horizontally. Bard just didn’t get the memo. It stubbornly stuck to horizontal placements only.

Maybe with some more patience and finding the right words to prompt Bard, things could have improved, but alas, it wasn’t meant to be this time. Playing around with the grid size didn’t help much either.

Does the code offered by Google Bard work?

Similar to the case of ChatGPT, the answer would be no. Partly. But if you look at whether the code completed the task – no. As can be seen from the derived solution, here too words are formed that are not at all in the original list, e.g. “apcat”.

Google Bard need to lear writting code.

Summary: the Code Verdict.

Now, let’s talk about the PHP code generated by both tools. Spoiler alert: neither of them nailed it.

The code produced by ChatGPT had its share of issues, like missing word endings and words awkwardly inserted into others. It was like a crossword gone wrong, where “apcat” became a legitimate word. Despite its limitations, such as difficulty in understanding complex queries and inability to separate words, ChatGPT showcased better code generation capabilities.

As for Bard’s code, well, it was another wild ride with inaccuracies galore. It seemed to have a mind of its own, conjuring up words that never existed in the original list. It’s safe to say that Bard needs a crash course in writing good code. Talk about a creative imagination!

Google Bard lack language support and a strong understanding of programming concepts. While it provided more up-to-date information from the internet, its limitations outweighed its benefits.

If I had to choose a PHP programming companion for the moment, ChatGPT would be the winner.

ChatGPT could not give a precise answer in other conversations, but for now is more useful for formulating and summarizing an idea. Perhaps ChatGPT gives better code results because it has access to the Github code repository- You know Microsoft/Github Copilot.

But hey, they’re free tools, so we can’t be too picky when one desn’t want to pay per tokens (in ChatGPT case)!

Where’s the Game, You Ask?

Unfortunately, the crossword puzzle game isn’t available to the public just yet. I still have some bugs to fix, some security improvements to implement, and a few more integrations to make the game truly captivating, even after playing it a few times.

But hey, if there’s enough interest out there, I’d be more than happy to launch the crossword puzzle and let everyone enjoy the word-hunting adventure!

So, stay tuned and keep an eye out for updates. Who knows, you might soon find yourself immersed in a thrilling crossword challenge with Latvian (or English, or…) words.





2 responses to “ChatGPT vs Google Bard: Can they write PHP code for a crossword game?”

  1. […] Hint. You can read article here: “ChatGPT vs Google Bard: Can they write PHP code for a crossword game?“. […]

  2. […] My ChatGPT vs Google Bard first code challenge is out: “ChatGPT vs Google Bard: Can they write PHP code for a crossword game?“. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.