News for hackers. Stuff that matters.
Re:Battleship by drekipus on Saturday April 02, 2022 @06:04PM (#30892066)
This reminds me of a project idea I had...

I was thinking of setting up a small server that can emulate some up multiplayer games, such as battleship, connect 4, even perhaps monopoly.

Then people submit code, or connect their machines to it, and it becomes "battle of the algorithms".

You'd have to register an algorithm name / version, and compete a few times against other algorithms, to be placed on the leaderboard for that game*.

Each game could just be stored as plaintext, so it would be easy to replay each move and visualise it on the website.

I haven't yet begun creating it, but it'd be great to see how your algorithm would work against another; You'd also have to consider how to place your ships as well. (probably sticking them in the corners could be easily dealt with, right?

Looking at this algorithm it seems like it's pretty optimal, I don't think there's much else that could be done with Battleships. Playing with other human players would be a different outcome..

* I would only really expect algorithms work per game, not across games.

Re:Battleship by hntcz on Saturday April 02, 2022 @06:10PM (#30892115)
About 20 years ago when I was a teenager Microsoft did this in my country with rock-paper-scissors. XML-RPC-based web services were new at the time and they promoted it this way. You hosted your own web service and they called it to play, I think 10 or 20 games against each opponent in your group. Obviously you can't get an edge against someone playing completely randomly but they placed a bunch of simpler bots in the groups that you could detect (e.g, always playing a pattern). Group winners made it to the final. It was awesome, thanks for reminding me of that memory!
Re:Battleship by mormegil on Sunday April 03, 2022 @02:32AM (#30894927)
> you can't get an edge against someone playing completely randomly

Sure, random choice is not only a Nash equilibrium, it even has a fixed expected value without regard to the other player's strategy, _but_ that is only in the basic two-player game. If you have a tournament and some players use other strategies, you can get better score against them by a non-random strategy, meaning you can beat the random strategy in the global tournament. But it also means someone can defeat you! Which means RPS tournaments are interesting even if the game seemed almost trivial!

Re:Battleship by evil-olive on Saturday April 02, 2022 @07:15PM (#30892537)
not exactly the same because it's not playing an established human vs. human game such as Battleship, but Core War [0] from 1984 is the earliest example of this idea that I'm aware of.

> At the beginning of a game, each battle program is loaded into memory at a random location, after which each program executes one instruction in turn. The goal of the game is to cause the processes of opposing programs to terminate (which happens if they execute an invalid instruction), leaving the victorious program in sole possession of the machine.

Battlecode [1] from MIT seems to be along similar lines as well

0: https://en.wikipedia.org/wiki/Core_War

1: https://battlecode.org/

Re:Battleship by jhbadger on Saturday April 02, 2022 @08:48PM (#30893118)
Corewar may be the first example of the game in its purest form, but earlier than that was Robotwar (first on the PLATO system in the 1970s then on the Apple ][ in 1981) which involved players writing simple programs to control robots in a BASIC like language. You could either compete against a friend or compete against a series of programs included with the game.

https://en.wikipedia.org/wiki/RobotWar

Re:Battleship by pr0gramm on Sunday April 03, 2022 @04:51AM (#30895496)
We (http://pr0gramm.com) had a multiplayer battleship[1] for our april's fools two days ago. All users were divided into a red and blue team and then voted for the next shot. For our april's fools in 2018 we did the same with connect 4[2].

The games itself are not that interesting (altough OP certainly disagrees), but the social dynamics, shitposts and memes that came out of this were fascinating.

[1] https://vid.pr0gramm.com/2022/04/02/e9c168457179b582.mp4

[2] https://vid.pr0gramm.com/2018/04/01/fa0b52dacd80da53.mp4

Re:Battleship by gusgus01 on Saturday April 02, 2022 @07:06PM (#30892478)
StarCraft 2 has a pretty active version of this! I've always wanted to play around with it but I lost a lot of steam when I wanted to upstream some changes to the various libraries involved and my employer vetoed the idea.

https://sc2ai.net/

Re:Battleship by Aeolun on Sunday April 03, 2022 @05:33AM (#30895648)
Your employer vetoed the idea?How are they related to that?
Re:Battleship by gusgus01 on Monday April 04, 2022 @12:41AM (#30903362)
I work in America, so my employer owns my entire being. Specifically, in order to commit to open source, do any independent project, etc, I need to get permission from my employer that it doesn't compete with them and that they are willing to relinquish the copyright/IP rights.
Re:Battleship by aleksiy123 on Saturday April 02, 2022 @06:26PM (#30892217)
There is a snake version of this called Battlesnake https://play.battlesnake.com/

Did it while I was in university. I even won one of the categories one year.

Re:Battleship by Carbocarde on Saturday April 02, 2022 @06:24PM (#30892207)
I actually started working on that with some of my friends, here's a link: https://github.com/Carbocarde/games

We were planning on eventually making it into a website and doing a leaderboard.

The program works by having agents that write to stdout and a game that reads from stdin. That way we can kinda avoid some of the security issues around running untrusted code.

Still has a lot of work to be done before it's ready to simulate battleship :)

Re:Battleship by dawidloubser on Sunday April 03, 2022 @03:35AM (#30895163)
One of the first incantations of this idea that I encountered, when I had just started working at my first corporate job back in the day, was Robocode ( https://robocode.sourceforge.io/ ) - it was great fun, and I see it's still going.
Re:Battleship by flir on Saturday April 02, 2022 @08:44PM (#30893096)
I think there's only two possible outcomes - either a best solution emerges, or a rock-paper-scissors scenario emerges with a number of solutions.

If there's another outcome I'm missing, I'd like to hear about it (stalemate?)

Re:Battleship by bckr on Saturday April 02, 2022 @08:10PM (#30892859)
Might want to chat with this user: https://news.ycombinator.com/user?id=mathgladiator

Who has a SaaS prototype for creating board game servers

Re:Battleship by Delgan on Saturday April 02, 2022 @07:07PM (#30892480)
It reminds me of the multiplayer section from CodinGame website: https://www.codingame.com/multiplayer/bot-programming

Although there is no specific implementation for Battleship, but I believe that some users sometimes have the possibility to create and submit their own games.

Re:Battleship by kwhitefoot on Sunday April 03, 2022 @08:54AM (#30896489)
Reminds me of Robert Axelrod's computer tournament, won by Anatol Rapoport's Tit for Tat. See https://lps.library.cmu.edu/NCMR/article/351/galley/355/view...
Re:Battleship by kayamon on Saturday April 02, 2022 @09:19PM (#30893317)
I wanna say the Metropolis-Hastings algorithm is probably the best way to explore any probability distribution like this. The core algorithm is pretty similar to battleships -- pick a random point from a map, then explore neighbouring points, use the difference between predicted and measured results to update the map, and when bored do random restarts.
Re:Battleship by onionisafruit on Saturday April 02, 2022 @06:11PM (#30892117)
I worked on something like that for a while that I never finished. One of the stumbling blocks was executing untrusted code. I settled on having players either connect via websocket or receiving webhooks and having to respond in a given time frame.
Re:Battleship by tomcam on Saturday April 02, 2022 @08:19PM (#30892907)
I don’t understand the executing of entrusted code part. If the instructions are plain text, how could it even be a problem? The instruction FIRE(5,7) isn’t going to turn into a zero day exploit, right?
Re:Battleship by flir on Saturday April 02, 2022 @08:46PM (#30893106)
How did you decide to fire at 5,7 though?
Re:Battleship by tomcam on Sunday April 03, 2022 @07:46PM (#30901931)
In a game of battleship it’s a human player who would write down the text, correct? But that doesn’t matter at all. It seems to me it could be a very simple text protocol with literally zero chance of binary execution exploits
Re:Battleship by kevinwang on Sunday April 03, 2022 @08:33AM (#30896369)
To add on to the list of bot competitions: there's a really great one with a nice interface for a version of blind chess: https://rbc.jhuapl.edu/
Re:Battleship by debbiedowner on Saturday April 02, 2022 @06:58PM (#30892422)
I participated in a "ruby fight club" like this a few years ago hosted by grouper: https://github.com/Grouper/battleship
Re:Battleship by captn3m0 on Sunday April 03, 2022 @03:49AM (#30895221)
Want to build the same, but using boardgame.io. Search for Gym here: https://github.com/captn3m0/ideas
Re:Battleship by dpflug on Sunday April 03, 2022 @11:35PM (#30903107)
There's some effort in that direction here: http://ggp.stanford.edu/
Re:Battleship by IIAOPSW on Saturday April 02, 2022 @11:15PM (#30894071)
I think you are teetering on the edge of the rabbit hole of a domain specific language for the representation of board game rules. Unless you want to write a new emulator for each new multiplayer game, that's the hole you'll dive down. But once down there, you'll realize you're basically making a programming language with a board game theme, as any language sophisticated enough to represent most board games is destined to become a Turing tarpit. At that point the project has become self defeating, as you are now coding each new game in a programming language you invented to avoid coding each new game.
Re:Battleship by gnopgnip on Saturday April 02, 2022 @07:44PM (#30892700)
Screeps is similar