Ruby VS Python 4月3日活动 平台发布+ 开始报名了~~

19 views
Skip to first unread message

Mike - GuruDigger

unread,
Mar 29, 2011, 5:31:37 AM3/29/11
to shangha...@googlegroups.com
各位, 4月3日 Ruby VS Python 比赛平台终于在大家的努力下,已经初见雏形~大家可以玩起来啦~

项目地址:https://bitbucket.org/linjunhalida/snake-challenge/wiki/Home (欢迎大家提交任何bug)

时间: 4月3日,星期天 1pm - 5pm
地点: GuruDigger Office 
奖品: 
同时我们会提供免费的食物+啤酒~

如果要报名参赛请联系我, mi...@gurudigger.com
活动更多内容以及头脑风暴区:http://gurudigger.com/idea/detail?iid=20888 , 大家一起有钱的出钱,有力的出力吧
(需要内测账户,大家要的话可以联系我。PS:我们只给工程师账户)

这里,非常非常感谢以下一直在幕后,但是对于本次活动作出巨大贡献的人:
Dorain Zhou: Designer
Ultraman: Designer

蕲春人

unread,
Mar 29, 2011, 7:35:10 AM3/29/11
to shangha...@googlegroups.com
Very nice.

--
--~--~---------~--~----~------------~-------~--~----~
Shanghai Ruby&Rails 爱好者论坛是一个非营利的民间组织,它旨在为Ruby&Rails爱好者提供一个自由,开放的交流平台,论坛每季度举行一次大型会议,会议的所有费用由赞助商支付,来宾不需交纳任何费用。
We push the china ruby&rails community forward!!
Shanghai Ruby&Rails的邮件列表地址是 shangha...@googlegroups.com
要了解更多详情,请访问 http://groups.google.com/group/shanghaionrails?hl=en?hl=en
退订请发送mail到 shanghaionrai...@googlegroups.com
--~--~---------~--~----~------------~-------~--~----~



--



http://www.cqror.com

mike cai

unread,
Mar 30, 2011, 3:18:38 AM3/30/11
to Shanghai on Rails
比赛还有10个名额
似乎现在报名的都是python的
ruby只有quake一个人报名了

/mike from GuruDigger

On Mar 29, 7:35 pm, 蕲春人 <whyr...@gmail.com> wrote:
> Very nice.
>

> 在 2011年3月29日 下午5:31,Mike - GuruDigger <m...@gurudigger.com>写道:
>
>
>
>
>
>
>
>
>
> > 各位, 4月3日 Ruby VS Python 比赛平台终于在大家的努力下,已经初见雏形~大家可以玩起来啦~
>

> > *项目地址:https://bitbucket.org/linjunhalida/snake-challenge/wiki/Home
> > (欢迎大家提交任何bug)*
> > <https://bitbucket.org/linjunhalida/snake-challenge/wiki/Home>
> > *时间: 4月3日,星期天 1pm - 5pm*

> > 如果要报名参赛请联系我, m...@gurudigger.com
> > *活动更多内容以及头脑风暴区:http://gurudigger.com/idea/detail?iid=20888,
> > 大家一起有钱的出钱,有力的出力吧*
> > (需要内测账户,大家要的话可以联系我。PS:我们只给工程师账户)
>
> > *这里,非常非常感谢以下一直在幕后,但是对于本次活动作出巨大贡献的人:*
> > *Linjunhalida *:http://gurudigger.com/profile/?uid=5140
> > *Quake Wang*:http://gurudigger.com/profile/?uid=6114
> > *Ray**58750034*:http://gurudigger.com/profile/?uid=10514
> > *TualatriX*:http://gurudigger.com/profile/?uid=21287
> > *Dorain Zhou*: Designer
> > *Ultraman*: Designer
>
> > --
> > --~--~---------~--~----~------------~-------~--~----~
> > Shanghai Ruby&Rails
> > 爱好者论坛是一个非营利的民间组织,它旨在为Ruby&Rails爱好者提供一个自由,开放的交流平台,论坛每季度举行一次大型会议,会议的所有费用由赞助商支 付,来宾不需交纳任何费用。


