wavesinaroom / my_odin_project_battleship

0 stars 0 forks source link

CPU player #9

Closed wavesinaroom closed 1 year ago

wavesinaroom commented 1 year ago

The game is played against the computer, so make ‘computer’ players capable of making random plays. The AI does not have to be smart, but it should know whether or not a given move is legal. (i.e. it shouldn’t shoot the same coordinate twice).

wavesinaroom commented 1 year ago

Sometimes I feel that debugging tests is a hurdle for the project. On one hand I've found myself spending way too much time on a task because the test itself is buggy and my code is alright, that's annoying. On the other hand, my code is a lot simpler and cleaner thanks to TDD which makes me think that writing test is an art itself that needs more of my time. In the meantime, I'm gonna keep going with a not so cool design for creating CPU cause I'd not like to debug Jest when I remove the CPU module

wavesinaroom commented 1 year ago

Basic firing cpu attack function has already been tested. I'm still deciding whether coding a more intelligent attack AI or not

wavesinaroom commented 1 year ago

I've already coded some lines of code in placeRandomShip function that effectively place a randomship but it's likely to dissapear cause there's a much more accurate way to place ship that are within board boundaries and off of tiles with ships

wavesinaroom commented 1 year ago

Tried to code a function that checks random coordinate surrounding to avoid random ship placement clashing. Then, I realized that'd already been covered in gameboard.js... funny thing. Maybe that happened because the project grew and I couldn't remember all it space immediately. That makes me think ahead of a way to document my progress to avoid delays in production. Perhaps, checking gh issue more often helps.

wavesinaroom commented 1 year ago

For now, I'll leave CPU and the rest of the scripts because further changes may come alongside the HTML and CSS production stages