• What are you working on? V4 (HTML ISN'T PROGRAMMING)
    2,003 replies, posted
[QUOTE=TehDoomCat;18098251]stuff[/QUOTE] gravity you say, I did that in 3d a while back you can do something like this: (pseudocode) [code] //object is the thing being affected by gravity difference = normalisedVector2(gravitySource.origin - object.origin); distance = distancev2(gravitySource.origin, object.origin); distance *= distance; //square it object.momentum += difference * (arbitraryValue / distance); [/code] then add the objects momentum to its origin [b]edit:[/b] post count
[QUOTE=NovembrDobby;18098488]gravity you say, I did that in 3d a while back you can do something like this: (pseudocode) [code] //object is the thing being affected by gravity difference = normalisedVector2(gravitySource.origin - object.origin); distance = distancev2(gravitySource.origin, object.origin); distance *= distance; //square it object.momentum += difference * (arbitraryValue / distance); [/code] then add the objects momentum to its origin [b]edit:[/b] post count[/QUOTE] Okay, I don't get that... In a 2D space, what's the difference between... well, an objects origin subtracted from another, and their distance apart? 'distancev2' sounds like a function which returns the difference between two objects' origins as it is... Also, is this point gravity? I was going for 'fall to the floor' gravity, but then I changed my mind and decided I wanted it to be point gravity 'cause I could develop on it...
[QUOTE=Giraffen93;18098377][media]http://www.youtube.com/watch?v=f4pp7AbaNKM[/media] Better video.[/QUOTE] Not sure what you're showing us.
[QUOTE=gngbng;18097567]how are you parsing incoming irc commands? my php irc class using some god awful regex that breaks half the time for god knows what reason.[/QUOTE] [lua] function ircm:Think( ) -- Thanks to RabidToaster for showing me how my parsing was carp local read = self.Socket:receive( "*line" ) if not read then return end local split = explode( " ", read ) local prfx, user, cmd, args, optfarg = "", "", "", "", "" if #split < 2 then return end for k,v in pairs( split ) do split[ k ] = trim( v ) end if left( split[ 1 ], 1 ) == ":" then prfx = string.sub( split[ 1 ], 2 ) table.remove( split, 1 ) end cmd = trim( split[ 1 ] ) table.remove( split, 1 ) local gotargs = false if left( split[ 1 ], 1 ) ~= ":" then user = split[ 1 ] table.remove( split, 1 ) end -- Optional second user argument and command arguments for k,v in pairs( split ) do if left( v, 1 ) ~= ":" and not gotargs then optfarg = optfarg .. " " .. v elseif not gotargs then gotargs = true args = string.sub( v, 2 ) else args = args .. " " .. v end end self:Parse( prfx, user, cmd, args, trim( optfarg ) ) end [/lua] This is how my last IRC thingy did it. ps optfarg
[QUOTE=Ortzinator;18098800]Not sure what you're showing us.[/QUOTE] i'm guessing he recreated an engine in flash [editline]04:27PM[/editline] also, grabbing steam servers in php: [php]<?php require("bytebuffer.php"); $sock = stream_socket_client("tcp://69.28.151.178:27037", $ernum, $erstr, 15); if(!$sock) echo "$erstr ($ernum)\n"; else { fwrite($sock, "\0\0\0\x02"); fread($sock, 1); fwrite($sock, "\0\0\0\x01\x03"); $svr = new ByteBuffer(fread($sock, 1500)); $svr->get(6); while($svr->remaining() > 0) { $ip = $svr->get(4); echo inet_ntop($ip) . ":" . $svr->getShort() . "\n } fclose($sock); } ?>[/php] [code]209.197.20.99:27031 209.197.20.98:27031 68.142.72.251:27031 208.111.156.52:27031 68.142.72.253:27031 209.197.20.34:27031 66.77.143.140:27031 68.142.72.252:27031 69.28.186.162:27031 69.28.153.90:27031 69.28.153.106:27031 63.236.79.100:27031 69.28.153.108:27031 69.28.153.107:27031 69.28.153.109:27031 85.236.103.42:27031 87.248.209.212:27031 87.248.208.117:27031 87.248.208.118:27031 87.248.209.210:27031 87.248.209.211:27031 87.248.209.213:27031 87.248.208.116:27031 213.202.254.131:27031 194.124.229.14:27031 194.124.229.16:27031 194.124.229.12:27031 194.124.229.15:27031 194.124.229.99:27031 194.124.229.11:27031 62.118.240.140:27031 62.118.240.142:27031 118.107.173.150:27031 211.44.250.15:27031 118.107.173.24:27031 121.254.164.102:27031 58.120.225.166:27031 118.107.172.76:27031 61.110.195.10:27031 58.120.225.167:27031 203.66.135.26:27031 203.66.135.194:27031 203.66.135.197:27031 203.66.135.195:27031 203.66.135.193:27031 203.66.135.28:27031 203.66.135.29:27031 203.66.135.196:27031 69.28.151.182:27031 69.28.151.170:27031 209.197.6.226:27031 69.28.151.27:27031 69.28.151.26:27031 209.197.6.227:27031 68.142.116.3:27031 68.142.116.2:27031 69.28.135.84:27031 69.28.135.83:27031 69.28.135.85:27031 69.28.140.243:27031 208.111.140.6:27031 208.111.140.5:27031 69.28.140.242:27031 69.28.140.244:27031 68.142.100.74:27031 68.142.100.78:27031 68.142.100.77:27031 68.142.100.75:27031 79.141.163.3:27031 79.141.163.2:27031 87.248.196.116:27031 87.248.196.200:27031 87.248.196.117:27031 81.171.115.2:27031 81.171.115.3:27031 87.248.196.196:27031 87.248.196.197:27031 79.141.173.3:27031 208.111.182.251:27031 208.111.182.250:27031 203.46.104.8:27031 150.101.120.97:27031 213.8.254.150:27031 65.113.241.34:27031 68.177.111.62:27031 72.165.61.151:27031 65.122.178.70:27031 203.77.185.182:27031 203.77.185.181:27031 203.77.185.186:27031 203.77.185.187:27031 203.77.185.185:27031 203.77.185.3:27031 203.77.185.2:27031 203.77.185.5:27031 202.80.110.130:27031 202.80.110.131:27031 202.80.110.129:27031 203.77.190.250:27031 202.80.110.132:27031 202.80.110.133:27031 122.155.10.58:27031 117.121.248.123:27031 117.121.248.122:27031 117.121.248.124:27031 117.121.248.125:27031 193.34.49.6:27031 193.34.49.5:27031 79.141.167.4:27031 79.141.167.5:27031 193.34.49.2:27031 193.34.49.3:27031 79.141.160.2:27031 193.34.51.2:27031 193.34.51.3:27031 193.34.51.99:27031 193.34.51.100:27031 79.141.165.2:27031 80.160.78.27:27031 79.141.166.2:27031 79.141.166.3:27031 60.19.64.121:27031 119.167.242.111:27031 119.167.242.114:27031 124.131.219.31:27031 60.19.64.122:27031 119.167.242.108:27031 119.167.242.113:27031 60.19.64.124:27031 114.80.71.108:27031 61.174.18.42:27031 218.15.142.44:27031 218.15.142.42:27031 114.80.71.114:27031 118.123.14.37:27031 114.80.71.110:27031 61.174.18.43:27031 63.150.161.165:27031 68.142.119.10:27031 68.142.119.11:27031 202.22.163.246:27031 202.173.128.178:27031 203.34.186.24:27031 150.101.135.1:27031 202.72.191.174:27031 208.111.133.82:27031 68.142.81.5:27031 68.142.83.179:27031 68.142.81.2:27031 69.28.158.130:27031 68.142.81.3:27031 208.111.133.83:27031 68.142.83.178:27031 209.197.4.35:27031 209.197.4.34:27031 69.28.181.178:27031 69.28.181.180:27031 69.28.181.179:27031 209.197.4.186:27031 69.28.145.82:27031 63.236.12.142:27031 209.197.8.242:27031 208.111.158.51:27031 208.111.158.50:27031 79.141.170.10:27031 213.115.191.19:27031 79.141.164.2:27031 79.141.172.2:27031 79.141.162.2:27031 79.141.162.3:27031 202.190.75.100:27031[/code] the first step at reverse engineering the steam protocol.
[QUOTE=gngbng;18098373]no i mean stuff like ":guy!~teh@isp.com PRIVMSG #somechat :hi", unless that's what that code you pasted does (in that case your code is awful). also, why are you using inis? [b]edit:[/b] after closer looking i have determined that your code is fucking atrocious.[/QUOTE] I've always failed at good code [CODE] <?php $Explosion = explode(" ", $data, 5); $Seperate = explode("!", $Explosion[0]); $Nick = str_replace(array(chr(10), chr(13), chr(32), chr(58)), "", $Seperate[0]); $Channel = str_replace(array(chr(10), chr(13), chr(32), chr(58)), "", $Explosion[2]); $Message = substr(str_replace(array(chr(10), chr(13)), "", $Explosion[3]),1)." ".RL($Explosion[4])." ".RL($Explosion[5])." ".RL($Explosion[6]); $Time = gmdate("H:i"); if ($Explosion[1] == "JOIN") { if ($Nick != GetINI("Bot.ini","Nick") && $Nick != GetINI("Bot.ini","AltNick") ) { fputs($socket, "PRIVMSG $Channel :Welcome to $Channel, $Nick.\n"); } echo "[$Time] $Nick has joined: $Channel.\n"; LogThis(gmdate("jS"), "<pre>[$Time] $Nick has joined: $Channel.</pre>\n"); } elseif ($Explosion[1] == "PART") { echo PQ("P", $Nick, $Channel, RL($Explosion[3]), RL($Explosion[4]), RL($Explosion[5])); LogThis(gmdate("jS"), PQF("P", $Nick, $Channel, RL($Explosion[3]), RL($Explosion[4]), RL($Explosion[5]))); } elseif ($Explosion[1] == "QUIT") { echo PQ("Q", $Nick, $Channel, RL($Explosion[3]), RL($Explosion[4]), RL($Explosion[5])); LogThis(gmdate("jS"), PQF("Q", $Nick, $Channel, RL($Explosion[3]), RL($Explosion[4]), RL($Explosion[5]))); } elseif ($Explosion[1] == "PRIVMSG") { if ($Explosion[2] == GetINI("Bot.ini","Nick")) { echo "[$Time] $Nick (Personal): $Message\n"; LogThis(gmdate("jS"), "<pre>[$Time] $Nick (Personal): ".htmlspecialchars($Message, ENT_QUOTES)."</pre>\n"); } else { echo "[$Time] $Nick ($Channel): $Message\n"; LogThis(gmdate("jS"), "<pre>[$Time] $Nick ($Channel): ".htmlspecialchars($Message, ENT_QUOTES)."</pre>\n"); } } elseif ($Explosion[1] == "NOTICE") { echo "[$Time] $Nick (Personal): $Message\n"; LogThis(gmdate("jS"), "<pre>[$Time] $Nick (Personal): ".htmlspecialchars($Message, ENT_QUOTES)."</pre>\n"); } elseif ($Explosion[1] == "MODE"){ echo "[$Time] $Nick ($Channel): Changed mode for ".RL($Explosion[4]).". (".RL($Explosion[3]).").\n"; LogThis(gmdate("jS"), "<pre>[$Time] $Nick ($Channel): Changed mode for ".RL($Explosion[4]).". (".RL($Explosion[3]).").</pre>\n"); } elseif ($Explosion[0] == "PING") { } elseif ($Explosion[1] == "NICK") { echo "[$Time] $Nick has changed their nickname to ".str_replace(array(chr(10), chr(13), chr(58)), "", $Explosion[2]).".\n"; LogThis(gmdate("jS"), "<pre>[$Time] $Nick has changed their nickname to ".str_replace(array(chr(10), chr(13), chr(58)), "", $Explosion[2]).".</pre>\n"); } else { echo "[$Time] $Nick $Explosion[1] $Explosion[2] $Explosion[3] $Explosion[4]\n"; LogThis(gmdate("jS"), "<pre>[$Time] $Nick ".htmlspecialchars($Explosion[1], ENT_QUOTES)." ".htmlspecialchars($Explosion[2], ENT_QUOTES)." ".htmlspecialchars($Explosion[3], ENT_QUOTES)." ".htmlspecialchars($Explosion[4], ENT_QUOTES)."</pre>\n"); } ?> [/CODE] That's the code for displaying it.
Ok, now you can see the bots fight! [url=http://www.robertandsherman.co.uk/uploads/bots/0/]SimpleBot vs Scavenger[/url] Would anyone be interested in a competition to make the best bot? And is there anything else I should add to the map apart from ammo and health?
[QUOTE=TehDoomCat;18098701]Also, is this point gravity? I was going for 'fall to the floor' gravity, but then I changed my mind and decided I wanted it to be point gravity 'cause I could develop on it...[/QUOTE] Yep [QUOTE=TehDoomCat;18098701]In a 2D space, what's the difference between... well, an objects origin subtracted from another, and their distance apart? 'distancev2' sounds like a function which returns the difference between two objects' origins as it is...[/quote] origin minus origin gives a two-part vector showing the x/y difference, and the distance between two origins gives a single number. distancev2 just calculates the single number for a distance between them
[QUOTE=Robert64;18099257]Ok, now you can see the bots fight! [url=http://www.robertandsherman.co.uk/uploads/bots/0/]SimpleBot vs Scavenger[/url] Would anyone be interested in a competition to make the best bot? And is there anything else I should add to the map apart from ammo and health?[/QUOTE] Scavenger won after a 2 minute battle of just collecting health all the time. Jeez. I love the idea though, you should make it so everyone can test their own code. Edit: Scavenger won again.
[QUOTE=AzzyMaster;18099231]I've always failed at good code code That's the code for displaying it.[/QUOTE] [php]<?php class IRC { function __construct($server, $port) { $this->Server = $server; $this->Connected = false; $this->Socket = stream_socket_client("tcp://{$this->Server}:$port", $errno, $errstr, 30); } private function Parse($input) { // broken regex ahoy // someone fix this for me :C $regex = '/(?::(\S+)\s)?(\d{3}|[a-zA-Z]+)(?:\s((?:[^\0\n\r :][^\0\n\r ]*)(?:\s[^\0\n\r :][^\0\n\r ]*){0,13}))?(?:\s:([^\0\n\r]*))?/'; preg_match($regex, $input, $matches); if(!$matches) { return array(); } return array('prefix' => $matches[1], 'command' => $matches[2], 'params' => $matches[3], 'data' => $matches[4] ); } public function ParseName($input) { $regex = "/(.+)!(.+)@(.+)/"; preg_match($regex, $input, $matches); if(!$matches) { return array(); } $output = array('nick' => $matches[1], 'user' => $matches[2], 'host' => $matches[3] ); return $output; } function Send($command, $params = false, $data = false) { $final = "$command"; if($params) $final .= " $params"; if($data) $final .= " :$data"; $final .= "\r\n"; fwrite($this->Socket, $final); } function Recieve() { $get = fread($this->Socket, 1500); if(!$get) $this->Message = false; $this->Message = $this->Parse($get); } function Connect() { $this->Connected = true; $this->Send("NICK", $this->Nickname); $this->Send("USER", "teh \"teh\" \"{$this->Server}\"", "teh"); } function SetNickname($nick) { if($this->Connected) $this->Send("NICK", false, $nick); else $this->Nickname = $nick; } } ?>[/php] [php]<?php require("irc.php"); $irc = new IRC("irc.gamesurge.net", 6667); $irc->SetNickname("GERTY"); $irc->Connect(); while($irc->Connected) { $irc->Recieve(); if($irc->Message) { switch ($irc->Message["command"]) { case "PING": $irc->Send("PONG", false, $irc->Message["data"]); break; case "001": // on connect $irc->Send("JOIN", "#somechan"); break; case "PRIVMSG": // code to handle shit break; default: //echo "Unhandled command {$irc->Message["command"]}.\n"; break; } } } ?>[/php] have fun. it's also incomplete.
[QUOTE=Maurice;18099400]Scavenger won after a 2 minute battle of just collecting health all the time. Jeez. I love the idea though, you should make it so everyone can test their own code. Edit: Scavenger won again.[/QUOTE] Scavenger has better tactics, it scavenges for health and then ammo until it has full of both, then uses all of its ammo at once on the other bot so it doesn't have time to heal. I'll start building a site for people to upload their bots now.
[QUOTE=Jallen;18094378]I'm at home for the weekend on my Eee PC, My desktop is at my university room. Need an idea for something to occupy me... I was thinking something using SFML and maybe Box 2D, Also want to try out some 2D smoke effects with sprites some time. I could do a GUI type thing like some of you guys have done. Dunno what to make :sigh:[/QUOTE] Make a fancy screensaver.
[QUOTE=noctune9;18099656]Make a fancy screensaver.[/QUOTE] I've always gone for the blank screensavers. It seems the opposite of sensible to use a 3D or somehow processing intensive screensaver since it's the thing that shows when you aren't using your computer. It wastes power and produces heat :/ But I don't have a better idea :(
[QUOTE=Robert64;18099512]Scavenger has better tactics, it scavenges for health and then ammo until it has full of both, then uses all of its ammo at once on the other bot so it doesn't have time to heal. I'll start building a site for people to upload their bots now.[/QUOTE] That is really awesome!
Robert64: Very nice, it's like we're working on two twin projects! Scavenger is canny! I noticed your scripting language is a bit unusual, Had I noticed your post earlier, I would've advised you to use something like [url=http://code.google.com/p/as3scriptinglib/]this[/url] instead, you can have a generic bot class and pass it as the "this" object to the bot's code, which would run as standard ECMA Script. Great work, I'd write some kickass AI right now, but I'm a little busy with my own project. :eng99:
[QUOTE=gngbng;18097567]how are you parsing incoming irc commands? my php irc class using some god awful regex that breaks half the time for god knows what reason.[/QUOTE] [url]http://github.com/TheLinx/Juiz/blob/master/juiz[/url] Line 143 - 189 [QUOTE=gngbng;18099008] the first step at reverse engineering the steam protocol.[/QUOTE] [url]http://github.com/koraktor/steam-condenser[/url]
[QUOTE=thelinx;18099949][url]http://github.com/TheLinx/Juiz/blob/master/juiz[/url] Line 143 - 189 [url]http://github.com/koraktor/steam-condenser[/url][/QUOTE] first of all, i'm using php/pcre. second of all, steam condenser is totally irrelevant and high-level compared to what i am attempting.
[QUOTE=thelinx;18099949][url]http://github.com/TheLinx/Juiz/blob/master/juiz[/url][/QUOTE] Jesus, can't you assign some more things in a single line? Those first couple are a bit short. You're also doing a lot of pattern matching, that can be done much simpler. In processdata you're calling lower on the same strings over and over, seems awfully redundant. For a supposed highly modular bot, you've got a lot of hard coded responses in that parsing method of yours. And finally, a single file for the whole parser / bot control thing is insane, write your IRC library separately as a module.
[QUOTE=Robert64;18099257]Ok, now you can see the bots fight! [url=http://www.robertandsherman.co.uk/uploads/bots/0/]SimpleBot vs Scavenger[/url] Would anyone be interested in a competition to make the best bot? And is there anything else I should add to the map apart from ammo and health?[/QUOTE] haha that's brilliant!
[QUOTE=Robert64;18099512]I'll start building a site for people to upload their bots now.[/QUOTE] Ok, finished the basic site: [url]http://www.robertandsherman.co.uk/botbattle/[/url] You make an account then upload the bots you make. At the moment you can test against yourself or against a random other bot, and the outcome of the match isn't stored. I'll explain the syntax of the bot's language later if anyone is interested. Edit: Adding an update and a delete button for your bots now.
[QUOTE=Robert64;18102666]Ok, finished the basic site: [url]http://www.robertandsherman.co.uk/botbattle/[/url] You make an account then upload the bots you make. At the moment you can test against yourself or against a random other bot, and the outcome of the match isn't stored. I'll explain the syntax of the bot's language later if anyone is interested. Edit: Adding an update and a delete button for your bots now.[/QUOTE] You can abuse "move: forward;" to create faster bots :). [code] move: forward; move: forward; move: forward; [/code]
[QUOTE=Aertz;18103141]You can abuse "move: forward;" to create faster bots :).[/QUOTE] The game runs 4 commands per frame, so you can put four "move: forward;"s or "shoot;"s in a row for maximum speed. This is a valid tactic (my bot #3 uses this for shooting). But if you do that you're sacrificing if statements etc, so your bot isn't as smart. You have to balance speed and intelligence to make the best bot.
[QUOTE=Robert64;18103224]The game runs 4 commands per frame, so you can put four "move: forward;"s or "shoot;"s in a row for maximum speed. This is a valid tactic (my bot #3 uses this for shooting). But if you do that you're sacrificing if statements etc, so your bot isn't as smart. You have to balance speed and intelligence to make the best bot.[/QUOTE] Ahhh nice.
Is there a way to get the closest distance of a health or ammo?
[QUOTE=Jawalt;18103487]Is there a way to get the closest distance of a health or ammo?[/QUOTE] [code]health_x // x position of closest health health_y // y position to nearest health health_dir // relative direction to direction of bot to nearest health health_dist // distance to nearest health[/code] And same for enemy_ and ammo_ Be careful, if statements are very strict. Separate each part with a space like this: [code]if: health_dist + 16 < ammo_dist * 2;[/code] And you can only have one operator in the middle out of: [code]> = <[/code] edit: And valid colours are as follows ;) [code]white, grey, black, red, orange, yellow, green, blue, purple, brown, pink[/code]
[QUOTE=Jawalt;18103487]Is there a way to get the closest distance of a health or ammo?[/QUOTE] Without knowing exactly what you want can I suggest the following. Check all of the items within a range of co-ordinates to see if they match what you want (maybe a range of two or three rooms if doing a roguelike for example). If there is more than one then find which is closer, if there aren't any then make the range slightly larger and repeat until you have the closest desired item. Or you could simply go through every item of the desired type and calculate the distance to it and take the one with the shortest distance. That's the best I can suggest though having never done anything similar and not knowing what your making (haven't really been reading all the posts recently).
I'm going to sleep. The update button doesn't work and there are a pair of null bots (6 and 13? I think). I'll fix these tomorrow Edit: And FYI my latest bot was Scavenger M2
[QUOTE=Ortzinator;18098800]Not sure what you're showing us.[/QUOTE] [I]The game[/I] i made on the previous page..
[QUOTE=Robert64;18104142]I'm going to sleep. The update button doesn't work and there are a pair of null bots (6 and 13? I think). I'll fix these tomorrow Edit: And FYI my latest bot was Scavenger M2[/QUOTE] I'll beat it! My latest robot stands still on start and dies.
I made what I believe to be a completely unbeatable robot (like 90% of the time) it's code is as small as possible with as little logic as possible, and it's only goal is to collect ammo then kill. It's called ScavangerAdvanced.
Sorry, you need to Log In to post a reply to this thread.