> > We push the china ruby&rails community forward!!
> > Shanghai Ruby&Rails的邮件列表地址是 shangha...@googlegroups.com

> > 要了解更多详情,请访问http://groups.google.com/group/shanghaionrails?hl=en?hl=en

mike cai

unread,
Mar 30, 2011, 12:34:29 PM3/30/11
to Shanghai on Rails
活动官网: rubyvspython.org

femto Zheng

unread,
Mar 30, 2011, 11:57:12 PM3/30/11
to shangha...@googlegroups.com
报名,
如果有时间就过去,
如果没时间就把代码提交过去。

2011/3/31 mike cai <jin....@gmail.com>
活动官网: rubyvspython.org
Shanghai Ruby&Rails 爱好者论坛是一个非营利的民间组织,它旨在为Ruby&Rails爱好者提供一个自由,开放的交流平台,论坛每季度举行一次大型会议,会议的所有费用由赞助商支付,来宾不需交纳任何费用。

We push the china ruby&rails community forward!!
Shanghai Ruby&Rails的邮件列表地址是 shangha...@googlegroups.com
要了解更多详情,请访问 http://groups.google.com/group/shanghaionrails?hl=en?hl=en
退订请发送mail到 shanghaionrai...@googlegroups.com
--~--~---------~--~----~------------~-------~--~----~



--
http://hi.baidu.com/femto

Quake Wang

unread,
Mar 31, 2011, 12:11:05 AM3/31/11
to shangha...@googlegroups.com
哈哈,我总算不用单挑一群Python选手了,鸭梨很大阿,还有其他Ruby程序员一起来玩么?

2011/3/31 femto Zheng <femt...@gmail.com>:

stainless

unread,
Mar 31, 2011, 12:19:55 AM3/31/11
to shangha...@googlegroups.com
可以到 http://www.rubyflow.com/ 之类的地方宣传下

mike cai

unread,
Mar 31, 2011, 3:52:40 AM3/31/11
to Shanghai on Rails
哈哈 你现在还是Ruby的唯一独苗~~
这个你成为最终冠军就强大了啊

/mike from GuruDigger

On Mar 31, 12:11 pm, Quake Wang <quake.w...@gmail.com> wrote:
> 哈哈,我总算不用单挑一群Python选手了,鸭梨很大阿,还有其他Ruby程序员一起来玩么?
>

> 2011/3/31 femto Zheng <femto...@gmail.com>:
>
>
>
>
>
>
>
> > 报名,
> > 如果有时间就过去,
> > 如果没时间就把代码提交过去。
>
> > 2011/3/31 mike cai <jin.ca...@gmail.com>

> >http://hi.baidu.com/femto
> >http://www.aisiming.com/
>
> > --
> > --~--~---------~--~----~------------~-------~--~----~
> > Shanghai Ruby&Rails

mike cai

unread,
Apr 1, 2011, 4:23:44 AM4/1/11
to Shanghai on Rails
今天有了2个rubyist报名,一位还是正好来上海旅游的加拿大籍华人,我是越来越期待比赛了
http://gurudigger.com/idea/detail?iid=20888

mike cai

unread,
Apr 2, 2011, 5:07:22 AM4/2/11
to Shanghai on Rails
一个小提示:所有明天围观群众(除了已经对于本项目捐赠过的)都需要有一个小测验,才能进入。这个测验游戏大家一定都玩过。:)
idea brainstorming: http:// goo.gl/ZIdQa

/mike from GuruDigger

On Apr 1, 4:23 pm, mike cai <jin.ca...@gmail.com> wrote:
> 今天有了2个rubyist报名,一位还是正好来上海旅游的加拿大籍华人,我是越来越期待比赛了http://gurudigger.com/idea/detail?iid=20888

