d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Peer-to-peer C++
123Next
Add Reply New Topic New Poll
Member
Posts: 11,153
Joined: Aug 23 2008
Gold: 4,230.00
Oct 12 2018 02:09pm
I'd like to program a simple battlehship game played on command line (c++). I have 2 routes: Add AI as the only opponent or include network capabilities.

My question is for the second route. I'd like to do this, however, all my google searches aren't coming up with anything on how to program network capabilities into a game. Does anyone have an online resource that goes through this?

As for the method of connecting I'd like to go with the easier method to code (assuming it would be peer-to-peer).
Member
Posts: 11,273
Joined: Apr 26 2008
Gold: 3,303.50
Oct 12 2018 02:34pm
If you want to hardcode you can use sockets. There are some middlewares which makes the communication easier.
I don't know how low level you want to go but let me know more details :)
Member
Posts: 11,153
Joined: Aug 23 2008
Gold: 4,230.00
Oct 12 2018 04:09pm
Quote (xapeu @ Oct 12 2018 10:34pm)
If you want to hardcode you can use sockets. There are some middlewares which makes the communication easier.
I don't know how low level you want to go but let me know more details :)


as low level as possible. I'm in a programming fundamentals class so I don't have much knowledge. It is just something I have a personal interest in and would like to start somewhere. I would much prefer hard-coded. Will be my final project for a class and I don't think middle-ware is allowed or at the very least, not recommended. I will look into sockets thanks. :D
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 12 2018 04:55pm
does it actually have to be a good AI? if you just need an opponent who can randomly play, that would probably be easier to code.
Member
Posts: 11,273
Joined: Apr 26 2008
Gold: 3,303.50
Oct 12 2018 05:08pm
Quote (carteblanche @ Oct 12 2018 10:55pm)
does it actually have to be a good AI? if you just need an opponent who can randomly play, that would probably be easier to code.


Agree here. Will you only do one of the two options? Random is not that bad and could easily be adapted to a better strategy such as random until hit and then "find" the boat.

I suggest you to do a separate project for the socket part. Try to first pass simple messages between two machines and then adapt it to the game after it is fully coded
Member
Posts: 11,153
Joined: Aug 23 2008
Gold: 4,230.00
Oct 12 2018 06:52pm
Quote (carteblanche @ Oct 13 2018 12:55am)
does it actually have to be a good AI? if you just need an opponent who can randomly play, that would probably be easier to code.


I plan to implement both. the AI I have no problems doing (as it will just be doing it randomly ignoring already called locations, unless it gets a hit). Adding a "pvp" mode is more of a personal challenge.

Quote (xapeu @ Oct 13 2018 01:08am)
Agree here. Will you only do one of the two options? Random is not that bad and could easily be adapted to a better strategy such as random until hit and then "find" the boat.

I suggest you to do a separate project for the socket part. Try to first pass simple messages between two machines and then adapt it to the game after it is fully coded


Thanks for the advice; I definitely will experiment before just trying to jump in. I am quite a ways from when this is due. This post was mainly in search of material i can research to learn as my google skills have failed me. However, it seems I was missing a keyword in my search (socket).
Member
Posts: 11,273
Joined: Apr 26 2008
Gold: 3,303.50
Oct 13 2018 02:37am
http://www.datagenetics.com/blog/december32011/index.html

maybe this will help with the AI part xD
Member
Posts: 12,703
Joined: May 17 2013
Gold: 2,935.00
Oct 13 2018 10:25am
Networking will surface a few issues, such as needing to do NAT hole punching and the like, if people don't port forward.

I'd recommend finding something that can take care of most of the low level stuff like sockets that includes hole punching, unless you want to learn about that.

You would need an external server to the clients to do that though.

This post was edited by Klexmoo on Oct 13 2018 10:26am
Member
Posts: 11,153
Joined: Aug 23 2008
Gold: 4,230.00
Oct 13 2018 04:37pm
Quote (Klexmoo @ Oct 13 2018 06:25pm)
Networking will surface a few issues, such as needing to do NAT hole punching and the like, if people don't port forward.

I'd recommend finding something that can take care of most of the low level stuff like sockets that includes hole punching, unless you want to learn about that.

You would need an external server to the clients to do that though.


Would I still require the hole punching and server for LAN play? wasn't planning to run this over the cloud. Just local lan setup.

Quote (xapeu @ Oct 13 2018 10:37am)
http://www.datagenetics.com/blog/december32011/index.html

maybe this will help with the AI part xD


wow. thats cool and helpful. allows different modes for AI as well :)
Member
Posts: 11,153
Joined: Aug 23 2008
Gold: 4,230.00
Oct 13 2018 08:30pm
Unfortunately I probably won't be able to implement the probability as it will be a console game. Seems to be too complex to implement the required counter for the cells in a console program. Or at least too complex for me to calculate each individual cell for it. There is probably a simple loop that calculates it all for each cell but I just can't think of it right now. I will cross that bridge when it comes time.

This post was edited by kasey21 on Oct 13 2018 08:31pm
Go Back To Programming & Development Topic List
123Next
Add Reply New Topic New Poll