Takeshi Koeda

unread,
Apr 2, 2011, 5:07:15 PM4/2/11
to Shanghai on Rails
大家,你好。我也是报名。想看看。还在可以吗?
我是一个日本人。请多多关照。

地址是这个flyer上面的吗
http://yfrog.com/z/gzjkd2j

Quake Wang

unread,
Apr 2, 2011, 9:49:03 PM4/2/11
to shangha...@googlegroups.com
欢迎欢迎,我们今天下午1点就要开始了,地点就是这个海报上写的。
在一个民房里面,有一点难找,到时候如果找不到的话,你可以联系一下Mike Cai: 13817775744

2011/4/3 Takeshi Koeda <kembo.k...@gmail.com>:

> Shanghai Ruby&Rails 爱好者论坛是一个非营利的民间组织,它旨在为Ruby&Rails爱好者提供一个自由,开放的交流平台,论坛每季度举行一次大型会议,会议的所有费用由赞助商支付,来宾不需交纳任何费用。


> We push the china ruby&rails community forward!!
> Shanghai Ruby&Rails的邮件列表地址是 shangha...@googlegroups.com

femto Zheng

unread,
Apr 3, 2011, 7:09:31 AM4/3/11
to shangha...@googlegroups.com
回来了,准备将今天的代码开源


2011/4/3 Quake Wang <quake...@gmail.com>
330.gif

mike cai

unread,
Apr 3, 2011, 8:09:26 AM4/3/11
to Shanghai on Rails
haha 恭喜Femto Zheng
大家以后有什么想法,也欢迎到GD(http://gurudigger.com/idea/detail?iid=20888)上面去讨论交流,这样
可以把Python 和 Ruby的互相交流起来,这个也是我们搞这个pythonvsruby的最大目的~

On Apr 3, 7:09 pm, femto Zheng <femto...@gmail.com> wrote:
> 回来了,准备将今天的代码开源
> [?]
>
> 2011/4/3 Quake Wang <quake.w...@gmail.com>


>
>
>
>
>
>
>
>
>
> > 欢迎欢迎,我们今天下午1点就要开始了,地点就是这个海报上写的。
> > 在一个民房里面,有一点难找,到时候如果找不到的话,你可以联系一下Mike Cai: 13817775744
>

> > 2011/4/3 Takeshi Koeda <kembo.koeda....@gmail.com>:

> > >> > > > >> > > > 要了解更多详情,请访问
> >http://groups.google.com/group/shanghaionrails?hl=en?hl=en
> > >> > > > >> > > > 退订请发送mail到 shanghaionrai...@googlegroups.com
> > >> > > > >> > > > --~--~---------~--~----~------------~-------~--~----~
>
> > >> > > > >> > > --
>

> > >> > > > >> > >http://www.cqror.com
>
> > >> > > > >> --
> > >> > > > >> --~--~---------~--~----~------------~-------~--~----~
> > >> > > > >> Shanghai Ruby&Rails
>
> > 爱好者论坛是一个非营利的民间组织,它旨在为Ruby&Rails爱好者提供一个自由,开放的交流平台,论坛每季度举行一次大型会议,会议的所有费用由赞助商支
> > 付,来宾不需交纳任何费用。
> > >> > > > >> We push the china ruby&rails community forward!!
> > >> > > > >> Shanghai Ruby&Rails的邮件列表地址是 shangha...@googlegroups.com

> > >> > > > >> 要了解更多详情,请访问
> >http://groups.google.com/group/shanghaionrails?hl=en?hl=en
> > >> > > > >> 退订请发送mail到 shanghaionrai...@googlegroups.com
> > >> > > > >> --~--~---------~--~----~------------~-------~--~----~
>
> > >> > > > > --
> > >> > > > >http://hi.baidu.com/femto
> > >> > > > >http://www.aisiming.com/
>

> > >> > > > > --
> > >> > > > > --~--~---------~--~----~------------~-------~--~----~
> > >> > > > > Shanghai Ruby&Rails
>
> > 爱好者论坛是一个非营利的民间组织,它旨在为Ruby&Rails爱好者提供一个自由,开放的交流平台,论坛每季度举行一次大型会议,会议的所有费用由赞助商支
> > 付,来宾不需交纳任何费用。
> > >> > > > > We push the china ruby&rails community forward!!
> > >> > > > > Shanghai Ruby&Rails的邮件列表地址是 shangha...@googlegroups.com

> > >> > > > > 要了解更多详情,请访问
> >http://groups.google.com/group/shanghaionrails?hl=en?hl=en
> > >> > > > > 退订请发送mail到 shanghaionrai...@googlegroups.com
> > >> > > > > --~--~---------~--~----~------------~-------~--~----~
>
> > > --
> > > --~--~---------~--~----~------------~-------~--~----~
> > > Shanghai Ruby&Rails

> > 爱好者论坛是一个非营利的民间组织,它旨在为Ruby&Rails爱好者提供一个自由,开放的交流平台,论坛每季度举行一次大型会议,会议的所有费用由赞助商支 付,来宾不需交纳任何费用。
> > > We push the china ruby&rails community forward!!
> > > Shanghai Ruby&Rails的邮件列表地址是 shangha...@googlegroups.com
> > > 要了解更多详情,请访问http://groups.google.com/group/shanghaionrails?hl=en?hl=en
> > > 退订请发送mail到 shanghaionrai...@googlegroups.com
> > > --~--~---------~--~----~------------~-------~--~----~
>
> > --
> > --~--~---------~--~----~------------~-------~--~----~
> > Shanghai Ruby&Rails

> > 爱好者论坛是一个非营利的民间组织,它旨在为Ruby&Rails爱好者提供一个自由,开放的交流平台,论坛每季度举行一次大型会议,会议的所有费用由赞助商支 付,来宾不需交纳任何费用。
> > We push the china ruby&rails community forward!!
> > Shanghai Ruby&Rails的邮件列表地址是 shangha...@googlegroups.com
> > 要了解更多详情,请访问http://groups.google.com/group/shanghaionrails?hl=en?hl=en
> > 退订请发送mail到 shanghaionrai...@googlegroups.com
> > --~--~---------~--~----~------------~-------~--~----~
>

> --http://hi.baidu.com/femtohttp://www.aisiming.com/
>
> 330.gif
> < 1KViewDownload

femto Zheng

unread,
Apr 6, 2011, 3:28:18 AM4/6/11
to shangha...@googlegroups.com
大致说一下思路:
这次比赛,有一下几个目标:
1.寻路,用最短的路寻到食物
2.防止陷阱,不能跑进陷阱撞死
3.绞杀敌蛇
4.联合己方蛇绞杀敌蛇

以下一一分析,并且贴出一些关键代码

1.寻路
我用astar算法

def astar(info, start, goal, enemy_food_type)
  return nil if goal.nil?
  closedset      = Set.new
  openset        = Set.new([start])
  came_from      = {}
  go_for         = {}
  g_score        = {}
  h_score        = {}
  f_score        = {}
  g_score[start] = 0
  h_score[start] = dist(start, goal)
  f_score[start] = h_score[start]
  while !openset.empty?

    x = openset.min_by { |node| f_score[node] }
    if x == goal
      return reconstruct_path(came_from, goal)
      #return go_for[start]
    end

    openset.delete(x)
    closedset.add(x)

    neighbors = []
    if !obstacle(info, x, 0, g_score[x], enemy_food_type)
      neighbors << left_point(x)
    end
    if !obstacle(info, x, 1, g_score[x], enemy_food_type)
      neighbors << upper_point(x)
    end
    if !obstacle(info, x, 2, g_score[x], enemy_food_type)
      neighbors << right_point(x)
    end

    if !obstacle(info, x, 3, g_score[x], enemy_food_type)
      neighbors << down_point(x)
    end


    neighbors.each do |y|
      if closedset.include?(y)
        next
      end
      tentative_g_score = g_score[x] + 1

      if !openset.include?(y)
        openset.add(y)
        tentative_is_better = true
      elsif tentative_g_score < g_score[y]
        tentative_is_better = true
      else
        tentative_is_better = false
      end

      if tentative_is_better = true
        came_from[y] = x
        g_score[y]   = tentative_g_score
        h_score[y]   = dist(y, goal)
        f_score[y]   = g_score[y] + h_score[y]
        #openset.delete(y)
      end


    end

  end
  #else failure
end

def reconstruct_path(came_from, current_node)
  if !came_from[current_node].nil?
    p = reconstruct_path(came_from, came_from[current_node])
    return (p + [current_node])
  else
    return [current_node]
  end
end

2.防止陷阱,不能跑进陷阱撞死, 代码如下

def trap(info, seq, path, enemy_food_type)
 
  depth = 5
  if !path.empty?
    live_nodes = Set.new([path.last])
  else
    live_nodes = Set.new([info["snakes"][seq]["body"][0]])
  end
  other_obstacles = path.clone if path
  other_obstacles ||= []
  other_obstacles = other_obstacles.reverse
  other_obstacles = other_obstacles[0..info["snakes"][seq]["body"].size]
  while !live_nodes.empty? && depth >=0
    node = live_nodes.to_a[0]
    live_nodes.delete(node)
    other_obstacles << node

    if !obstacle(info, node, 0, path.length-2, enemy_food_type, other_obstacles)
      live_nodes << left_point(node)
    end
    if !obstacle(info, node, 1, path.length-2, enemy_food_type, other_obstacles)
      live_nodes << upper_point(node)
    end
    if !obstacle(info, node, 2, path.length-2, enemy_food_type, other_obstacles)
      live_nodes << right_point(node)
    end
    if !obstacle(info, node, 3, path.length-2, enemy_food_type, other_obstacles)
      live_nodes << down_point(node)
    end

    depth -= 1
  end
  return live_nodes.size == 0 #if nothing left, consider a trap
end
3.绞杀敌蛇
实测,600个回合,大体能吃到40-50身长,很难把敌方绕死,而且如果敌方也写了
防陷阱算法,那么这个等于没用。并且,即使只绕一个食物,走一个食物的周边,
也有7格,那么再提前去这食物之前,再考虑7格,14格的深度,太深了,本来写了
决策树搜索的,不过太深了,去掉了。基本对这次比赛无效。

4.联合己方蛇绞杀敌蛇
同理,两个问题,1.决策树太深, 2.无法判断己方蛇的ai算法,没办法那么聪明绞杀敌蛇。
而且实际中发现,同一种类型的蛇反而是竞争者,因为抢同一种食物吃。所以这种算法
也没用,去掉了。

同步发在自己的博客上
http://hi.baidu.com/femto
http://t.sina.com.cn/femtowin




2011/4/3 mike cai <jin....@gmail.com>
--~--~---------~--~----~------------~-------~--~----~
Shanghai Ruby&Rails 爱好者论坛是一个非营利的民间组织,它旨在为Ruby&Rails爱好者提供一个自由,开放的交流平台,论坛每季度举行一次大型会议,会议的所有费用由赞助商支付,来宾不需交纳任何费用。

We push the china ruby&rails community forward!!
Shanghai Ruby&Rails的邮件列表地址是 shangha...@googlegroups.com
要了解更多详情,请访问 http://groups.google.com/group/shanghaionrails?hl=en?hl=en
退订请发送mail到 shanghaionrai...@googlegroups.com
--~--~---------~--~----~------------~-------~--~----~
Reply all
Reply to author
Forward
0 new messages